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

Method isSafe

lib/symboldatabase.cpp:3444–3464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3442}
3443
3444bool Function::isSafe(const Settings &settings) const
3445{
3446 if (settings.safeChecks.externalFunctions) {
3447 if (nestedIn->type == ScopeType::eNamespace && token->fileIndex() != 0)
3448 return true;
3449 if (nestedIn->type == ScopeType::eGlobal && (token->fileIndex() != 0 || !isStatic()))
3450 return true;
3451 }
3452
3453 if (settings.safeChecks.internalFunctions) {
3454 if (nestedIn->type == ScopeType::eNamespace && token->fileIndex() == 0)
3455 return true;
3456 if (nestedIn->type == ScopeType::eGlobal && (token->fileIndex() == 0 || isStatic()))
3457 return true;
3458 }
3459
3460 if (settings.safeChecks.classes && access == AccessControl::Public && (nestedIn->type == ScopeType::eClass || nestedIn->type == ScopeType::eStruct))
3461 return true;
3462
3463 return false;
3464}
3465
3466Function* SymbolDatabase::addGlobalFunction(Scope*& scope, const Token*& tok, const Token *argStart, const Token* funcStart)
3467{

Callers 1

valueFlowSafeFunctionsFunction · 0.80

Calls 2

isStaticFunction · 0.85
fileIndexMethod · 0.80

Tested by

no test coverage detected