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

Function valueFlowGetStrLength

lib/vf_common.cpp:395–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393 }
394
395 MathLib::bigint valueFlowGetStrLength(const Token* tok, const Settings& settings)
396 {
397 if (tok->tokType() == Token::eString)
398 return Token::getStrLength(tok);
399 if (astIsGenericChar(tok) || tok->tokType() == Token::eChar)
400 return 1;
401 if (const Value* v = tok->getKnownValue(Value::ValueType::CONTAINER_SIZE))
402 return v->intvalue;
403 if (const Value* v = tok->getKnownValue(Value::ValueType::TOK)) {
404 if (v->tokvalue != tok)
405 return valueFlowGetStrLength(v->tokvalue, settings);
406 }
407 if (const Token* cont = settings.library.getContainerFromYield(tok, Library::Container::Yield::BUFFER_NT))
408 return valueFlowGetStrLength(cont, settings);
409 return 0;
410 }
411}

Callers 3

valueFlowContainerSizeFunction · 0.85
writeValueMethod · 0.85

Calls 3

astIsGenericCharFunction · 0.85
getKnownValueMethod · 0.80
getContainerFromYieldMethod · 0.80

Tested by

no test coverage detected