diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 33c8c9d5a..14219ee98 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -117,7 +117,16 @@ static std::vector splitString(const std::string &line) pos2 = line.find("\'", pos2 + 3); } else { pos2 = line.find(" ", pos1) - 1; - if (std::isalpha(line[pos1]) && + if ((std::isalpha(line[pos1]) || line[pos1] == '_') && + line.find("::", pos1) < pos2 && + line.find("::", pos1) < line.find("<", pos1)) { + pos2 = line.find("::", pos1); + ret.push_back(line.substr(pos1, pos2-pos1)); + ret.push_back("::"); + pos1 = pos2 + 2; + continue; + } + if ((std::isalpha(line[pos1]) || line[pos1] == '_') && line.find("<", pos1) < pos2 && line.find("<<",pos1) != line.find("<",pos1) && line.find(">", pos1) != std::string::npos && @@ -457,7 +466,7 @@ const ::Type * clangimport::AstNode::addTypeTokens(TokenList *tokenList, const s for (const Token *typeToken = tokenList->back(); Token::Match(typeToken, "&|*|%name%"); typeToken = typeToken->previous()) { if (!typeToken->isName()) continue; - const ::Type *recordType = scope->findType(typeToken->str()); + const ::Type *recordType = scope->check->findVariableType(scope, typeToken); if (recordType) { const_cast(typeToken)->type(recordType); return recordType; diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index b93718a38..0771776a3 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -323,7 +323,7 @@ private: " `-CompoundStmt 0x3e4cb80 \n" " `-ReturnStmt 0x3e4cb68 \n" " `-CXXConstructExpr 0x3e4cb38 'std::string':'std::__cxx11::basic_string' '....' list"; - ASSERT_EQUALS("std::string f ( ) { return std::string ( ) ; }", parse(clang)); + ASSERT_EQUALS("std :: string f ( ) { return std :: string ( ) ; }", parse(clang)); } void cxxConstructExpr3() { @@ -339,7 +339,7 @@ private: " | `-ImplicitCastExpr 0x2c58858 'char *' \n" " | `-DeclRefExpr 0x2c58750 'char *' lvalue Var 0x2c58670 'p' 'char *'\n" " `-CXXDefaultArgExpr 0x2c58940 <> 'const std::allocator':'const std::allocator' lvalue\n"; - ASSERT_EQUALS("void f ( ) { char * p@1 ; std::string s@2 ( p@1 ) ; }", parse(clang)); + ASSERT_EQUALS("void f ( ) { char * p@1 ; std :: string s@2 ( p@1 ) ; }", parse(clang)); } void cxxDeleteExpr() { @@ -468,7 +468,7 @@ private: "| |-ParmVarDecl 0x55c786f5a6a8 col:125 checksum 'unsigned long long'\n" "| |-ParmVarDecl 0x55c786f5ac00 col:173 errors 'std::list *'\n" " `-CompoundStmt 0x0 <>"; - ASSERT_EQUALS("_Bool analyzeFile ( const std::string & buildDir@1 , const std::string & sourcefile@2 , const std::string & cfg@3 , unsigned long long checksum@4 , std::list * errors@5 ) { }", parse(clang)); + ASSERT_EQUALS("_Bool analyzeFile ( const std :: string & buildDir@1 , const std :: string & sourcefile@2 , const std :: string & cfg@3 , unsigned long long checksum@4 , std :: list * errors@5 ) { }", parse(clang)); } void cxxMethodDecl2() { // "unexpanded" template method @@ -584,7 +584,7 @@ private: " | |-IntegerLiteral 0x2f920e0 'int' 2\n" " | `-IntegerLiteral 0x2f92100 'int' 3\n" " `-CXXDefaultArgExpr 0x2fb0ae0 <> 'const std::vector >::allocator_type':'const std::allocator' lvalue"; - ASSERT_EQUALS("std::vector x@1 { 1 , 2 , 3 } ;", parse(clang)); + ASSERT_EQUALS("std :: vector x@1 { 1 , 2 , 3 } ;", parse(clang)); } void cxxThrowExpr() { @@ -954,7 +954,7 @@ private: "`-VarDecl 0x29ad898 col:9 x 'ns::abc':'ns::abc' cinit\n" " `-DeclRefExpr 0x29ad998 'ns::abc' EnumConstant 0x29ad7b0 'c' 'ns::abc'\n"; - ASSERT_EQUALS("namespace ns { enum abc { a , b , c } } ns::abc x@1 = c ;", parse(clang)); + ASSERT_EQUALS("namespace ns { enum abc { a , b , c } } ns :: abc x@1 = c ;", parse(clang)); GET_SYMBOL_DB(clang);