From a1053dd7ddf780244b1b4db1e44cb99c1438e820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 6 Oct 2017 11:27:01 +0200 Subject: [PATCH] --check-library: Report unconfigured scoped functions also --- lib/checkfunctions.cpp | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 810122784..042f71f23 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -413,21 +413,33 @@ void CheckFunctions::checkLibraryMatchFunctions() if (!_settings->checkLibrary || !_settings->isEnabled(Settings::INFORMATION)) return; + bool New = false; for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { - if (Token::Match(tok, "%name% (") && - !Token::Match(tok, "for|if|while|switch|sizeof|catch|asm|return") && - !tok->function() && - !tok->varId() && - !tok->type() && - !tok->isStandardType() && - tok->linkAt(1)->strAt(1) != "(" && - !Token::simpleMatch(tok->astParent(), "new") && - tok->astParent() == tok->next() && - _settings->library.isNotLibraryFunction(tok)) { - reportError(tok, - Severity::information, - "checkLibraryFunction", - "--check-library: There is no matching configuration for function " + _settings->library.getFunctionName(tok) + "()"); - } + if (!tok->scope() || !tok->scope()->isExecutable()) + continue; + + if (tok->str() == "new") + New = true; + else if (tok->str() == ";") + New = false; + else if (New) + continue; + + if (!Token::Match(tok, "%name% (") || Token::Match(tok, "for|if|while|switch|sizeof|catch|asm|return")) + continue; + + 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) + "()"); } }