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

Function isAliasOf

lib/vf_analyzers.cpp:860–884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

858// Check if its an alias of the variable or is being aliased to this variable
859template<typename V>
860static bool isAliasOf(const Variable * var, const Token *tok, nonneg int varid, const V& values, bool* inconclusive = nullptr)
861{
862 if (tok->varId() == varid)
863 return false;
864 if (tok->varId() == 0)
865 return false;
866 if (isAliasOf(tok, varid, inconclusive))
867 return true;
868 if (var && !var->isPointer())
869 return false;
870 // Search through non value aliases
871 return std::any_of(values.begin(), values.end(), [&](const ValueFlow::Value& val) {
872 if (!val.isNonValue())
873 return false;
874 if (val.isInconclusive())
875 return false;
876 if (val.isLifetimeValue() && !val.isLocalLifetimeValue())
877 return false;
878 if (val.isLifetimeValue() && val.lifetimeKind != ValueFlow::Value::LifetimeKind::Address)
879 return false;
880 if (!Token::Match(val.tokvalue, ".|&|*|%var%"))
881 return false;
882 return astHasVar(val.tokvalue, tok->varId());
883 });
884}
885
886struct MultiValueFlowAnalyzer : ValueFlowAnalyzer {
887 class SelectValueFromVarIdMapRange {

Callers 3

isAliasMethod · 0.70
isAliasMethod · 0.70
matchMethod · 0.70

Calls 4

astHasVarFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
isInconclusiveMethod · 0.45

Tested by

no test coverage detected