Skip to content

Commit c501a4a

Browse files
committed
fix
1 parent 60a59a2 commit c501a4a

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/clangimport.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,24 @@ static std::vector<std::string> splitString(const std::string &line)
217217
return ret;
218218
}
219219

220+
static std::string::size_type getQualTypeSplitPos(const std::string& qualType) {
221+
const auto pos1 = qualType.find_first_of("[(");
222+
if (pos1 == std::string::npos)
223+
return pos1;
224+
if (qualType[pos1] == '[')
225+
return pos1;
226+
const auto pos2 = qualType.find(")(");
227+
return (pos2 == std::string::npos) ? pos1 : std::string::npos;
228+
}
229+
220230
static std::string getQualTypeBefore(const std::string& qualType) {
221-
return qualType.find_first_of("[(") != std::string::npos ? qualType.substr(0, qualType.find_first_of("[(")) : qualType;
231+
const auto pos = getQualTypeSplitPos(qualType);
232+
return (pos == std::string::npos) ? qualType : qualType.substr(0, pos);
222233
}
223234

224235
static std::string getQualTypeAfter(const std::string& qualType) {
225-
return qualType.find_first_of("[(") != std::string::npos ? qualType.substr(qualType.find_first_of("[(")) : "";
236+
const auto pos = getQualTypeSplitPos(qualType);
237+
return (pos == std::string::npos) ? "" : qualType.substr(pos);
226238
}
227239

228240
namespace clangimport {

0 commit comments

Comments
 (0)