Tweak Function::isSafe()

This commit is contained in:
Daniel Marjamäki 2019-07-25 20:52:24 +02:00
parent 4611cbb5bb
commit 9009eeb83d
1 changed files with 9 additions and 12 deletions

View File

@ -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;
}