AST: A little code cleanup
This commit is contained in:
parent
9587c3758e
commit
ffdf13fcdb
|
@ -1279,36 +1279,23 @@ static Token * createAstAtToken(Token *tok, bool cpp);
|
|||
static void createAstAtTokenInner(Token * const tok1, const Token *endToken, bool cpp)
|
||||
{
|
||||
for (Token *tok = tok1; tok && tok != endToken; tok = tok ? tok->next() : nullptr) {
|
||||
if (tok->str() == "{" && !iscpp11init(tok)) {
|
||||
if (Token::simpleMatch(tok->astOperand1(), ","))
|
||||
continue;
|
||||
if (Token::simpleMatch(tok->previous(), "( {"))
|
||||
;
|
||||
// struct assignment
|
||||
else if (Token::simpleMatch(tok->previous(), ") {") && Token::simpleMatch(tok->linkAt(-1), "( struct"))
|
||||
continue;
|
||||
// Lambda function
|
||||
else if (Token::simpleMatch(tok->astParent(), "(") &&
|
||||
Token::simpleMatch(tok->astParent()->astParent(), "[") &&
|
||||
tok->astParent()->astParent()->astOperand1() &&
|
||||
tok == tok->astParent()->astParent()->astOperand1()->astOperand1())
|
||||
;
|
||||
else {
|
||||
// function argument is initializer list?
|
||||
const Token *parent = tok->astParent();
|
||||
while (Token::simpleMatch(parent, ","))
|
||||
parent = parent->astParent();
|
||||
if (!parent || !Token::Match(parent->previous(), "%name% ("))
|
||||
// not function argument..
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Token::simpleMatch(tok->previous(), "( { ."))
|
||||
break;
|
||||
|
||||
if (tok->str() == "{" && !iscpp11init(tok) && !tok->astOperand1()) {
|
||||
const Token * const endToken2 = tok->link();
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
bool hasAst = false;
|
||||
for (const Token *inner = tok->next(); inner != endToken2; inner = inner->next()) {
|
||||
if (inner->astOperand1()) {
|
||||
hasAst = true;
|
||||
break;
|
||||
}
|
||||
if (tok->isConstOp())
|
||||
break;
|
||||
if (inner->str() == "{")
|
||||
inner = inner->link();
|
||||
}
|
||||
if (!hasAst) {
|
||||
for (; tok && tok != endToken && tok != endToken2; tok = tok ? tok->next() : nullptr)
|
||||
tok = createAstAtToken(tok, cpp);
|
||||
}
|
||||
} else if (cpp && tok->str() == "[") {
|
||||
if (isLambdaCaptureList(tok)) {
|
||||
tok = tok->astOperand1();
|
||||
|
|
Loading…
Reference in New Issue