--check-library: Report unconfigured scoped functions also

This commit is contained in:
Daniel Marjamäki 2017-10-06 11:27:01 +02:00
parent 2a6fbe2e3c
commit a1053dd7dd
1 changed files with 27 additions and 15 deletions

View File

@ -413,21 +413,33 @@ void CheckFunctions::checkLibraryMatchFunctions()
if (!_settings->checkLibrary || !_settings->isEnabled(Settings::INFORMATION)) if (!_settings->checkLibrary || !_settings->isEnabled(Settings::INFORMATION))
return; return;
bool New = false;
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
if (Token::Match(tok, "%name% (") && if (!tok->scope() || !tok->scope()->isExecutable())
!Token::Match(tok, "for|if|while|switch|sizeof|catch|asm|return") && continue;
!tok->function() &&
!tok->varId() && if (tok->str() == "new")
!tok->type() && New = true;
!tok->isStandardType() && else if (tok->str() == ";")
tok->linkAt(1)->strAt(1) != "(" && New = false;
!Token::simpleMatch(tok->astParent(), "new") && else if (New)
tok->astParent() == tok->next() && continue;
_settings->library.isNotLibraryFunction(tok)) {
reportError(tok, if (!Token::Match(tok, "%name% (") || Token::Match(tok, "for|if|while|switch|sizeof|catch|asm|return"))
Severity::information, continue;
"checkLibraryFunction",
"--check-library: There is no matching configuration for function " + _settings->library.getFunctionName(tok) + "()"); if (tok->varId() != 0 || tok->type() || tok->isStandardType())
} continue;
if (tok->linkAt(1)->strAt(1) == "(")
continue;
if (!_settings->library.isNotLibraryFunction(tok))
continue;
reportError(tok,
Severity::information,
"checkLibraryFunction",
"--check-library: There is no matching configuration for function " + _settings->library.getFunctionName(tok) + "()");
} }
} }