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

Function inBooleanFunction

lib/checkcondition.cpp:283–298  ·  view source on GitHub ↗

Return whether tok is in the body for a function returning a boolean. */

Source from the content-addressed store, hash-verified

281
282/* Return whether tok is in the body for a function returning a boolean. */
283static bool inBooleanFunction(const Token *tok)
284{
285 const Scope *scope = tok ? tok->scope() : nullptr;
286 while (scope && scope->isLocal())
287 scope = scope->nestedIn;
288 if (scope && scope->type == ScopeType::eFunction) {
289 const Function *func = scope->function;
290 if (func) {
291 const Token *ret = func->retDef;
292 while (Token::Match(ret, "static|const"))
293 ret = ret->next();
294 return Token::Match(ret, "bool|_Bool");
295 }
296 }
297 return false;
298}
299
300static bool isOperandExpanded(const Token *tok)
301{

Callers 1

checkBadBitmaskCheckMethod · 0.85

Calls 2

scopeMethod · 0.80
nextMethod · 0.80

Tested by

no test coverage detected