From e669b102f84d2123fe1dc4d78ef272fb693a9c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 18 Aug 2023 13:45:25 +0200 Subject: [PATCH] renamed `Check::reportError(const ErrorMessage&)` to `writeToErrorList()` to reflect its actual behavior (#5322) --- lib/check.cpp | 6 +++--- lib/check.h | 4 ++-- lib/checkmemoryleak.cpp | 2 +- lib/checkunusedfunctions.cpp | 2 +- lib/errorlogger.cpp | 3 ++- lib/tokenize.cpp | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/check.cpp b/lib/check.cpp index bc67e683dfc..de7b3892c10 100644 --- a/lib/check.cpp +++ b/lib/check.cpp @@ -55,7 +55,7 @@ Check::Check(const std::string &aname) instances().insert(it, this); } -void Check::reportError(const ErrorMessage &errmsg) +void Check::writeToErrorList(const ErrorMessage &errmsg) { std::cout << errmsg.toXML() << std::endl; } @@ -67,7 +67,7 @@ void Check::reportError(const std::list &callstack, Severity::Sev if (mErrorLogger) mErrorLogger->reportErr(errmsg); else - reportError(errmsg); + writeToErrorList(errmsg); } void Check::reportError(const ErrorPath &errorPath, Severity::SeverityType severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty) @@ -76,7 +76,7 @@ void Check::reportError(const ErrorPath &errorPath, Severity::SeverityType sever if (mErrorLogger) mErrorLogger->reportErr(errmsg); else - reportError(errmsg); + writeToErrorList(errmsg); } bool Check::wrongData(const Token *tok, const char *str) diff --git a/lib/check.h b/lib/check.h index 2663416008e..5421c64a71c 100644 --- a/lib/check.h +++ b/lib/check.h @@ -91,11 +91,11 @@ class CPPCHECKLIB Check { virtual std::string classInfo() const = 0; /** - * Write given error to errorlogger or to out stream in xml format. + * Write given error to stdout in xml format. * This is for for printout out the error list with --errorlist * @param errmsg Error message to write */ - static void reportError(const ErrorMessage &errmsg); + static void writeToErrorList(const ErrorMessage &errmsg); /** Base class used for whole-program analysis */ class CPPCHECKLIB FileInfo { diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index f42a88f8831..7612091c29b 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -293,7 +293,7 @@ void CheckMemoryLeak::reportErr(const std::list &callstack, Sever if (mErrorLogger_) mErrorLogger_->reportErr(errmsg); else - Check::reportError(errmsg); + Check::writeToErrorList(errmsg); } void CheckMemoryLeak::memleakError(const Token *tok, const std::string &varname) const diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index c0fa12c2f6b..4319b927cac 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -357,7 +357,7 @@ void CheckUnusedFunctions::unusedFunctionError(ErrorLogger * const errorLogger, if (errorLogger) errorLogger->reportErr(errmsg); else - reportError(errmsg); + Check::writeToErrorList(errmsg); } Check::FileInfo *CheckUnusedFunctions::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 16010663e3e..efe89308852 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -43,6 +43,7 @@ ErrorMessage::ErrorMessage() : severity(Severity::none), cwe(0U), certainty(Certainty::normal), hash(0) {} +// TODO: id and msg are swapped compared to other calls ErrorMessage::ErrorMessage(std::list callStack, std::string file1, Severity::SeverityType severity, const std::string &msg, std::string id, Certainty certainty) : callStack(std::move(callStack)), // locations for this error message id(std::move(id)), // set the message id @@ -57,7 +58,7 @@ ErrorMessage::ErrorMessage(std::list callStack, std::string file1, } - +// TODO: id and msg are swapped compared to other calls ErrorMessage::ErrorMessage(std::list callStack, std::string file1, Severity::SeverityType severity, const std::string &msg, std::string id, const CWE &cwe, Certainty certainty) : callStack(std::move(callStack)), // locations for this error message id(std::move(id)), // set the message id diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 0c9ac365315..86a843c9632 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -10139,7 +10139,7 @@ void Tokenizer::reportError(const std::list& callstack, Severity:: if (mErrorLogger) mErrorLogger->reportErr(errmsg); else - Check::reportError(errmsg); + Check::writeToErrorList(errmsg); } void Tokenizer::setPodTypes()