diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 5be38e6f0..3cf4a99a5 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -497,17 +497,21 @@ void clangimport::AstNode::dumpAst(int num, int indent) const void clangimport::AstNode::setLocations(TokenList *tokenList, int file, int line, int col) { for (const std::string &ext: mExtTokens) { - if (ext.compare(0,5,"appendFileIfNew(ext.substr(1, sep1 - 1)); - line = MathLib::toLongNumber(ext.substr(sep1+1, sep2-sep1)); + } else if (ext[0] == '<') { + const std::string::size_type colon = ext.find(':'); + if (colon != std::string::npos) { + const bool windowsPath = colon == 2 && ext.size() > 4 && ext[3] == '\\'; + std::string::size_type sep1 = windowsPath ? ext.find(':', 4) : colon; + std::string::size_type sep2 = ext.find(':', sep1 + 1); + file = tokenList->appendFileIfNew(ext.substr(1, sep1 - 1)); + line = MathLib::toLongNumber(ext.substr(sep1 + 1, sep2 - sep1 - 1)); + } } } mFile = file; diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index ec6dc43c0..40b021014 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -584,7 +584,10 @@ private: } void cxxRecordDecl1() { - const char clang[] = "`-CXXRecordDecl 0x34cc5f8 <1.cpp:2:1, col:7> col:7 class Foo"; + const char* clang = "`-CXXRecordDecl 0x34cc5f8 <1.cpp:2:1, col:7> col:7 class Foo"; + ASSERT_EQUALS("class Foo ;", parse(clang)); + + clang = "`-CXXRecordDecl 0x34cc5f8 col:7 class Foo"; ASSERT_EQUALS("class Foo ;", parse(clang)); }