From 1b66820cdb09073c4a3df6bfb4755f321cdb2f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 12 Feb 2020 18:54:07 +0100 Subject: [PATCH] Revert "remove BUG_HUNTING_UNINIT conditionals" This reverts commit 07a251d783a4041fb9cbb0fdee8b001bfc9161c9. --- lib/exprengine.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/exprengine.cpp b/lib/exprengine.cpp index 281340f3e..f2032edf7 100644 --- a/lib/exprengine.cpp +++ b/lib/exprengine.cpp @@ -1888,7 +1888,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, }; #endif - +#ifdef BUG_HUNTING_UNINIT std::function uninit = [=](const Token *tok, const ExprEngine::Value &value, ExprEngine::DataBase *dataBase) { if (!tok->astParent()) return; @@ -1952,6 +1952,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, ErrorLogger::ErrorMessage errmsg(callstack, &tokenizer->list, Severity::SeverityType::error, "bughuntingUninit", "Cannot determine that '" + tok->expressionString() + "' is initialized", CWE_USE_OF_UNINITIALIZED_VARIABLE, false); errorLogger->reportErr(errmsg); }; +#endif std::function checkFunctionCall = [=](const Token *tok, const ExprEngine::Value &value, ExprEngine::DataBase *dataBase) { if (!Token::Match(tok->astParent(), "[(,]")) @@ -2051,6 +2052,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, } } +#ifdef BUG_HUNTING_UNINIT // Uninitialized function argument.. if (settings->library.isuninitargbad(parent->astOperand1(), num) && settings->library.isnullargbad(parent->astOperand1(), num) && value.type == ExprEngine::ValueType::ArrayValue) { const ExprEngine::ArrayValue &arrayValue = static_cast(value); @@ -2065,6 +2067,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, } } } +#endif }; std::function checkAssignment = [=](const Token *tok, const ExprEngine::Value &value, ExprEngine::DataBase *dataBase) { @@ -2106,7 +2109,9 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer, #ifdef BUG_HUNTING_INTEGEROVERFLOW callbacks.push_back(integerOverflow); #endif +#ifdef BUG_HUNTING_UNINIT callbacks.push_back(uninit); +#endif std::ostringstream report; ExprEngine::executeAllFunctions(tokenizer, settings, callbacks, report);