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

Function isConstExpression

lib/astutils.cpp:2126–2146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2124}
2125
2126bool isConstExpression(const Token *tok, const Library& library)
2127{
2128 if (!tok)
2129 return true;
2130 if (tok->variable() && tok->variable()->isVolatile())
2131 return false;
2132 if (tok->isName() && tok->strAt(1) == "(") {
2133 if (!isConstFunctionCall(tok, library))
2134 return false;
2135 }
2136 if (tok->tokType() == Token::eIncDecOp)
2137 return false;
2138 if (tok->isAssignmentOp())
2139 return false;
2140 if (isLikelyStreamRead(tok))
2141 return false;
2142 // bailout when we see ({..})
2143 if (tok->str() == "{")
2144 return false;
2145 return isConstExpression(tok->astOperand1(), library) && isConstExpression(tok->astOperand2(), library);
2146}
2147
2148bool isWithoutSideEffects(const Token* tok, bool checkArrayAccess, bool checkReference)
2149{

Callers 9

valueFlowSymbolicFunction · 0.85
traverseConditionMethod · 0.85
parseMethod · 0.85
checkBitwiseOnBooleanMethod · 0.85
useStandardLibraryMethod · 0.85
traverseMethod · 0.85
useStlAlgorithmMethod · 0.85

Calls 8

isConstFunctionCallFunction · 0.85
isLikelyStreamReadFunction · 0.85
variableMethod · 0.80
isVolatileMethod · 0.80
isAssignmentOpMethod · 0.80
astOperand1Method · 0.80
astOperand2Method · 0.80
strMethod · 0.45

Tested by

no test coverage detected