Skip to content

Commit

Permalink
Remove unnecessary stack
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jun 15, 2024
1 parent 163d802 commit 8aa96ee
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,29 +1564,25 @@ namespace {
}
};
using ExprIdMap = std::map<ExprIdKey, nonneg int>;
void setParentExprId(Token* tokStart, ExprIdMap& exprIdMap, nonneg int &id) {
std::stack<Token*> tokens;
tokens.push(tokStart);
while (!tokens.empty()) {
Token* tok = tokens.top();
tokens.pop();
void setParentExprId(Token* tok, ExprIdMap& exprIdMap, nonneg int &id) {
for (;;) {
if (!tok->astParent() || tok->astParent()->isControlFlowKeyword())
continue;
break;
const Token* op1 = tok->astParent()->astOperand1();
if (op1 && op1->exprId() == 0 && !Token::Match(op1, "[{[]"))
continue;
break;
const Token* op2 = tok->astParent()->astOperand2();
if (op2 && op2->exprId() == 0 &&
!((tok->astParent()->astParent() && tok->astParent()->isAssignmentOp() && tok->astParent()->astParent()->isAssignmentOp()) ||
isLambdaCaptureList(op2) ||
(op2->str() == "(" && isLambdaCaptureList(op2->astOperand1())) ||
Token::simpleMatch(op2, "{ }")))
continue;
break;

if (tok->astParent()->isExpandedMacro() || Token::Match(tok->astParent(), "++|--")) {
tok->astParent()->exprId(id);
++id;
tokens.push(tok->astParent());
tok = tok->astParent();
continue;
}

Expand Down Expand Up @@ -1647,7 +1643,7 @@ namespace {
else {
tok->astParent()->exprId(it->second);
}
tokens.push(tok->astParent());
tok = tok->astParent();
}
}
}
Expand Down

0 comments on commit 8aa96ee

Please sign in to comment.