MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / getExprIdForOperand

Function getExprIdForOperand

lib/symboldatabase.cpp:1614–1632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1612
1613namespace {
1614 int getExprIdForOperand(const Token* tok) {
1615 if (!tok)
1616 return 0;
1617
1618 int otherExprId = 0;
1619
1620 // Look through all referenced tokens.
1621 // If two exprIds are found and one matches tok->exprId(), return the other.
1622 // Otherwise, default to returning tok->exprId().
1623 for (const auto& ref: followAllReferences(tok)) {
1624 const int refExprId = ref.token->exprId();
1625 if (refExprId != 0 && refExprId != tok->exprId()) {
1626 if (otherExprId != 0 && otherExprId != refExprId)
1627 return tok->exprId();
1628 otherExprId = refExprId;
1629 }
1630 }
1631 return otherExprId != 0 ? otherExprId : tok->exprId();
1632 }
1633
1634 struct ExprIdKey {
1635 std::string parentOp;

Callers 1

setParentExprIdFunction · 0.85

Calls 1

followAllReferencesFunction · 0.85

Tested by

no test coverage detected