Clang import: Better handling of scope types
This commit is contained in:
parent
88a35d2253
commit
ff17d3e7c6
|
@ -117,7 +117,16 @@ static std::vector<std::string> 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<Token*>(typeToken)->type(recordType);
|
||||
return recordType;
|
||||
|
|
|
@ -323,7 +323,7 @@ private:
|
|||
" `-CompoundStmt 0x3e4cb80 <col:17, col:30>\n"
|
||||
" `-ReturnStmt 0x3e4cb68 <col:19, col:27>\n"
|
||||
" `-CXXConstructExpr 0x3e4cb38 <col:26, col:27> 'std::string':'std::__cxx11::basic_string<char>' '....' 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 <col:35> 'char *' <LValueToRValue>\n"
|
||||
" | `-DeclRefExpr 0x2c58750 <col:35> 'char *' lvalue Var 0x2c58670 'p' 'char *'\n"
|
||||
" `-CXXDefaultArgExpr 0x2c58940 <<invalid sloc>> 'const std::allocator<char>':'const std::allocator<char>' 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:106, col:125> col:125 checksum 'unsigned long long'\n"
|
||||
"| |-ParmVarDecl 0x55c786f5ac00 <col:135, col:173> col:173 errors 'std::list<ErrorLogger::ErrorMessage> *'\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<ErrorLogger::ErrorMessage> * 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<ErrorLogger::ErrorMessage> * errors@5 ) { }", parse(clang));
|
||||
}
|
||||
|
||||
void cxxMethodDecl2() { // "unexpanded" template method
|
||||
|
@ -584,7 +584,7 @@ private:
|
|||
" | |-IntegerLiteral 0x2f920e0 <col:22> 'int' 2\n"
|
||||
" | `-IntegerLiteral 0x2f92100 <col:24> 'int' 3\n"
|
||||
" `-CXXDefaultArgExpr 0x2fb0ae0 <<invalid sloc>> 'const std::vector<int, std::allocator<int> >::allocator_type':'const std::allocator<int>' lvalue";
|
||||
ASSERT_EQUALS("std::vector<int> x@1 { 1 , 2 , 3 } ;", parse(clang));
|
||||
ASSERT_EQUALS("std :: vector<int> x@1 { 1 , 2 , 3 } ;", parse(clang));
|
||||
}
|
||||
|
||||
void cxxThrowExpr() {
|
||||
|
@ -954,7 +954,7 @@ private:
|
|||
"`-VarDecl 0x29ad898 <line:5:1, col:22> col:9 x 'ns::abc':'ns::abc' cinit\n"
|
||||
" `-DeclRefExpr 0x29ad998 <col:13, col:22> '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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue