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

Function isStrlenOf

lib/valueflow.cpp:3626–3652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3624}
3625
3626static const Token* isStrlenOf(const Token* tok, const Token* expr, int depth = 10)
3627{
3628 if (depth < 0)
3629 return nullptr;
3630 if (!tok)
3631 return nullptr;
3632 if (!expr)
3633 return nullptr;
3634 if (expr->exprId() == 0)
3635 return nullptr;
3636 if (Token::simpleMatch(tok->previous(), "strlen (")) {
3637 if (tok->astOperand2()->exprId() == expr->exprId())
3638 return tok;
3639 } else {
3640 for (const ValueFlow::Value& v : tok->values()) {
3641 if (!v.isSymbolicValue())
3642 continue;
3643 if (!v.isKnown())
3644 continue;
3645 if (v.intvalue != 0)
3646 continue;
3647 if (const Token* next = isStrlenOf(v.tokvalue, expr, depth - 1))
3648 return next;
3649 }
3650 }
3651 return nullptr;
3652}
3653
3654static void valueFlowSymbolicOperators(const SymbolDatabase& symboldatabase, const Settings& settings)
3655{

Callers 1

Calls 3

astOperand2Method · 0.80
isKnownMethod · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected