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

Function valueFlowContainerSetTokValue

lib/valueflow.cpp:6612–6627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6610}
6611
6612static void valueFlowContainerSetTokValue(const TokenList& tokenlist, ErrorLogger& errorLogger, const Settings& settings, const Token* tok, Token* initList)
6613{
6614 ValueFlow::Value value;
6615 value.valueType = ValueFlow::Value::ValueType::TOK;
6616 value.tokvalue = initList;
6617 if (astIsContainerString(tok) && Token::simpleMatch(initList, "{") && Token::Match(initList->astOperand2(), "%str%")) {
6618 value.tokvalue = initList->astOperand2();
6619 }
6620 value.setKnown();
6621 Token* start = initList->link() ? initList->link() : initList->next();
6622 if (tok->variable() && tok->variable()->isConst()) {
6623 valueFlowForwardConst(start, tok->variable()->scope()->bodyEnd, tok->variable(), {std::move(value)}, settings);
6624 } else {
6625 valueFlowForward(start, tok, std::move(value), tokenlist, errorLogger, settings);
6626 }
6627}
6628
6629static const Scope* getFunctionScope(const Scope* scope) {
6630 while (scope && scope->type != ScopeType::eFunction)

Callers 1

valueFlowContainerSizeFunction · 0.85

Calls 9

astIsContainerStringFunction · 0.85
valueFlowForwardConstFunction · 0.85
valueFlowForwardFunction · 0.85
astOperand2Method · 0.80
nextMethod · 0.80
variableMethod · 0.80
isConstMethod · 0.80
scopeMethod · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected