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

Function isModified

lib/vf_analyzers.cpp:209–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207 }
208
209 virtual Action isModified(const Token* tok) const {
210 const ValueFlow::Value* value = getValue(tok);
211 if (value) {
212 // Moving a moved value won't change the moved value
213 if (value->isMovedValue() && isMoveOrForward(tok) != ValueFlow::Value::MoveKind::NonMovedVariable)
214 return Action::Read;
215 // Inserting elements to container won't change the lifetime
216 if (astIsContainer(tok) && value->isLifetimeValue() &&
217 contains({Library::Container::Action::PUSH,
218 Library::Container::Action::INSERT,
219 Library::Container::Action::APPEND,
220 Library::Container::Action::CHANGE_INTERNAL},
221 astContainerAction(tok, getSettings().library)))
222 return Action::Read;
223 }
224 bool inconclusive = false;
225 if (isVariableChangedByFunctionCall(tok, getIndirect(tok), getSettings(), &inconclusive))
226 return Action::Read | Action::Invalid;
227 if (inconclusive)
228 return Action::Read | Action::Inconclusive;
229 if (isVariableChanged(tok, getIndirect(tok), getSettings())) {
230 if (Token::Match(tok->astParent(), "*|[|.|++|--"))
231 return Action::Read | Action::Invalid;
232 // Check if its assigned to the same value
233 if (value && !value->isImpossible() && Token::simpleMatch(tok->astParent(), "=") && astIsLHS(tok) &&
234 astIsIntegral(tok->astParent()->astOperand2(), false)) {
235 std::vector<MathLib::bigint> result = evaluateInt(tok->astParent()->astOperand2());
236 if (!result.empty() && value->equalTo(result.front()))
237 return Action::Idempotent;
238 }
239 return Action::Invalid;
240 }
241 return Action::Read;
242 }
243
244 virtual Action isAliasModified(const Token* tok, int indirect = -1) const {
245 // Lambda function call

Callers 2

analyzeMatchFunction · 0.70
analyzeTokenFunction · 0.70

Calls 15

getValueFunction · 0.85
isMoveOrForwardFunction · 0.85
astIsContainerFunction · 0.85
containsFunction · 0.85
astContainerActionFunction · 0.85
getIndirectFunction · 0.85
isVariableChangedFunction · 0.85
astIsLHSFunction · 0.85
astIsIntegralFunction · 0.85
evaluateIntFunction · 0.85
astParentMethod · 0.80

Tested by

no test coverage detected