| 3442 | } |
| 3443 | |
| 3444 | bool 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 | |
| 3466 | Function* SymbolDatabase::addGlobalFunction(Scope*& scope, const Token*& tok, const Token *argStart, const Token* funcStart) |
| 3467 | { |
no test coverage detected