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

Function skipUnreachableIfBranch

lib/astutils.cpp:3873–3892  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3871}
3872
3873static const Token *skipUnreachableIfBranch(const Token *tok)
3874{
3875 const Token *condTok = tok->linkAt(-1);
3876 if (!condTok)
3877 return tok;
3878
3879 if (!Token::simpleMatch(condTok->tokAt(-1), "if") && !Token::simpleMatch(condTok->tokAt(-2), "if constexpr"))
3880 return tok;
3881
3882 condTok = condTok->astOperand2();
3883 if (!condTok)
3884 return tok;
3885
3886 if ((condTok->hasKnownIntValue() && condTok->getKnownIntValue() == 0)
3887 || (unknownLeafValuesAreTemplateArgs(condTok) && condTok->getValue(0))) {
3888 tok = tok->link();
3889 }
3890
3891 return tok;
3892}
3893
3894static const Token *skipUnreachableElseBranch(const Token *tok)
3895{

Callers 1

skipUnreachableBranchFunction · 0.85

Calls 8

linkAtMethod · 0.80
astOperand2Method · 0.80
getKnownIntValueMethod · 0.80
simpleMatchFunction · 0.70
tokAtMethod · 0.45
hasKnownIntValueMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected