Clang import: Fixed variable type for pointers
This commit is contained in:
parent
7e8f405c6d
commit
bd5fc4b579
|
@ -108,6 +108,11 @@ static std::vector<std::string> splitString(const std::string &line)
|
|||
std::string::size_type pos1 = line.find_first_not_of(" ");
|
||||
while (pos1 != std::string::npos) {
|
||||
std::string::size_type pos2;
|
||||
if (line[pos1] == '*') {
|
||||
ret.push_back("*");
|
||||
pos1 = line.find_first_not_of(" ", pos1 + 1);
|
||||
continue;
|
||||
}
|
||||
if (line[pos1] == '<')
|
||||
pos2 = line.find(">", pos1);
|
||||
else if (line[pos1] == '\"')
|
||||
|
|
|
@ -1846,9 +1846,9 @@ Variable::Variable(const Token *name_, const std::string &clangType, const Token
|
|||
mTypeStartToken = mTypeStartToken->next();
|
||||
}
|
||||
|
||||
if (endsWith(clangType, " &", 2))
|
||||
if (Token::simpleMatch(mTypeEndToken, "&"))
|
||||
setFlag(fIsReference, true);
|
||||
else if (endsWith(clangType, " &&", 3)) {
|
||||
else if (Token::simpleMatch(mTypeEndToken, "&&")) {
|
||||
setFlag(fIsReference, true);
|
||||
setFlag(fIsRValueRef, true);
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@ private:
|
|||
TEST_CASE(symbolDatabaseFunctionConst);
|
||||
TEST_CASE(symbolDatabaseVariableRef);
|
||||
TEST_CASE(symbolDatabaseVariableRRef);
|
||||
TEST_CASE(symbolDatabaseVariablePointerRef);
|
||||
TEST_CASE(symbolDatabaseNodeType1);
|
||||
|
||||
TEST_CASE(valueFlow1);
|
||||
|
@ -456,7 +457,7 @@ private:
|
|||
" | `-CXXFunctionalCastExpr 0x1592b40 <line:2:15, line:3:28> 'MyVar<int>':'MyVar<int>' functional cast to MyVar<int> <ConstructorConversion>\n"
|
||||
" | `-CXXConstructExpr 0x15929f0 <line:2:15, line:3:28> 'MyVar<int>':'MyVar<int>' 'void (int)'\n"
|
||||
" | `-IntegerLiteral 0x1570248 <col:27> 'int' 5\n";
|
||||
ASSERT_EQUALS("int main ( int argc@1 , char ** argv@2 ) { MyVar<int> setCode@3 = MyVar<int> ( 5 ) ; }",
|
||||
ASSERT_EQUALS("int main ( int argc@1 , char * * argv@2 ) { MyVar<int> setCode@3 = MyVar<int> ( 5 ) ; }",
|
||||
parse(clang));
|
||||
}
|
||||
|
||||
|
@ -922,7 +923,7 @@ private:
|
|||
|
||||
void vardecl5() {
|
||||
const char clang[] = "|-VarDecl 0x2e31fc0 <line:27:1, col:38> col:26 sys_errlist 'const char *const []' extern";
|
||||
ASSERT_EQUALS("const char *const [] sys_errlist@1 ;", parse(clang));
|
||||
ASSERT_EQUALS("const char * const [] sys_errlist@1 ;", parse(clang));
|
||||
}
|
||||
|
||||
void vardecl6() {
|
||||
|
@ -1095,6 +1096,18 @@ private:
|
|||
ASSERT(refVar->isRValueReference());
|
||||
}
|
||||
|
||||
void symbolDatabaseVariablePointerRef() {
|
||||
const char clang[] = "`-FunctionDecl 0x9b4f10 <3.cpp:1:1, col:17> col:6 used foo 'void (int *&)'\n"
|
||||
" `-ParmVarDecl 0x9b4e40 <col:10, col:16> col:16 p 'int *&'\n";
|
||||
|
||||
ASSERT_EQUALS("void foo ( int * & p@1 ) ;", parse(clang));
|
||||
|
||||
GET_SYMBOL_DB(clang);
|
||||
const Variable *p = db->variableList().back();
|
||||
ASSERT(p->isPointer());
|
||||
ASSERT(p->isReference());
|
||||
}
|
||||
|
||||
void symbolDatabaseNodeType1() {
|
||||
const char clang[] = "`-FunctionDecl 0x32438c0 <line:5:1, line:7:1> line:5:6 foo 'a::b (a::b)'\n"
|
||||
" |-ParmVarDecl 0x32437b0 <col:10, col:15> col:15 used i 'a::b':'long'\n"
|
||||
|
|
Loading…
Reference in New Issue