Skip to content

Commit e669b10

Browse files
authored
renamed Check::reportError(const ErrorMessage&) to writeToErrorList() to reflect its actual behavior (#5322)
1 parent bfb50ca commit e669b10

6 files changed

Lines changed: 10 additions & 9 deletions

File tree

lib/check.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Check::Check(const std::string &aname)
5555
instances().insert(it, this);
5656
}
5757

58-
void Check::reportError(const ErrorMessage &errmsg)
58+
void Check::writeToErrorList(const ErrorMessage &errmsg)
5959
{
6060
std::cout << errmsg.toXML() << std::endl;
6161
}
@@ -67,7 +67,7 @@ void Check::reportError(const std::list<const Token *> &callstack, Severity::Sev
6767
if (mErrorLogger)
6868
mErrorLogger->reportErr(errmsg);
6969
else
70-
reportError(errmsg);
70+
writeToErrorList(errmsg);
7171
}
7272

7373
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
7676
if (mErrorLogger)
7777
mErrorLogger->reportErr(errmsg);
7878
else
79-
reportError(errmsg);
79+
writeToErrorList(errmsg);
8080
}
8181

8282
bool Check::wrongData(const Token *tok, const char *str)

lib/check.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ class CPPCHECKLIB Check {
9191
virtual std::string classInfo() const = 0;
9292

9393
/**
94-
* Write given error to errorlogger or to out stream in xml format.
94+
* Write given error to stdout in xml format.
9595
* This is for for printout out the error list with --errorlist
9696
* @param errmsg Error message to write
9797
*/
98-
static void reportError(const ErrorMessage &errmsg);
98+
static void writeToErrorList(const ErrorMessage &errmsg);
9999

100100
/** Base class used for whole-program analysis */
101101
class CPPCHECKLIB FileInfo {

lib/checkmemoryleak.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void CheckMemoryLeak::reportErr(const std::list<const Token *> &callstack, Sever
293293
if (mErrorLogger_)
294294
mErrorLogger_->reportErr(errmsg);
295295
else
296-
Check::reportError(errmsg);
296+
Check::writeToErrorList(errmsg);
297297
}
298298

299299
void CheckMemoryLeak::memleakError(const Token *tok, const std::string &varname) const

lib/checkunusedfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ void CheckUnusedFunctions::unusedFunctionError(ErrorLogger * const errorLogger,
357357
if (errorLogger)
358358
errorLogger->reportErr(errmsg);
359359
else
360-
reportError(errmsg);
360+
Check::writeToErrorList(errmsg);
361361
}
362362

363363
Check::FileInfo *CheckUnusedFunctions::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const

lib/errorlogger.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ ErrorMessage::ErrorMessage()
4343
: severity(Severity::none), cwe(0U), certainty(Certainty::normal), hash(0)
4444
{}
4545

46+
// TODO: id and msg are swapped compared to other calls
4647
ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity::SeverityType severity, const std::string &msg, std::string id, Certainty certainty) :
4748
callStack(std::move(callStack)), // locations for this error message
4849
id(std::move(id)), // set the message id
@@ -57,7 +58,7 @@ ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1,
5758
}
5859

5960

60-
61+
// TODO: id and msg are swapped compared to other calls
6162
ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity::SeverityType severity, const std::string &msg, std::string id, const CWE &cwe, Certainty certainty) :
6263
callStack(std::move(callStack)), // locations for this error message
6364
id(std::move(id)), // set the message id

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10139,7 +10139,7 @@ void Tokenizer::reportError(const std::list<const Token*>& callstack, Severity::
1013910139
if (mErrorLogger)
1014010140
mErrorLogger->reportErr(errmsg);
1014110141
else
10142-
Check::reportError(errmsg);
10142+
Check::writeToErrorList(errmsg);
1014310143
}
1014410144

1014510145
void Tokenizer::setPodTypes()

0 commit comments

Comments
 (0)