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

Function mayDependOn

lib/checkother.cpp:1304–1327  ·  view source on GitHub ↗

used to check if an argument to a function might depend on another argument

Source from the content-addressed store, hash-verified

1302
1303// used to check if an argument to a function might depend on another argument
1304static bool mayDependOn(const ValueType *other, const ValueType *original)
1305{
1306 if (!other || !original)
1307 return false;
1308
1309 // other must be pointer
1310 if (!other->pointer)
1311 return false;
1312
1313 // must be same underlying type
1314 if (other->type != original->type)
1315 return false;
1316
1317 const int otherPtr = other->pointer + (other->reference == Reference::LValue ? 1 : 0);
1318 const int originalPtr = original->pointer;
1319
1320 if (otherPtr == originalPtr) {
1321 // if other is not const than original may be copied to other
1322 return !other->isConst(otherPtr);
1323 }
1324
1325 // other may be reassigned to original
1326 return otherPtr > originalPtr;
1327}
1328
1329static bool isOnlyUsedInCurrentScope(const Variable* var, const Token *tok, const Scope* scope)
1330{

Callers 1

checkInnerScopeMethod · 0.85

Calls 1

isConstMethod · 0.80

Tested by

no test coverage detected