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);
|
return tok->linkAt(1);
|
||||||
|
|
||||||
if (Token::Match(tok, "%type% %name%|*|&|::") && tok->str() != "return") {
|
if (Token::Match(tok, "%type% %name%|*|&|::") && tok->str() != "return") {
|
||||||
bool decl = false;
|
|
||||||
Token *typetok = tok;
|
Token *typetok = tok;
|
||||||
while (Token::Match(typetok, "%type%|::|*|&")) {
|
while (Token::Match(typetok, "%type%|::|*|&"))
|
||||||
if (typetok->isStandardType() || Token::Match(typetok, "struct|const|static"))
|
|
||||||
decl = true;
|
|
||||||
typetok = typetok->next();
|
typetok = typetok->next();
|
||||||
}
|
if (Token::Match(typetok, "%var% =") && typetok->varId())
|
||||||
if (!typetok)
|
|
||||||
return nullptr;
|
|
||||||
if (decl && Token::Match(typetok->previous(), "[*&] %var% ="))
|
|
||||||
tok = typetok;
|
tok = typetok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7781,6 +7781,8 @@ private:
|
||||||
"Ref<X> r;\n"
|
"Ref<X> r;\n"
|
||||||
"int x(0);";
|
"int x(0);";
|
||||||
ASSERT_EQUALS("unoRef:: x0(", testAst(code1));
|
ASSERT_EQUALS("unoRef:: x0(", testAst(code1));
|
||||||
|
|
||||||
|
ASSERT_EQUALS("vary=", testAst("std::string var = y;"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void astunaryop() { // unary operators
|
void astunaryop() { // unary operators
|
||||||
|
|
Loading…
Reference in New Issue