Cppcheck
|
class for handling suppressions More...
#include <suppressions.h>
Classes | |
struct | ErrorMessage |
struct | Suppression |
Public Types | |
enum class | Type { unique , file , block , blockBegin , blockEnd , macro } |
Public Member Functions | |
std::string | parseFile (std::istream &istr) |
Don't show errors listed in the file. More... | |
std::string | parseXmlFile (const char *filename) |
Don't show errors listed in the file. More... | |
std::string | addSuppressionLine (const std::string &line) |
Don't show the given error. More... | |
std::string | addSuppression (Suppression suppression) |
Don't show this error. More... | |
std::string | addSuppressions (std::list< Suppression > suppressions) |
Combine list of suppressions into the current suppressions. More... | |
bool | isSuppressed (const ErrorMessage &errmsg, bool global=true) |
Returns true if this message should not be shown to the user. More... | |
bool | isSuppressedExplicitly (const ErrorMessage &errmsg, bool global=true) |
Returns true if this message is "explicitly" suppressed. More... | |
bool | isSuppressed (const ::ErrorMessage &errmsg, const std::set< std::string > ¯oNames) |
Returns true if this message should not be shown to the user. More... | |
void | dump (std::ostream &out) const |
Create an xml dump of suppressions. More... | |
std::list< Suppression > | getUnmatchedLocalSuppressions (const std::string &file, const bool unusedFunctionChecking) const |
Returns list of unmatched local (per-file) suppressions. More... | |
std::list< Suppression > | getUnmatchedGlobalSuppressions (const bool unusedFunctionChecking) const |
Returns list of unmatched global (glob pattern) suppressions. More... | |
const std::list< Suppression > & | getSuppressions () const |
Returns list of all suppressions. More... | |
void | markUnmatchedInlineSuppressionsAsChecked (const Tokenizer &tokenizer) |
Marks Inline Suppressions as checked if source line is in the token stream. More... | |
Static Public Member Functions | |
static std::vector< Suppression > | parseMultiSuppressComment (const std::string &comment, std::string *errorMessage) |
Parse multi inline suppression in comment. More... | |
static bool | reportUnmatchedSuppressions (const std::list< SuppressionList::Suppression > &unmatched, ErrorLogger &errorLogger) |
Report unmatched suppressions. More... | |
Private Attributes | |
std::list< Suppression > | mSuppressions |
List of error which the user doesn't want to see. More... | |
class for handling suppressions
Definition at line 42 of file suppressions.h.
|
strong |
Enumerator | |
---|---|
unique | |
file | |
block | |
blockBegin | |
blockEnd | |
macro |
Definition at line 45 of file suppressions.h.
std::string SuppressionList::addSuppression | ( | SuppressionList::Suppression | suppression | ) |
Don't show this error.
File and/or line are optional. In which case the errorId alone is used for filtering.
suppression | suppression details |
Definition at line 247 of file suppressions.cpp.
References SuppressionList::Suppression::errorId, SuppressionList::Suppression::fileName, SuppressionList::Suppression::hash, isAcceptedErrorIdChar(), SuppressionList::Suppression::isLocal(), SuppressionList::Suppression::isSameParameters(), isValidGlobPattern(), SuppressionList::Suppression::matched, and mSuppressions.
Referenced by addInlineSuppressions(), addSuppressionLine(), addSuppressions(), MainWindow::getCppcheckSettings(), and parseXmlFile().
std::string SuppressionList::addSuppressionLine | ( | const std::string & | line | ) |
Don't show the given error.
line | Description of error to suppress (in id:file:line format). |
Definition at line 199 of file suppressions.cpp.
References addSuppression(), SuppressionList::Suppression::errorId, SuppressionList::Suppression::fileName, SuppressionList::Suppression::lineNumber, SuppressionList::Suppression::NO_LINE, and Path::simplifyPath().
Referenced by Settings::loadCppcheckCfg(), parseFile(), and CmdLineParser::parseFromArgs().
std::string SuppressionList::addSuppressions | ( | std::list< Suppression > | suppressions | ) |
Combine list of suppressions into the current suppressions.
suppressions | list of suppression details |
Definition at line 282 of file suppressions.cpp.
References addSuppression().
Referenced by CppCheck::check().
void SuppressionList::dump | ( | std::ostream & | out | ) | const |
Create an xml dump of suppressions.
out | stream to write XML to |
Definition at line 445 of file suppressions.cpp.
References block, blockBegin, blockEnd, file, macro, mSuppressions, SuppressionList::Suppression::NO_LINE, and ErrorLogger::toxml().
Referenced by CppCheck::checkFile().
const std::list< SuppressionList::Suppression > & SuppressionList::getSuppressions | ( | ) | const |
Returns list of all suppressions.
Definition at line 519 of file suppressions.cpp.
References mSuppressions.
Referenced by CppCheck::check(), and CppCheckExecutor::reportSuppressions().
std::list< SuppressionList::Suppression > SuppressionList::getUnmatchedGlobalSuppressions | ( | const bool | unusedFunctionChecking | ) | const |
Returns list of unmatched global (glob pattern) suppressions.
Definition at line 500 of file suppressions.cpp.
References ID_CHECKERSREPORT, ID_UNUSEDFUNCTION, mSuppressions, and SuppressionList::Suppression::NO_LINE.
Referenced by CppCheckExecutor::reportSuppressions().
std::list< SuppressionList::Suppression > SuppressionList::getUnmatchedLocalSuppressions | ( | const std::string & | file, |
const bool | unusedFunctionChecking | ||
) | const |
Returns list of unmatched local (per-file) suppressions.
Definition at line 478 of file suppressions.cpp.
References ID_CHECKERSREPORT, ID_UNUSEDFUNCTION, macro, mSuppressions, SuppressionList::Suppression::NO_LINE, and Path::simplifyPath().
Referenced by CppCheck::checkFile(), and CppCheckExecutor::reportSuppressions().
bool SuppressionList::isSuppressed | ( | const ::ErrorMessage & | errmsg, |
const std::set< std::string > & | macroNames | ||
) |
Returns true if this message should not be shown to the user.
errmsg | error message |
Definition at line 438 of file suppressions.cpp.
References SuppressionList::ErrorMessage::fromErrorMessage(), isSuppressed(), and mSuppressions.
bool SuppressionList::isSuppressed | ( | const ErrorMessage & | errmsg, |
bool | global = true |
||
) |
Returns true if this message should not be shown to the user.
errmsg | error message |
global | use global suppressions |
Definition at line 410 of file suppressions.cpp.
References SuppressionList::ErrorMessage::errorId, and mSuppressions.
Referenced by Executor::hasToLog(), SuppressionList::Suppression::isMatch(), isSuppressed(), CppCheck::reportErr(), and ProcessExecutor::reportInternalChildErr().
bool SuppressionList::isSuppressedExplicitly | ( | const ErrorMessage & | errmsg, |
bool | global = true |
||
) |
Returns true if this message is "explicitly" suppressed.
The suppression "id" must match textually exactly.
errmsg | error message |
global | use global suppressions |
Definition at line 425 of file suppressions.cpp.
References SuppressionList::ErrorMessage::errorId, and mSuppressions.
Referenced by CppCheck::reportErr().
void SuppressionList::markUnmatchedInlineSuppressionsAsChecked | ( | const Tokenizer & | tokenizer | ) |
Marks Inline Suppressions as checked if source line is in the token stream.
Definition at line 524 of file suppressions.cpp.
References block, TokenList::file(), Tokenizer::list, mSuppressions, Token::next(), Tokenizer::tokens(), and unique.
Referenced by CppCheck::checkFile().
std::string SuppressionList::parseFile | ( | std::istream & | istr | ) |
Don't show errors listed in the file.
istr | Open file stream where errors can be read. |
Definition at line 71 of file suppressions.cpp.
References addSuppressionLine(), and replace().
Referenced by CmdLineParser::parseFromArgs().
|
static |
Parse multi inline suppression in comment.
comment | the full comment text |
errorMessage | output parameter for error message (wrong suppression attribute) |
Definition at line 142 of file suppressions.cpp.
References SuppressionList::Suppression::errorId, startsWith(), and SuppressionList::Suppression::symbolName.
Referenced by parseInlineSuppressionCommentToken().
std::string SuppressionList::parseXmlFile | ( | const char * | filename | ) |
Don't show errors listed in the file.
filename | file name |
Definition at line 102 of file suppressions.cpp.
References addSuppression(), error, SuppressionList::Suppression::errorId, SuppressionList::Suppression::fileName, SuppressionList::Suppression::hash, SuppressionList::Suppression::lineNumber, and SuppressionList::Suppression::symbolName.
Referenced by CmdLineParser::parseFromArgs().
|
static |
Report unmatched suppressions.
unmatched | list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions) |
Definition at line 548 of file suppressions.cpp.
References emptyString, information, SuppressionList::Suppression::NO_LINE, normal, and ErrorLogger::reportErr().
Referenced by CppCheck::checkFile(), and CppCheckExecutor::reportSuppressions().
|
private |
List of error which the user doesn't want to see.
Definition at line 258 of file suppressions.h.
Referenced by addSuppression(), dump(), getSuppressions(), getUnmatchedGlobalSuppressions(), getUnmatchedLocalSuppressions(), isSuppressed(), isSuppressedExplicitly(), and markUnmatchedInlineSuppressionsAsChecked().