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

Function valueFlowPointerAlias

lib/valueflow.cpp:822–851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

820}
821
822static void valueFlowPointerAlias(TokenList& tokenlist, const Settings& settings)
823{
824 for (Token* tok = tokenlist.front(); tok; tok = tok->next()) {
825 // not address of
826 if (!tok->isUnaryOp("&"))
827 continue;
828
829 // parent should be a '='
830 if (!Token::simpleMatch(tok->astParent(), "="))
831 continue;
832
833 // child should be some buffer or variable
834 const Token* vartok = tok->astOperand1();
835 while (vartok) {
836 if (vartok->str() == "[")
837 vartok = vartok->astOperand1();
838 else if (vartok->str() == "." || vartok->str() == "::")
839 vartok = vartok->astOperand2();
840 else
841 break;
842 }
843 if (!(vartok && vartok->variable() && !vartok->variable()->isPointer()))
844 continue;
845
846 ValueFlow::Value value;
847 value.valueType = ValueFlow::Value::ValueType::TOK;
848 value.tokvalue = tok;
849 setTokenValue(tok, std::move(value), settings);
850 }
851}
852
853static void valueFlowBitAnd(TokenList& tokenlist, const Settings& settings)
854{

Callers 1

setValuesMethod · 0.85

Calls 10

setTokenValueFunction · 0.85
frontMethod · 0.80
nextMethod · 0.80
isUnaryOpMethod · 0.80
astParentMethod · 0.80
astOperand1Method · 0.80
astOperand2Method · 0.80
variableMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected