Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/processexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ void ProcessExecutor::reportInternalChildErr(const std::string &childname, const
const ErrorMessage errmsg(std::move(locations),
"",
Severity::error,
"Internal error: " + msg,
"cppcheckError",
"Internal error: " + msg,
Certainty::normal);

if (!mSuppressions.nomsg.isSuppressed(errmsg, {}))
Expand Down
2 changes: 1 addition & 1 deletion gui/checkthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS
const std::string f0 = file0.toStdString();
const std::string msg = e.message.toStdString();
const std::string id = e.errorId.toStdString();
ErrorMessage errmsg(std::move(callstack), f0, e.severity, msg, id, Certainty::normal);
ErrorMessage errmsg(std::move(callstack), f0, e.severity, id, msg, Certainty::normal);
mResult.reportErr(errmsg);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/checkbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,8 @@ bool CheckBufferOverrun::analyseWholeProgram1(const std::map<std::string, std::l
const ErrorMessage errorMessage(std::move(locationList),
file0,
Severity::error,
errmsg,
errorId,
errmsg,
cwe, Certainty::normal);
errorLogger.reportErr(errorMessage);

Expand Down
2 changes: 1 addition & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3801,9 +3801,9 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo &ctu, const std::list<C
const ErrorMessage errmsg(std::move(locationList),
fi->file0,
Severity::error,
"ctuOneDefinitionRuleViolation",
"$symbol:" + nameLoc.className +
"\nThe one definition rule is violated, different classes/structs have the same name '$symbol'",
"ctuOneDefinitionRuleViolation",
CWE_ONE_DEFINITION_RULE,
Certainty::normal);
errorLogger.reportErr(errmsg);
Expand Down
2 changes: 1 addition & 1 deletion lib/checknullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,8 @@ bool CheckNullPointer::analyseWholeProgram(const CTU::FileInfo &ctu, const std::
ErrorMessage errmsg(std::move(locationList),
fi->file0,
warning ? Severity::warning : Severity::error,
message,
std::move(id),
message,
CWE_NULL_POINTER_DEREFERENCE, Certainty::normal);
errorLogger.reportErr(errmsg);

Expand Down
2 changes: 1 addition & 1 deletion lib/checkuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,8 +1789,8 @@ bool CheckUninitVar::analyseWholeProgram(const CTU::FileInfo &ctu, const std::li
const ErrorMessage errmsg(std::move(locationList),
fi->file0,
Severity::error,
"Using argument " + unsafeUsage.myArgumentName + " that points at uninitialized variable " + functionCall->callArgumentExpression,
"ctuuninitvar",
"Using argument " + unsafeUsage.myArgumentName + " that points at uninitialized variable " + functionCall->callArgumentExpression,
CWE_USE_OF_UNINITIALIZED_VARIABLE,
Certainty::normal);
errorLogger.reportErr(errmsg);
Expand Down
4 changes: 2 additions & 2 deletions lib/checkunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void CheckUnusedFunctions::staticFunctionError(ErrorLogger& errorLogger,
locationList.back().fileIndex = fileIndex;
}

const ErrorMessage errmsg(std::move(locationList), "", Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' should have static linkage since it is not used outside of its translation unit.", "staticFunction", Certainty::normal);
const ErrorMessage errmsg(std::move(locationList), "", Severity::style, "staticFunction", "$symbol:" + funcname + "\nThe function '$symbol' should have static linkage since it is not used outside of its translation unit.", Certainty::normal);
errorLogger.reportErr(errmsg);
}

Expand Down Expand Up @@ -413,7 +413,7 @@ void CheckUnusedFunctions::unusedFunctionError(ErrorLogger& errorLogger,
locationList.back().fileIndex = fileIndex;
}

const ErrorMessage errmsg(std::move(locationList), "", Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' is never used.", "unusedFunction", CWE561, Certainty::normal);
const ErrorMessage errmsg(std::move(locationList), "", Severity::style, "unusedFunction", "$symbol:" + funcname + "\nThe function '$symbol' is never used.", CWE561, Certainty::normal);
errorLogger.reportErr(errmsg);
}

Expand Down
25 changes: 13 additions & 12 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ static bool reportClangErrors(std::istream &is, const std::function<void(const E
ErrorMessage errmsg({std::move(loc)},
std::move(locFile),
Severity::error,
msg,
"syntaxError",
msg,
Certainty::normal);

if (line.compare(pos3, 10, ": warning:") == 0) {
Expand Down Expand Up @@ -984,8 +984,8 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
ErrorMessage errmsg({std::move(loc1)},
"", // TODO: is this correct?
Severity::error,
output.msg,
"syntaxError",
output.msg,
Certainty::normal);
mErrorLogger.reportErr(errmsg);
return mLogger->exitcode();
Expand Down Expand Up @@ -1243,8 +1243,8 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
ErrorMessage errmsg({std::move(loc1)},
file.spath(),
Severity::error,
o.msg,
"preprocessorErrorDirective",
o.msg,
Certainty::normal);
mErrorLogger.reportErr(errmsg);
}
Expand Down Expand Up @@ -1273,8 +1273,8 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string
ErrorMessage errmsg({std::move(loc)},
std::move(locFile),
Severity::information,
msg,
"noValidConfiguration",
msg,
Certainty::normal);
mErrorLogger.reportErr(errmsg);
}
Expand Down Expand Up @@ -1335,8 +1335,8 @@ void CppCheck::internalError(const std::string &filename, const std::string &msg
ErrorMessage errmsg({std::move(loc1)},
"",
Severity::error,
fullmsg,
"internalError",
fullmsg,
Certainty::normal);

mErrorLogger.reportErr(errmsg);
Expand Down Expand Up @@ -1370,8 +1370,8 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer, AnalyzerInformation
ErrorMessage errmsg({std::move(loc)},
"",
Severity::debug,
"Checks maximum time exceeded",
"checksMaxTime",
"Checks maximum time exceeded",
Certainty::normal);
mErrorLogger.reportErr(errmsg);
}
Expand Down Expand Up @@ -1601,8 +1601,8 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list)
const ErrorMessage errmsg({},
"",
Severity::error,
msg,
"pcre_compile",
msg,
Certainty::normal);

mErrorLogger.reportErr(errmsg);
Expand All @@ -1622,8 +1622,8 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list)
const ErrorMessage errmsg({},
"",
Severity::error,
msg,
"pcre_study",
msg,
Certainty::normal);

mErrorLogger.reportErr(errmsg);
Expand All @@ -1645,8 +1645,8 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list)
const ErrorMessage errmsg({},
"",
Severity::error,
std::string("pcre_exec failed: ") + errorMessage,
"pcre_exec",
std::string("pcre_exec failed: ") + errorMessage,
Certainty::normal);

mErrorLogger.reportErr(errmsg);
Expand Down Expand Up @@ -1681,8 +1681,8 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list)
const ErrorMessage errmsg({std::move(loc)},
list.getSourceFilePath(),
rule.severity,
!rule.summary.empty() ? rule.summary : "found '" + str.substr(pos1, pos2 - pos1) + "'",
rule.id,
!rule.summary.empty() ? rule.summary : "found '" + str.substr(pos1, pos2 - pos1) + "'",
Certainty::normal);

// Report error
Expand Down Expand Up @@ -1890,8 +1890,9 @@ void CppCheck::tooManyConfigsError(const std::string &file, const int numberOfCo
ErrorMessage errmsg(std::move(loclist),
"",
Severity::information,
"toomanyconfigs",
msg.str(),
"toomanyconfigs", CWE398,
CWE398,
Certainty::normal);

mErrorLogger.reportErr(errmsg);
Expand All @@ -1912,8 +1913,8 @@ void CppCheck::purgedConfigurationMessage(const std::string &file, const std::st
ErrorMessage errmsg(std::move(loclist),
"",
Severity::information,
"The configuration '" + configuration + "' was not checked because its code equals another one.",
"purgedConfiguration",
"The configuration '" + configuration + "' was not checked because its code equals another one.",
Certainty::normal);

mErrorLogger.reportErr(errmsg);
Expand Down
9 changes: 3 additions & 6 deletions lib/errorlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,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<FileLocation> callStack, std::string file1, Severity severity, const std::string &msg, std::string id, Certainty certainty) :
ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity severity, std::string id, const std::string &msg, Certainty certainty) :
callStack(std::move(callStack)), // locations for this error message
id(std::move(id)), // set the message id
file0(std::move(file1)),
Expand All @@ -74,9 +73,7 @@ ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1,
setmsg(msg);
}


