From 9009eeb83d10932c0f7056ea552dac4210701c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 25 Jul 2019 20:52:24 +0200 Subject: [PATCH] Tweak Function::isSafe() --- lib/symboldatabase.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 7ebeb480b..3ed5ff0f3 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2089,24 +2089,21 @@ const Token * Function::constructorMemberInitialization() const bool Function::isSafe(const Settings *settings) const { if (settings->safeChecks.externalFunctions) { - if (nestedIn->type == Scope::ScopeType::eGlobal || nestedIn->type == Scope::ScopeType::eNamespace) { - if (token->fileIndex() != 0 || !isStatic()) { - return true; - } - } + if (nestedIn->type == Scope::ScopeType::eNamespace && token->fileIndex() != 0) + return true; + if (nestedIn->type == Scope::ScopeType::eGlobal && (token->fileIndex() != 0 || !isStatic())) + return true; } if (settings->safeChecks.internalFunctions) { - if (nestedIn->type == Scope::ScopeType::eGlobal || nestedIn->type == Scope::ScopeType::eNamespace) { - if (token->fileIndex() == 0 && isStatic()) { - return true; - } - } + if (nestedIn->type == Scope::ScopeType::eNamespace && token->fileIndex() == 0) + return true; + if (nestedIn->type == Scope::ScopeType::eGlobal && (token->fileIndex() == 0 || isStatic())) + return true; } - if (settings->safeChecks.classes && access == AccessControl::Public) { + if (settings->safeChecks.classes && access == AccessControl::Public && (nestedIn->type == Scope::ScopeType::eClass || nestedIn->type == Scope::ScopeType::eStruct)) return true; - } return false; }