AST: improved AST when expression starts with %char% or %str%
This commit is contained in:
parent
4c5310433c
commit
ac1ceb85b6
|
@ -1483,7 +1483,12 @@ static Token * createAstAtToken(Token *tok, bool cpp)
|
|||
tok = typetok;
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "return|case") || (cpp && tok->str() == "throw") || !tok->previous() || Token::Match(tok, "%name% %op%|(|[|.|::|<|?|;") || Token::Match(tok->previous(), "[;{}] %cop%|++|--|( !!{") || Token::Match(tok->previous(), "[;{}] %num%")) {
|
||||
if (Token::Match(tok, "return|case") ||
|
||||
(cpp && tok->str() == "throw") ||
|
||||
!tok->previous() ||
|
||||
Token::Match(tok, "%name% %op%|(|[|.|::|<|?|;") ||
|
||||
Token::Match(tok->previous(), "[;{}] %cop%|++|--|( !!{") ||
|
||||
Token::Match(tok->previous(), "[;{}] %num%|%str%|%char%")) {
|
||||
if (cpp && (Token::Match(tok->tokAt(-2), "[;{}] new|delete %name%") || Token::Match(tok->tokAt(-3), "[;{}] :: new|delete %name%")))
|
||||
tok = tok->previous();
|
||||
|
||||
|
|
|
@ -7720,6 +7720,8 @@ private:
|
|||
ASSERT_EQUALS("xab,c,{=", testAst("x={a,b,(c)};"));
|
||||
ASSERT_EQUALS("x0fSa.1=b.2=,c.\"\"=,{(||=", testAst("x = 0 || f(S{.a = 1, .b = 2, .c = \"\" });"));
|
||||
ASSERT_EQUALS("x0fSa.1{=b.2{,c.\"\"=,{(||=", testAst("x = 0 || f(S{.a = { 1 }, .b { 2 }, .c = \"\" });"));
|
||||
ASSERT_EQUALS("a0{,( \"\"abc12:?,", testAst("a(0, {{\"\", (abc) ? 1 : 2}});"));
|
||||
ASSERT_EQUALS("a0{,( \'\'abc12:?,", testAst("a(0, {{\'\', (abc) ? 1 : 2}});"));
|
||||
|
||||
// struct initialization hang
|
||||
ASSERT_EQUALS("sbar.1{,{(={= fcmd( forfieldfield++;;(",
|
||||
|
|
Loading…
Reference in New Issue