// TODO: id and msg are swapped compared to other calls
ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity severity, const std::string &msg, std::string id, const CWE &cwe, Certainty certainty) :
ErrorMessage::ErrorMessage(std::list<FileLocation> callStack, std::string file1, Severity severity, std::string id, const std::string &msg,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)),
Expand Down Expand Up @@ -262,8 +259,8 @@ ErrorMessage ErrorMessage::fromInternalError(const InternalError &internalError,
ErrorMessage errmsg(std::move(locationList),
tokenList ? tokenList->getSourceFilePath() : filename,
Severity::error,
(msg.empty() ? "" : (msg + ": ")) + internalError.errorMessage,
internalError.id,
(msg.empty() ? "" : (msg + ": ")) + internalError.errorMessage,
Certainty::normal);
// TODO: find a better way
if (!internalError.details.empty())
Expand Down
5 changes: 3 additions & 2 deletions lib/errorlogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ class CPPCHECKLIB ErrorMessage {
ErrorMessage(std::list<FileLocation> callStack,
std::string file1,
Severity severity,
std::string id,
const std::string &msg,
std::string id, Certainty certainty);
Certainty certainty);
ErrorMessage(std::list<FileLocation> callStack,
std::string file1,
Severity severity,
const std::string &msg,
std::string id,
const std::string &msg,
const CWE &cwe,
Certainty certainty);
ErrorMessage(const std::list<const Token*>& callstack,
Expand Down
2 changes: 1 addition & 1 deletion lib/forwardanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ namespace {

void reportError(Severity severity, const std::string& id, const std::string& msg) {
ErrorMessage::FileLocation loc(tokenList.getSourceFilePath(), 0, 0);
const ErrorMessage errmsg({std::move(loc)}, tokenList.getSourceFilePath(), severity, msg, id, Certainty::normal);
const ErrorMessage errmsg({std::move(loc)}, tokenList.getSourceFilePath(), severity, id, msg, Certainty::normal);
errorLogger.reportErr(errmsg);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,8 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, const
mErrorLogger.reportErr(ErrorMessage(std::move(locationList),
mFile0,
Severity::error,
msg,
"preprocessorErrorDirective",
msg,
Certainty::normal));
}

Expand All @@ -918,10 +918,10 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line
locationList.emplace_back(filename, linenr, 0);
}
ErrorMessage errmsg(std::move(locationList), mFile0, Severity::information,
(headerType==SystemHeader) ? "missingIncludeSystem" : "missingInclude",
(headerType==SystemHeader) ?
"Include file: <" + header + "> not found. Please note: Cppcheck does not need standard library headers to get proper results." :
"Include file: \"" + header + "\" not found.",
(headerType==SystemHeader) ? "missingIncludeSystem" : "missingInclude",
Certainty::normal);
mErrorLogger.reportErr(errmsg);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/suppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ bool SuppressionList::reportUnmatchedSuppressions(const std::list<SuppressionLis
std::list<::ErrorMessage::FileLocation> callStack;
if (!s.fileName.empty())
callStack.emplace_back(s.fileName, s.lineNumber, 0);
errorLogger.reportErr(::ErrorMessage(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, "unmatchedSuppression", Certainty::normal));
errorLogger.reportErr(::ErrorMessage(std::move(callStack), "", Severity::information, "unmatchedSuppression", "Unmatched suppression: " + s.errorId, Certainty::normal));
err = true;
}
return err;
Expand Down
4 changes: 2 additions & 2 deletions lib/templatesimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3226,8 +3226,8 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
ErrorMessage errmsg({std::move(loc)},
"",
Severity::debug,
"Template instantiation maximum time exceeded",
"templateMaxTime",
"Template instantiation maximum time exceeded",
Certainty::normal);
mErrorLogger.reportErr(errmsg);
}
Expand Down Expand Up @@ -3302,8 +3302,8 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
ErrorMessage errmsg({std::move(loc)},
"",
Severity::debug,
"Template instantiation maximum time exceeded",
"templateMaxTime",
"Template instantiation maximum time exceeded",
Certainty::normal);
mErrorLogger.reportErr(errmsg);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,8 @@ void Tokenizer::simplifyTypedefCpp()
ErrorMessage errmsg({std::move(loc)},
"",
Severity::debug,
"Typedef simplification instantiation maximum time exceeded",
"typedefMaxTime",
"Typedef simplification instantiation maximum time exceeded",
Certainty::normal);
mErrorLogger.reportErr(errmsg);
}
Expand Down
Loading