From bcc7945540caf35fae994d05a55a8423c99aa954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 8 Dec 2020 10:28:40 +0100 Subject: [PATCH] Bug hunting; Separate bughuntingUninit warnings for arguments with separate id --- lib/bughuntingchecks.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/bughuntingchecks.cpp b/lib/bughuntingchecks.cpp index 9e0f612de..2e6f33734 100644 --- a/lib/bughuntingchecks.cpp +++ b/lib/bughuntingchecks.cpp @@ -498,9 +498,21 @@ static void uninit(const Token *tok, const ExprEngine::Value &value, ExprEngine: const std::string symbol = (tok->varId() > 0) ? ("$symbol:" + tok->str() + "\n") : std::string(); + std::string errorId = "bughuntingUninit"; + + { + const Token *vartok = tok; + while (Token::simpleMatch(vartok, ".")) + vartok = vartok->previous(); + const Variable *var = vartok ? vartok->variable() : nullptr; + if (var && var->isArgument()) + errorId += "Arg"; + } + + dataBase->reportError(tok, Severity::SeverityType::error, - "bughuntingUninit", + errorId.c_str(), symbol + "Cannot determine that '" + uninitexpr + "' is initialized" + inconclusiveMessage, CWE_USE_OF_UNINITIALIZED_VARIABLE, inconclusive,