removed unnecessary encapsulation of severity enum and made it an `enum class` (#5541)
This commit is contained in:
parent
179d26f06b
commit
8c0d43d928
|
@ -791,7 +791,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
if (message) {
|
||||
const tinyxml2::XMLElement *severity = message->FirstChildElement("severity");
|
||||
if (severity)
|
||||
rule.severity = Severity::fromString(severity->GetText());
|
||||
rule.severity = severityFromString(severity->GetText());
|
||||
|
||||
const tinyxml2::XMLElement *id = message->FirstChildElement("id");
|
||||
if (id)
|
||||
|
|
|
@ -347,9 +347,9 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS
|
|||
errorItem.errorPath.last().line = r1MatchRes.captured(2).toInt();
|
||||
errorItem.errorPath.last().column = r1MatchRes.captured(3).toInt();
|
||||
if (r1MatchRes.captured(4) == "warning")
|
||||
errorItem.severity = Severity::SeverityType::warning;
|
||||
errorItem.severity = Severity::warning;
|
||||
else if (r1MatchRes.captured(4) == "error" || r1MatchRes.captured(4) == "fatal error")
|
||||
errorItem.severity = Severity::SeverityType::error;
|
||||
errorItem.severity = Severity::error;
|
||||
|
||||
QString message,id;
|
||||
const QRegularExpressionMatch r2MatchRes = r2.match(r1MatchRes.captured(5));
|
||||
|
@ -362,13 +362,13 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS
|
|||
id = tool + '-' + r2MatchRes.captured(2);
|
||||
if (tool == CLANG_TIDY) {
|
||||
if (id1.startsWith("performance"))
|
||||
errorItem.severity = Severity::SeverityType::performance;
|
||||
errorItem.severity = Severity::performance;
|
||||
else if (id1.startsWith("portability"))
|
||||
errorItem.severity = Severity::SeverityType::portability;
|
||||
errorItem.severity = Severity::portability;
|
||||
else if (id1.startsWith("misc") && !id1.contains("unused"))
|
||||
errorItem.severity = Severity::SeverityType::warning;
|
||||
errorItem.severity = Severity::warning;
|
||||
else
|
||||
errorItem.severity = Severity::SeverityType::style;
|
||||
errorItem.severity = Severity::style;
|
||||
}
|
||||
} else {
|
||||
message = r1MatchRes.captured(5);
|
||||
|
|
|
@ -37,12 +37,12 @@
|
|||
*/
|
||||
class GuiSeverity {
|
||||
public:
|
||||
static QString toString(Severity::SeverityType severity) {
|
||||
return QString::fromStdString(Severity::toString(severity));
|
||||
static QString toString(Severity severity) {
|
||||
return QString::fromStdString(severityToString(severity));
|
||||
}
|
||||
|
||||
static Severity::SeverityType fromString(const QString &severity) {
|
||||
return Severity::fromString(severity.toStdString());
|
||||
static Severity fromString(const QString &severity) {
|
||||
return severityFromString(severity.toStdString());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
|
||||
QString file0;
|
||||
QString errorId;
|
||||
Severity::SeverityType severity;
|
||||
Severity severity;
|
||||
bool inconclusive;
|
||||
QString summary;
|
||||
QString message;
|
||||
|
@ -117,7 +117,7 @@ public:
|
|||
int cwe;
|
||||
unsigned long long hash;
|
||||
bool inconclusive;
|
||||
Severity::SeverityType severity;
|
||||
Severity severity;
|
||||
QString summary;
|
||||
QString message;
|
||||
QString sinceDate;
|
||||
|
|
|
@ -319,7 +319,7 @@ QStandardItem *ResultsTree::addBacktraceFiles(QStandardItem *parent,
|
|||
return list[0];
|
||||
}
|
||||
|
||||
QString ResultsTree::severityToTranslatedString(Severity::SeverityType severity)
|
||||
QString ResultsTree::severityToTranslatedString(Severity severity)
|
||||
{
|
||||
switch (severity) {
|
||||
case Severity::style:
|
||||
|
@ -901,7 +901,7 @@ void ResultsTree::copy()
|
|||
QString inconclusive = data[INCONCLUSIVE].toBool() ? ",inconclusive" : "";
|
||||
text += '[' + data[FILENAME].toString() + ':' + QString::number(data[LINE].toInt())
|
||||
+ "] ("
|
||||
+ QString::fromStdString(Severity::toString(ShowTypes::ShowTypeToSeverity((ShowTypes::ShowType)data[SEVERITY].toInt()))) + inconclusive
|
||||
+ QString::fromStdString(severityToString(ShowTypes::ShowTypeToSeverity((ShowTypes::ShowType)data[SEVERITY].toInt()))) + inconclusive
|
||||
+ ") "
|
||||
+ data[MESSAGE].toString()
|
||||
+ " ["
|
||||
|
@ -1155,7 +1155,7 @@ QString ResultsTree::getFilePath(const QStandardItem *target, bool fullPath)
|
|||
return QString();
|
||||
}
|
||||
|
||||
QString ResultsTree::severityToIcon(Severity::SeverityType severity)
|
||||
QString ResultsTree::severityToIcon(Severity severity)
|
||||
{
|
||||
switch (severity) {
|
||||
case Severity::error:
|
||||
|
|
|
@ -335,7 +335,7 @@ protected:
|
|||
*
|
||||
* @param severity Severity
|
||||
*/
|
||||
static QString severityToIcon(Severity::SeverityType severity);
|
||||
static QString severityToIcon(Severity severity);
|
||||
|
||||
/**
|
||||
* @brief Helper function to open an error within target with application*
|
||||
|
@ -382,7 +382,7 @@ protected:
|
|||
* @param severity Severity to convert
|
||||
* @return Severity as translated string
|
||||
*/
|
||||
static QString severityToTranslatedString(Severity::SeverityType severity);
|
||||
static QString severityToTranslatedString(Severity severity);
|
||||
|
||||
/**
|
||||
* @brief Load all settings
|
||||
|
|
|
@ -32,7 +32,7 @@ ShowTypes::~ShowTypes()
|
|||
save();
|
||||
}
|
||||
|
||||
ShowTypes::ShowType ShowTypes::SeverityToShowType(Severity::SeverityType severity)
|
||||
ShowTypes::ShowType ShowTypes::SeverityToShowType(Severity severity)
|
||||
{
|
||||
switch (severity) {
|
||||
case Severity::none:
|
||||
|
@ -54,7 +54,7 @@ ShowTypes::ShowType ShowTypes::SeverityToShowType(Severity::SeverityType severit
|
|||
}
|
||||
}
|
||||
|
||||
Severity::SeverityType ShowTypes::ShowTypeToSeverity(ShowTypes::ShowType type)
|
||||
Severity ShowTypes::ShowTypeToSeverity(ShowTypes::ShowType type)
|
||||
{
|
||||
switch (type) {
|
||||
case ShowTypes::ShowStyle:
|
||||
|
@ -117,7 +117,7 @@ bool ShowTypes::isShown(ShowTypes::ShowType category) const
|
|||
return mVisible[category];
|
||||
}
|
||||
|
||||
bool ShowTypes::isShown(Severity::SeverityType severity) const
|
||||
bool ShowTypes::isShown(Severity severity) const
|
||||
{
|
||||
return isShown(ShowTypes::SeverityToShowType(severity));
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
* @param severity severity to check.
|
||||
* @return true if the severity is visible.
|
||||
*/
|
||||
bool isShown(Severity::SeverityType severity) const;
|
||||
bool isShown(Severity severity) const;
|
||||
|
||||
/**
|
||||
* @brief Show/hide the showtype.
|
||||
|
@ -99,14 +99,14 @@ public:
|
|||
* @param severity Error severity
|
||||
* @return Severity converted to ShowTypes value
|
||||
*/
|
||||
static ShowTypes::ShowType SeverityToShowType(Severity::SeverityType severity);
|
||||
static ShowTypes::ShowType SeverityToShowType(Severity severity);
|
||||
|
||||
/**
|
||||
* @brief Convert ShowType to severity string
|
||||
* @param type ShowType to convert
|
||||
* @return ShowType converted to severity
|
||||
*/
|
||||
static Severity::SeverityType ShowTypeToSeverity(ShowTypes::ShowType type);
|
||||
static Severity ShowTypeToSeverity(ShowTypes::ShowType type);
|
||||
|
||||
/**
|
||||
* @brief Convert QVariant (that contains an int) to Showtypes value
|
||||
|
|
|
@ -61,7 +61,7 @@ void Check::writeToErrorList(const ErrorMessage &errmsg)
|
|||
}
|
||||
|
||||
|
||||
void Check::reportError(const std::list<const Token *> &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty)
|
||||
void Check::reportError(const std::list<const Token *> &callstack, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty)
|
||||
{
|
||||
const ErrorMessage errmsg(callstack, mTokenizer ? &mTokenizer->list : nullptr, severity, id, msg, cwe, certainty);
|
||||
if (mErrorLogger)
|
||||
|
@ -70,7 +70,7 @@ void Check::reportError(const std::list<const Token *> &callstack, Severity::Sev
|
|||
writeToErrorList(errmsg);
|
||||
}
|
||||
|
||||
void Check::reportError(const ErrorPath &errorPath, Severity::SeverityType severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty)
|
||||
void Check::reportError(const ErrorPath &errorPath, Severity severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty)
|
||||
{
|
||||
const ErrorMessage errmsg(errorPath, mTokenizer ? &mTokenizer->list : nullptr, severity, id, msg, cwe, certainty);
|
||||
if (mErrorLogger)
|
||||
|
|
10
lib/check.h
10
lib/check.h
|
@ -137,25 +137,25 @@ protected:
|
|||
ErrorLogger* const mErrorLogger{};
|
||||
|
||||
/** report an error */
|
||||
void reportError(const Token *tok, const Severity::SeverityType severity, const std::string &id, const std::string &msg) {
|
||||
void reportError(const Token *tok, const Severity severity, const std::string &id, const std::string &msg) {
|
||||
reportError(tok, severity, id, msg, CWE(0U), Certainty::normal);
|
||||
}
|
||||
|
||||
/** report an error */
|
||||
void reportError(const Token *tok, const Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty) {
|
||||
void reportError(const Token *tok, const Severity severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty) {
|
||||
const std::list<const Token *> callstack(1, tok);
|
||||
reportError(callstack, severity, id, msg, cwe, certainty);
|
||||
}
|
||||
|
||||
/** report an error */
|
||||
void reportError(const std::list<const Token *> &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg) {
|
||||
void reportError(const std::list<const Token *> &callstack, Severity severity, const std::string &id, const std::string &msg) {
|
||||
reportError(callstack, severity, id, msg, CWE(0U), Certainty::normal);
|
||||
}
|
||||
|
||||
/** report an error */
|
||||
void reportError(const std::list<const Token *> &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty);
|
||||
void reportError(const std::list<const Token *> &callstack, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe, Certainty certainty);
|
||||
|
||||
void reportError(const ErrorPath &errorPath, Severity::SeverityType severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty);
|
||||
void reportError(const ErrorPath &errorPath, Severity severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty);
|
||||
|
||||
/** log checker */
|
||||
void logChecker(const char id[]);
|
||||
|
|
|
@ -1715,7 +1715,7 @@ void CheckIO::wrongPrintfScanfArgumentsError(const Token* tok,
|
|||
nonneg int numFormat,
|
||||
nonneg int numFunction)
|
||||
{
|
||||
const Severity::SeverityType severity = numFormat > numFunction ? Severity::error : Severity::warning;
|
||||
const Severity severity = numFormat > numFunction ? Severity::error : Severity::warning;
|
||||
if (severity != Severity::error && !mSettings->severity.isEnabled(Severity::warning))
|
||||
return;
|
||||
|
||||
|
@ -1749,7 +1749,7 @@ void CheckIO::wrongPrintfScanfPosixParameterPositionError(const Token* tok, cons
|
|||
|
||||
void CheckIO::invalidScanfArgTypeError_s(const Token* tok, nonneg int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
const Severity severity = getSeverity(argInfo);
|
||||
if (!mSettings->severity.isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1765,7 +1765,7 @@ void CheckIO::invalidScanfArgTypeError_s(const Token* tok, nonneg int numFormat,
|
|||
}
|
||||
void CheckIO::invalidScanfArgTypeError_int(const Token* tok, nonneg int numFormat, const std::string& specifier, const ArgumentInfo* argInfo, bool isUnsigned)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
const Severity severity = getSeverity(argInfo);
|
||||
if (!mSettings->severity.isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1810,7 +1810,7 @@ void CheckIO::invalidScanfArgTypeError_int(const Token* tok, nonneg int numForma
|
|||
}
|
||||
void CheckIO::invalidScanfArgTypeError_float(const Token* tok, nonneg int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
const Severity severity = getSeverity(argInfo);
|
||||
if (!mSettings->severity.isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1829,7 +1829,7 @@ void CheckIO::invalidScanfArgTypeError_float(const Token* tok, nonneg int numFor
|
|||
|
||||
void CheckIO::invalidPrintfArgTypeError_s(const Token* tok, nonneg int numFormat, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
const Severity severity = getSeverity(argInfo);
|
||||
if (!mSettings->severity.isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1840,7 +1840,7 @@ void CheckIO::invalidPrintfArgTypeError_s(const Token* tok, nonneg int numFormat
|
|||
}
|
||||
void CheckIO::invalidPrintfArgTypeError_n(const Token* tok, nonneg int numFormat, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
const Severity severity = getSeverity(argInfo);
|
||||
if (!mSettings->severity.isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1851,7 +1851,7 @@ void CheckIO::invalidPrintfArgTypeError_n(const Token* tok, nonneg int numFormat
|
|||
}
|
||||
void CheckIO::invalidPrintfArgTypeError_p(const Token* tok, nonneg int numFormat, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
const Severity severity = getSeverity(argInfo);
|
||||
if (!mSettings->severity.isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1901,7 +1901,7 @@ static void printfFormatType(std::ostream& os, const std::string& specifier, boo
|
|||
|
||||
void CheckIO::invalidPrintfArgTypeError_uint(const Token* tok, nonneg int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
const Severity severity = getSeverity(argInfo);
|
||||
if (!mSettings->severity.isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1915,7 +1915,7 @@ void CheckIO::invalidPrintfArgTypeError_uint(const Token* tok, nonneg int numFor
|
|||
|
||||
void CheckIO::invalidPrintfArgTypeError_sint(const Token* tok, nonneg int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
const Severity severity = getSeverity(argInfo);
|
||||
if (!mSettings->severity.isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1928,7 +1928,7 @@ void CheckIO::invalidPrintfArgTypeError_sint(const Token* tok, nonneg int numFor
|
|||
}
|
||||
void CheckIO::invalidPrintfArgTypeError_float(const Token* tok, nonneg int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
const Severity severity = getSeverity(argInfo);
|
||||
if (!mSettings->severity.isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1941,7 +1941,7 @@ void CheckIO::invalidPrintfArgTypeError_float(const Token* tok, nonneg int numFo
|
|||
reportError(tok, severity, "invalidPrintfArgType_float", errmsg.str(), CWE686, Certainty::normal);
|
||||
}
|
||||
|
||||
Severity::SeverityType CheckIO::getSeverity(const CheckIO::ArgumentInfo *argInfo)
|
||||
Severity CheckIO::getSeverity(const CheckIO::ArgumentInfo *argInfo)
|
||||
{
|
||||
return (argInfo && argInfo->typeToken && !argInfo->typeToken->originalName().empty()) ? Severity::portability : Severity::warning;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ private:
|
|||
void invalidLengthModifierError(const Token* tok, nonneg int numFormat, const std::string& modifier);
|
||||
void invalidScanfFormatWidthError(const Token* tok, nonneg int numFormat, int width, const Variable *var, const std::string& specifier);
|
||||
static void argumentType(std::ostream & os, const ArgumentInfo * argInfo);
|
||||
static Severity::SeverityType getSeverity(const ArgumentInfo *argInfo);
|
||||
static Severity getSeverity(const ArgumentInfo *argInfo);
|
||||
|
||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override {
|
||||
CheckIO c(nullptr, settings, errorLogger);
|
||||
|
|
|
@ -279,7 +279,7 @@ void CheckMemoryLeak::memoryLeak(const Token *tok, const std::string &varname, A
|
|||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckMemoryLeak::reportErr(const Token *tok, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe) const
|
||||
void CheckMemoryLeak::reportErr(const Token *tok, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe) const
|
||||
{
|
||||
std::list<const Token *> callstack;
|
||||
|
||||
|
@ -289,7 +289,7 @@ void CheckMemoryLeak::reportErr(const Token *tok, Severity::SeverityType severit
|
|||
reportErr(callstack, severity, id, msg, cwe);
|
||||
}
|
||||
|
||||
void CheckMemoryLeak::reportErr(const std::list<const Token *> &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe) const
|
||||
void CheckMemoryLeak::reportErr(const std::list<const Token *> &callstack, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe) const
|
||||
{
|
||||
const ErrorMessage errmsg(callstack, mTokenizer_ ? &mTokenizer_->list : nullptr, severity, id, msg, cwe, Certainty::normal);
|
||||
if (mErrorLogger_)
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
* @param msg text
|
||||
* @param cwe cwe number
|
||||
*/
|
||||
void reportErr(const Token *tok, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe) const;
|
||||
void reportErr(const Token *tok, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe) const;
|
||||
|
||||
/**
|
||||
* Report error. Similar with the function Check::reportError
|
||||
|
@ -80,7 +80,7 @@ private:
|
|||
* @param msg text
|
||||
* @param cwe cwe number
|
||||
*/
|
||||
void reportErr(const std::list<const Token *> &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe) const;
|
||||
void reportErr(const std::list<const Token *> &callstack, Severity severity, const std::string &id, const std::string &msg, const CWE &cwe) const;
|
||||
|
||||
public:
|
||||
CheckMemoryLeak() = delete;
|
||||
|
|
|
@ -144,7 +144,7 @@ void CheckType::tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, con
|
|||
}
|
||||
|
||||
|
||||
Severity::SeverityType severity = rhsbits.errorSeverity() ? Severity::error : Severity::warning;
|
||||
Severity severity = rhsbits.errorSeverity() ? Severity::error : Severity::warning;
|
||||
if (cpp14)
|
||||
severity = Severity::portability;
|
||||
|
||||
|
|
|
@ -1429,8 +1429,8 @@ void CppCheck::executeAddons(const std::vector<std::string>& files)
|
|||
const std::string text = obj["message"].get<std::string>();
|
||||
errmsg.setmsg(text);
|
||||
const std::string severity = obj["severity"].get<std::string>();
|
||||
errmsg.severity = Severity::fromString(severity);
|
||||
if (errmsg.severity == Severity::SeverityType::none) {
|
||||
errmsg.severity = severityFromString(severity);
|
||||
if (errmsg.severity == Severity::none) {
|
||||
if (!endsWith(errmsg.id, "-logChecker"))
|
||||
continue;
|
||||
}
|
||||
|
@ -1672,13 +1672,13 @@ void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings)
|
|||
|
||||
errmsg.id = "clang-tidy-" + errorString.substr(1, errorString.length() - 2);
|
||||
if (errmsg.id.find("performance") != std::string::npos)
|
||||
errmsg.severity = Severity::SeverityType::performance;
|
||||
errmsg.severity = Severity::performance;
|
||||
else if (errmsg.id.find("portability") != std::string::npos)
|
||||
errmsg.severity = Severity::SeverityType::portability;
|
||||
errmsg.severity = Severity::portability;
|
||||
else if (errmsg.id.find("cert") != std::string::npos || errmsg.id.find("misc") != std::string::npos || errmsg.id.find("unused") != std::string::npos)
|
||||
errmsg.severity = Severity::SeverityType::warning;
|
||||
errmsg.severity = Severity::warning;
|
||||
else
|
||||
errmsg.severity = Severity::SeverityType::style;
|
||||
errmsg.severity = Severity::style;
|
||||
|
||||
errmsg.file0 = fixedpath;
|
||||
errmsg.setmsg(messageString);
|
||||
|
|
|
@ -58,7 +58,7 @@ ErrorMessage::ErrorMessage()
|
|||
{}
|
||||
|
||||
// TODO: id and msg are swapped compared to other calls
|
||||
ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity::SeverityType severity, const std::string &msg, std::string id, Certainty certainty) :
|
||||
ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity 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
|
||||
file0(std::move(file1)),
|
||||
|
@ -73,7 +73,7 @@ ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1,
|
|||
|
||||
|
||||
// TODO: id and msg are swapped compared to other calls
|
||||
ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity::SeverityType severity, const std::string &msg, std::string id, const CWE &cwe, Certainty certainty) :
|
||||
ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity 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
|
||||
file0(std::move(file1)),
|
||||
|
@ -86,7 +86,7 @@ ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1,
|
|||
setmsg(msg);
|
||||
}
|
||||
|
||||
ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity::SeverityType severity, std::string id, const std::string& msg, Certainty certainty)
|
||||
ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity severity, std::string id, const std::string& msg, Certainty certainty)
|
||||
: id(std::move(id)), severity(severity), cwe(0U), certainty(certainty), hash(0)
|
||||
{
|
||||
// Format callstack
|
||||
|
@ -105,7 +105,7 @@ ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const Token
|
|||
}
|
||||
|
||||
|
||||
ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity::SeverityType severity, std::string id, const std::string& msg, const CWE &cwe, Certainty certainty)
|
||||
ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const TokenList* list, Severity severity, std::string id, const std::string& msg, const CWE &cwe, Certainty certainty)
|
||||
: id(std::move(id)), severity(severity), cwe(cwe.id), certainty(certainty)
|
||||
{
|
||||
// Format callstack
|
||||
|
@ -125,7 +125,7 @@ ErrorMessage::ErrorMessage(const std::list<const Token*>& callstack, const Token
|
|||
hash = 0; // calculateWarningHash(list, hashWarning.str());
|
||||
}
|
||||
|
||||
ErrorMessage::ErrorMessage(const ErrorPath &errorPath, const TokenList *tokenList, Severity::SeverityType severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty)
|
||||
ErrorMessage::ErrorMessage(const ErrorPath &errorPath, const TokenList *tokenList, Severity severity, const char id[], const std::string &msg, const CWE &cwe, Certainty certainty)
|
||||
: id(id), severity(severity), cwe(cwe.id), certainty(certainty)
|
||||
{
|
||||
// Format callstack
|
||||
|
@ -165,7 +165,7 @@ ErrorMessage::ErrorMessage(const tinyxml2::XMLElement * const errmsg)
|
|||
id = attr ? attr : unknown;
|
||||
|
||||
attr = errmsg->Attribute("severity");
|
||||
severity = attr ? Severity::fromString(attr) : Severity::none;
|
||||
severity = attr ? severityFromString(attr) : Severity::none;
|
||||
|
||||
attr = errmsg->Attribute("cwe");
|
||||
cwe.id = attr ? strToInt<unsigned short>(attr) : 0;
|
||||
|
@ -267,7 +267,7 @@ std::string ErrorMessage::serialize() const
|
|||
// Serialize this message into a simple string
|
||||
std::string oss;
|
||||
serializeString(oss, id);
|
||||
serializeString(oss, Severity::toString(severity));
|
||||
serializeString(oss, severityToString(severity));
|
||||
serializeString(oss, std::to_string(cwe.id));
|
||||
serializeString(oss, std::to_string(hash));
|
||||
serializeString(oss, file0);
|
||||
|
@ -345,7 +345,7 @@ void ErrorMessage::deserialize(const std::string &data)
|
|||
throw InternalError(nullptr, "Internal Error: Deserialization of error message failed - insufficient elements");
|
||||
|
||||
id = std::move(results[0]);
|
||||
severity = Severity::fromString(results[1]);
|
||||
severity = severityFromString(results[1]);
|
||||
cwe.id = 0;
|
||||
if (!results[2].empty()) {
|
||||
std::string err;
|
||||
|
@ -483,7 +483,7 @@ std::string ErrorMessage::toXML() const
|
|||
tinyxml2::XMLPrinter printer(nullptr, false, 2);
|
||||
printer.OpenElement("error", false);
|
||||
printer.PushAttribute("id", id.c_str());
|
||||
printer.PushAttribute("severity", Severity::toString(severity).c_str());
|
||||
printer.PushAttribute("severity", severityToString(severity).c_str());
|
||||
printer.PushAttribute("msg", fixInvalidChars(mShortMessage).c_str());
|
||||
printer.PushAttribute("verbose", fixInvalidChars(mVerboseMessage).c_str());
|
||||
if (cwe.id)
|
||||
|
@ -629,7 +629,7 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
|
|||
}
|
||||
if (severity != Severity::none) {
|
||||
text += '(';
|
||||
text += Severity::toString(severity);
|
||||
text += severityToString(severity);
|
||||
if (certainty == Certainty::inconclusive)
|
||||
text += ", inconclusive";
|
||||
text += ") ";
|
||||
|
@ -651,7 +651,7 @@ std::string ErrorMessage::toString(bool verbose, const std::string &templateForm
|
|||
findAndReplace(result, replaceFrom, replaceWith);
|
||||
pos1 = result.find("{inconclusive:", pos1);
|
||||
}
|
||||
findAndReplace(result, "{severity}", Severity::toString(severity));
|
||||
findAndReplace(result, "{severity}", severityToString(severity));
|
||||
findAndReplace(result, "{cwe}", std::to_string(cwe.id));
|
||||
findAndReplace(result, "{message}", verbose ? mVerboseMessage : mShortMessage);
|
||||
if (!callStack.empty()) {
|
||||
|
@ -882,7 +882,7 @@ std::string ErrorLogger::plistData(const ErrorMessage &msg)
|
|||
|
||||
plist << " </array>\r\n"
|
||||
<< " <key>description</key><string>" << ErrorLogger::toxml(msg.shortMessage()) << "</string>\r\n"
|
||||
<< " <key>category</key><string>" << Severity::toString(msg.severity) << "</string>\r\n"
|
||||
<< " <key>category</key><string>" << severityToString(msg.severity) << "</string>\r\n"
|
||||
<< " <key>type</key><string>" << ErrorLogger::toxml(msg.shortMessage()) << "</string>\r\n"
|
||||
<< " <key>check_name</key><string>" << msg.id << "</string>\r\n"
|
||||
<< " <!-- This hash is experimental and going to change! -->\r\n"
|
||||
|
|
|
@ -110,32 +110,32 @@ public:
|
|||
|
||||
ErrorMessage(std::list<FileLocation> callStack,
|
||||
std::string file1,
|
||||
Severity::SeverityType severity,
|
||||
Severity severity,
|
||||
const std::string &msg,
|
||||
std::string id, Certainty certainty);
|
||||
ErrorMessage(std::list<FileLocation> callStack,
|
||||
std::string file1,
|
||||
Severity::SeverityType severity,
|
||||
Severity severity,
|
||||
const std::string &msg,
|
||||
std::string id,
|
||||
const CWE &cwe,
|
||||
Certainty certainty);
|
||||
ErrorMessage(const std::list<const Token*>& callstack,
|
||||
const TokenList* list,
|
||||
Severity::SeverityType severity,
|
||||
Severity severity,
|
||||
std::string id,
|
||||
const std::string& msg,
|
||||
Certainty certainty);
|
||||
ErrorMessage(const std::list<const Token*>& callstack,
|
||||
const TokenList* list,
|
||||
Severity::SeverityType severity,
|
||||
Severity severity,
|
||||
std::string id,
|
||||
const std::string& msg,
|
||||
const CWE &cwe,
|
||||
Certainty certainty);
|
||||
ErrorMessage(const ErrorPath &errorPath,
|
||||
const TokenList *tokenList,
|
||||
Severity::SeverityType severity,
|
||||
Severity severity,
|
||||
const char id[],
|
||||
const std::string &msg,
|
||||
const CWE &cwe,
|
||||
|
@ -173,7 +173,7 @@ public:
|
|||
/** For GUI rechecking; source file (not header) */
|
||||
std::string file0;
|
||||
|
||||
Severity::SeverityType severity;
|
||||
Severity severity;
|
||||
CWE cwe;
|
||||
Certainty certainty;
|
||||
|
||||
|
|
|
@ -47,47 +47,48 @@ InternalError::InternalError(const Token *tok, std::string errorMsg, std::string
|
|||
token(tok), errorMessage(std::move(errorMsg)), details(std::move(details)), type(type), id(typeToString(type))
|
||||
{}
|
||||
|
||||
std::string Severity::toString(Severity::SeverityType severity)
|
||||
std::string severityToString(Severity severity)
|
||||
{
|
||||
switch (severity) {
|
||||
case none:
|
||||
case Severity::none:
|
||||
return "";
|
||||
case error:
|
||||
case Severity::error:
|
||||
return "error";
|
||||
case warning:
|
||||
case Severity::warning:
|
||||
return "warning";
|
||||
case style:
|
||||
case Severity::style:
|
||||
return "style";
|
||||
case performance:
|
||||
case Severity::performance:
|
||||
return "performance";
|
||||
case portability:
|
||||
case Severity::portability:
|
||||
return "portability";
|
||||
case information:
|
||||
case Severity::information:
|
||||
return "information";
|
||||
case debug:
|
||||
case Severity::debug:
|
||||
return "debug";
|
||||
}
|
||||
throw InternalError(nullptr, "Unknown severity");
|
||||
}
|
||||
Severity::SeverityType Severity::fromString(const std::string& severity)
|
||||
|
||||
Severity severityFromString(const std::string& severity)
|
||||
{
|
||||
if (severity.empty())
|
||||
return none;
|
||||
return Severity::none;
|
||||
if (severity == "none")
|
||||
return none;
|
||||
return Severity::none;
|
||||
if (severity == "error")
|
||||
return error;
|
||||
return Severity::error;
|
||||
if (severity == "warning")
|
||||
return warning;
|
||||
return Severity::warning;
|
||||
if (severity == "style")
|
||||
return style;
|
||||
return Severity::style;
|
||||
if (severity == "performance")
|
||||
return performance;
|
||||
return Severity::performance;
|
||||
if (severity == "portability")
|
||||
return portability;
|
||||
return Severity::portability;
|
||||
if (severity == "information")
|
||||
return information;
|
||||
return Severity::information;
|
||||
if (severity == "debug")
|
||||
return debug;
|
||||
return none;
|
||||
return Severity::debug;
|
||||
return Severity::none;
|
||||
}
|
||||
|
|
108
lib/errortypes.h
108
lib/errortypes.h
|
@ -60,67 +60,61 @@ enum class Checks {
|
|||
};
|
||||
|
||||
/** @brief enum class for severity. Used when reporting errors. */
|
||||
class CPPCHECKLIB Severity {
|
||||
public:
|
||||
enum class Severity {
|
||||
/**
|
||||
* Message severities.
|
||||
* No severity (default value).
|
||||
*/
|
||||
enum SeverityType {
|
||||
/**
|
||||
* No severity (default value).
|
||||
*/
|
||||
none,
|
||||
/**
|
||||
* Programming error.
|
||||
* This indicates severe error like memory leak etc.
|
||||
* The error is certain.
|
||||
*/
|
||||
error,
|
||||
/**
|
||||
* Warning.
|
||||
* Used for dangerous coding style that can cause severe runtime errors.
|
||||
* For example: forgetting to initialize a member variable in a constructor.
|
||||
*/
|
||||
warning,
|
||||
/**
|
||||
* Style warning.
|
||||
* Used for general code cleanup recommendations. Fixing these
|
||||
* will not fix any bugs but will make the code easier to maintain.
|
||||
* For example: redundant code, unreachable code, etc.
|
||||
*/
|
||||
style,
|
||||
/**
|
||||
* Performance warning.
|
||||
* Not an error as is but suboptimal code and fixing it probably leads
|
||||
* to faster performance of the compiled code.
|
||||
*/
|
||||
performance,
|
||||
/**
|
||||
* Portability warning.
|
||||
* This warning indicates the code is not properly portable for
|
||||
* different platforms and bitnesses (32/64 bit). If the code is meant
|
||||
* to compile in different platforms and bitnesses these warnings
|
||||
* should be fixed.
|
||||
*/
|
||||
portability,
|
||||
/**
|
||||
* Checking information.
|
||||
* Information message about the checking (process) itself. These
|
||||
* messages inform about header files not found etc issues that are
|
||||
* not errors in the code but something user needs to know.
|
||||
*/
|
||||
information,
|
||||
/**
|
||||
* Debug message.
|
||||
* Debug-mode message useful for the developers.
|
||||
*/
|
||||
debug
|
||||
};
|
||||
|
||||
static std::string toString(SeverityType severity);
|
||||
static SeverityType fromString(const std::string &severity);
|
||||
none,
|
||||
/**
|
||||
* Programming error.
|
||||
* This indicates severe error like memory leak etc.
|
||||
* The error is certain.
|
||||
*/
|
||||
error,
|
||||
/**
|
||||
* Warning.
|
||||
* Used for dangerous coding style that can cause severe runtime errors.
|
||||
* For example: forgetting to initialize a member variable in a constructor.
|
||||
*/
|
||||
warning,
|
||||
/**
|
||||
* Style warning.
|
||||
* Used for general code cleanup recommendations. Fixing these
|
||||
* will not fix any bugs but will make the code easier to maintain.
|
||||
* For example: redundant code, unreachable code, etc.
|
||||
*/
|
||||
style,
|
||||
/**
|
||||
* Performance warning.
|
||||
* Not an error as is but suboptimal code and fixing it probably leads
|
||||
* to faster performance of the compiled code.
|
||||
*/
|
||||
performance,
|
||||
/**
|
||||
* Portability warning.
|
||||
* This warning indicates the code is not properly portable for
|
||||
* different platforms and bitnesses (32/64 bit). If the code is meant
|
||||
* to compile in different platforms and bitnesses these warnings
|
||||
* should be fixed.
|
||||
*/
|
||||
portability,
|
||||
/**
|
||||
* Checking information.
|
||||
* Information message about the checking (process) itself. These
|
||||
* messages inform about header files not found etc issues that are
|
||||
* not errors in the code but something user needs to know.
|
||||
*/
|
||||
information,
|
||||
/**
|
||||
* Debug message.
|
||||
* Debug-mode message useful for the developers.
|
||||
*/
|
||||
debug
|
||||
};
|
||||
|
||||
CPPCHECKLIB std::string severityToString(Severity severity);
|
||||
CPPCHECKLIB Severity severityFromString(const std::string &severity);
|
||||
|
||||
struct CWE {
|
||||
explicit CWE(unsigned short cweId) : id(cweId) {}
|
||||
unsigned short id;
|
||||
|
|
|
@ -837,7 +837,7 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
|
|||
const char* const severity = functionnode->Attribute("severity");
|
||||
if (severity == nullptr)
|
||||
return Error(ErrorCode::MISSING_ATTRIBUTE, "severity");
|
||||
wi.severity = Severity::fromString(severity);
|
||||
wi.severity = severityFromString(severity);
|
||||
|
||||
const char* const cstd = functionnode->Attribute("cstd");
|
||||
if (cstd) {
|
||||
|
|
|
@ -164,7 +164,7 @@ public:
|
|||
struct WarnInfo {
|
||||
std::string message;
|
||||
Standards standards;
|
||||
Severity::SeverityType severity;
|
||||
Severity severity;
|
||||
};
|
||||
std::map<std::string, WarnInfo> functionwarn;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void Settings::loadCppcheckCfg()
|
|||
}
|
||||
}
|
||||
|
||||
std::string Settings::parseEnabled(const std::string &str, std::tuple<SimpleEnableGroup<Severity::SeverityType>, SimpleEnableGroup<Checks>> &groups)
|
||||
std::string Settings::parseEnabled(const std::string &str, std::tuple<SimpleEnableGroup<Severity>, SimpleEnableGroup<Checks>> &groups)
|
||||
{
|
||||
// Enable parameters may be comma separated...
|
||||
if (str.find(',') != std::string::npos) {
|
||||
|
@ -100,9 +100,9 @@ std::string Settings::parseEnabled(const std::string &str, std::tuple<SimpleEnab
|
|||
|
||||
if (str == "all") {
|
||||
// "error" is always enabled and cannot be controlled - so exclude it from "all"
|
||||
SimpleEnableGroup<Severity::SeverityType> newSeverity;
|
||||
SimpleEnableGroup<Severity> newSeverity;
|
||||
newSeverity.fill();
|
||||
newSeverity.disable(Severity::SeverityType::error);
|
||||
newSeverity.disable(Severity::error);
|
||||
severity.enable(newSeverity);
|
||||
checks.enable(Checks::missingInclude);
|
||||
checks.enable(Checks::unusedFunction);
|
||||
|
@ -148,7 +148,7 @@ std::string Settings::removeEnabled(const std::string &str)
|
|||
|
||||
std::string Settings::applyEnabled(const std::string &str, bool enable)
|
||||
{
|
||||
std::tuple<SimpleEnableGroup<Severity::SeverityType>, SimpleEnableGroup<Checks>> groups;
|
||||
std::tuple<SimpleEnableGroup<Severity>, SimpleEnableGroup<Checks>> groups;
|
||||
std::string errmsg = parseEnabled(str, groups);
|
||||
if (!errmsg.empty())
|
||||
return (enable ? "--enable" : "--disable") + errmsg;
|
||||
|
@ -164,7 +164,7 @@ std::string Settings::applyEnabled(const std::string &str, bool enable)
|
|||
checks.disable(c);
|
||||
}
|
||||
// FIXME: hack to make sure "error" is always enabled
|
||||
severity.enable(Severity::SeverityType::error);
|
||||
severity.enable(Severity::error);
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ public:
|
|||
std::string pattern;
|
||||
std::string id = "rule"; // default id
|
||||
std::string summary;
|
||||
Severity::SeverityType severity = Severity::style; // default severity
|
||||
Severity severity = Severity::style; // default severity
|
||||
};
|
||||
|
||||
#ifdef HAVE_RULES
|
||||
|
@ -335,7 +335,7 @@ public:
|
|||
|
||||
SafeChecks safeChecks;
|
||||
|
||||
SimpleEnableGroup<Severity::SeverityType> severity;
|
||||
SimpleEnableGroup<Severity> severity;
|
||||
SimpleEnableGroup<Certainty> certainty;
|
||||
SimpleEnableGroup<Checks> checks;
|
||||
|
||||
|
@ -439,7 +439,7 @@ public:
|
|||
void setCheckLevelNormal();
|
||||
|
||||
private:
|
||||
static std::string parseEnabled(const std::string &str, std::tuple<SimpleEnableGroup<Severity::SeverityType>, SimpleEnableGroup<Checks>> &groups);
|
||||
static std::string parseEnabled(const std::string &str, std::tuple<SimpleEnableGroup<Severity>, SimpleEnableGroup<Checks>> &groups);
|
||||
std::string applyEnabled(const std::string &str, bool enable);
|
||||
};
|
||||
|
||||
|
|
|
@ -10274,13 +10274,13 @@ void Tokenizer::prepareTernaryOpForAST()
|
|||
}
|
||||
}
|
||||
|
||||
void Tokenizer::reportError(const Token* tok, const Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive) const
|
||||
void Tokenizer::reportError(const Token* tok, const Severity severity, const std::string& id, const std::string& msg, bool inconclusive) const
|
||||
{
|
||||
const std::list<const Token*> callstack(1, tok);
|
||||
reportError(callstack, severity, id, msg, inconclusive);
|
||||
}
|
||||
|
||||
void Tokenizer::reportError(const std::list<const Token*>& callstack, Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive) const
|
||||
void Tokenizer::reportError(const std::list<const Token*>& callstack, Severity severity, const std::string& id, const std::string& msg, bool inconclusive) const
|
||||
{
|
||||
const ErrorMessage errmsg(callstack, &list, severity, id, msg, inconclusive ? Certainty::inconclusive : Certainty::normal);
|
||||
if (mErrorLogger)
|
||||
|
|
|
@ -572,8 +572,8 @@ private:
|
|||
/**
|
||||
* report error message
|
||||
*/
|
||||
void reportError(const Token* tok, const Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive = false) const;
|
||||
void reportError(const std::list<const Token*>& callstack, Severity::SeverityType severity, const std::string& id, const std::string& msg, bool inconclusive = false) const;
|
||||
void reportError(const Token* tok, const Severity severity, const std::string& id, const std::string& msg, bool inconclusive = false) const;
|
||||
void reportError(const std::list<const Token*>& callstack, Severity severity, const std::string& id, const std::string& msg, bool inconclusive = false) const;
|
||||
|
||||
bool duplicateTypedef(Token **tokPtr, const Token *name, const Token *typeDef) const;
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ protected:
|
|||
explicit SettingsBuilder(const TestFixture &fixture) : fixture(fixture) {}
|
||||
SettingsBuilder(const TestFixture &fixture, Settings settings) : fixture(fixture), settings(std::move(settings)) {}
|
||||
|
||||
SettingsBuilder& severity(Severity::SeverityType sev, bool b = true) {
|
||||
SettingsBuilder& severity(Severity sev, bool b = true) {
|
||||
if (REDUNDANT_CHECK && settings.severity.isEnabled(sev) == b)
|
||||
throw std::runtime_error("redundant setting: severity");
|
||||
settings.severity.setEnabled(sev, b);
|
||||
|
|
|
@ -281,7 +281,7 @@ private:
|
|||
ASSERT(doc.Parse(xmldata, sizeof(xmldata)) == tinyxml2::XML_SUCCESS);
|
||||
ErrorMessage msg(doc.FirstChildElement());
|
||||
ASSERT_EQUALS("errorId", msg.id);
|
||||
ASSERT_EQUALS(Severity::error, msg.severity);
|
||||
ASSERT_EQUALS(static_cast<int>(Severity::error), static_cast<int>(msg.severity));
|
||||
ASSERT_EQUALS(123u, msg.cwe.id);
|
||||
ASSERT_EQUALS(static_cast<int>(Certainty::inconclusive), static_cast<int>(msg.certainty));
|
||||
ASSERT_EQUALS("Programming error.", msg.shortMessage());
|
||||
|
@ -330,7 +330,7 @@ private:
|
|||
ErrorMessage msg2;
|
||||
ASSERT_NO_THROW(msg2.deserialize(msg_str));
|
||||
ASSERT_EQUALS("errorId", msg2.id);
|
||||
ASSERT_EQUALS(Severity::error, msg2.severity);
|
||||
ASSERT_EQUALS(static_cast<int>(Severity::error), static_cast<int>(msg2.severity));
|
||||
ASSERT_EQUALS("test.cpp", msg2.file0);
|
||||
ASSERT_EQUALS(static_cast<int>(Certainty::inconclusive), static_cast<int>(msg2.certainty));
|
||||
ASSERT_EQUALS("Programming error", msg2.shortMessage());
|
||||
|
@ -418,7 +418,7 @@ private:
|
|||
ErrorMessage msg2;
|
||||
ASSERT_NO_THROW(msg2.deserialize(msg_str));
|
||||
ASSERT_EQUALS("errorId", msg2.id);
|
||||
ASSERT_EQUALS(Severity::error, msg2.severity);
|
||||
ASSERT_EQUALS(static_cast<int>(Severity::error), static_cast<int>(msg2.severity));
|
||||
ASSERT_EQUALS("1.c", msg2.file0);
|
||||
ASSERT_EQUALS("Illegal character in \"foo\\001bar\"", msg2.shortMessage());
|
||||
ASSERT_EQUALS("Illegal character in \"foo\\001bar\"", msg2.verboseMessage());
|
||||
|
|
|
@ -645,12 +645,12 @@ private:
|
|||
ASSERT(a && b);
|
||||
if (a && b) {
|
||||
ASSERT_EQUALS("Message", a->message);
|
||||
ASSERT_EQUALS(Severity::style, a->severity);
|
||||
ASSERT_EQUALS(static_cast<int>(Severity::style), static_cast<int>(a->severity));
|
||||
ASSERT_EQUALS(Standards::C99, a->standards.c);
|
||||
ASSERT_EQUALS(Standards::CPP03, a->standards.cpp);
|
||||
|
||||
ASSERT_EQUALS("Obsolescent function 'b' called. It is recommended to use 'c', 'd' or 'e' instead.", b->message);
|
||||
ASSERT_EQUALS(Severity::performance, b->severity);
|
||||
ASSERT_EQUALS(static_cast<int>(Severity::performance), static_cast<int>(b->severity));
|
||||
ASSERT_EQUALS(Standards::C89, b->standards.c);
|
||||
ASSERT_EQUALS(Standards::CPP11, b->standards.cpp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue