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

Function getSingleExpressionInBlock

lib/checkother.cpp:2629–2638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2627}
2628
2629static const Token * getSingleExpressionInBlock(const Token * tok)
2630{
2631 if (!tok)
2632 return nullptr;
2633 const Token * top = tok->astTop();
2634 const Token * nextExpression = nextAfterAstRightmostLeaf(top);
2635 if (!Token::simpleMatch(nextExpression, "; }"))
2636 return nullptr;
2637 return top;
2638}
2639
2640//-----------------------------------------------------------------------------
2641// check for duplicate code in if and else branches

Callers 1

checkDuplicateBranchMethod · 0.85

Calls 3

astTopMethod · 0.80
simpleMatchFunction · 0.70

Tested by

no test coverage detected