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

Function isWithoutSideEffects

lib/astutils.cpp:2148–2163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2146}
2147
2148bool isWithoutSideEffects(const Token* tok, bool checkArrayAccess, bool checkReference)
2149{
2150 if (!tok)
2151 return true;
2152 if (!tok->isCpp())
2153 return true;
2154
2155 while (tok && tok->astOperand2() && tok->astOperand2()->str() != "(")
2156 tok = tok->astOperand2();
2157 if (tok && tok->varId()) {
2158 const Variable* var = tok->variable();
2159 return var && ((!var->isClass() && (checkReference || !var->isReference())) || var->isPointer() ||
2160 (checkArrayAccess ? var->isArray() || (var->isStlType() && !var->isStlType(CheckClassImpl::stl_containers_not_const)) : var->isStlType()));
2161 }
2162 return true;
2163}
2164
2165bool isUniqueExpression(const Token* tok)
2166{

Callers 3

alwaysTrueFalseMethod · 0.85
isConstStatementFunction · 0.85

Calls 5

astOperand2Method · 0.80
variableMethod · 0.80
isClassMethod · 0.80
isArrayMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected