AST; Improved ast for variable declaration with assignment
This commit is contained in:
parent
44f87750e0
commit
9b5986505e
|
@ -1487,16 +1487,10 @@ static Token * createAstAtToken(Token *tok, bool cpp)
|
|||
return tok->linkAt(1);
|
||||
|
||||
if (Token::Match(tok, "%type% %name%|*|&|::") && tok->str() != "return") {
|
||||
bool decl = false;
|
||||
Token *typetok = tok;
|
||||
while (Token::Match(typetok, "%type%|::|*|&")) {
|
||||
if (typetok->isStandardType() || Token::Match(typetok, "struct|const|static"))
|
||||
decl = true;
|
||||
while (Token::Match(typetok, "%type%|::|*|&"))
|
||||
typetok = typetok->next();
|
||||
}
|
||||
if (!typetok)
|
||||
return nullptr;
|
||||
if (decl && Token::Match(typetok->previous(), "[*&] %var% ="))
|
||||
if (Token::Match(typetok, "%var% =") && typetok->varId())
|
||||
tok = typetok;
|
||||
}
|
||||
|
||||
|
|
|
@ -7781,6 +7781,8 @@ private:
|
|||
"Ref<X> r;\n"
|
||||
"int x(0);";
|
||||
ASSERT_EQUALS("unoRef:: x0(", testAst(code1));
|
||||
|
||||
ASSERT_EQUALS("vary=", testAst("std::string var = y;"));
|
||||
}
|
||||
|
||||
void astunaryop() { // unary operators
|
||||
|
|
Loading…
Reference in New Issue