Refactorization: Reimplemented Settings::_enabled as a bitfeld instead of std::set (#7995)
This commit is contained in:
parent
4d1a64301c
commit
b1f4bd7504
|
@ -325,7 +325,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
return false;
|
||||
}
|
||||
// when "style" is enabled, also enable "warning", "performance" and "portability"
|
||||
if (_settings->isEnabled("style")) {
|
||||
if (_settings->isEnabled(Settings::STYLE)) {
|
||||
_settings->addEnabled("warning");
|
||||
_settings->addEnabled("performance");
|
||||
_settings->addEnabled("portability");
|
||||
|
@ -759,7 +759,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
|||
else if ((def || _settings->preprocessOnly) && !maxconfigs)
|
||||
_settings->maxConfigs = 1U;
|
||||
|
||||
if (_settings->isEnabled("unusedFunction") && _settings->jobs > 1) {
|
||||
if (_settings->isEnabled(Settings::UNUSED_FUNCTION) && _settings->jobs > 1) {
|
||||
PrintMessage("cppcheck: unusedFunction check can't be used with '-j' option. Disabling unusedFunction check.");
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
|||
++iter;
|
||||
else {
|
||||
// If the include path is not found, warn user and remove the non-existing path from the list.
|
||||
if (settings.isEnabled("information"))
|
||||
if (settings.isEnabled(Settings::INFORMATION))
|
||||
std::cout << "(information) Couldn't find path given by -I '" << path << '\'' << std::endl;
|
||||
iter = settings.includePaths.erase(iter);
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
|
|||
|
||||
cppcheck.analyseWholeProgram(_settings->buildDir, _files);
|
||||
|
||||
if (settings.isEnabled("information") || settings.checkConfiguration) {
|
||||
if (settings.isEnabled(Settings::INFORMATION) || settings.checkConfiguration) {
|
||||
const bool enableUnusedFunctionCheck = cppcheck.isUnusedFunctionCheckEnabled();
|
||||
|
||||
if (settings.jointSuppressionReport) {
|
||||
|
@ -879,7 +879,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
|
|||
if (!settings.checkConfiguration) {
|
||||
cppcheck.tooManyConfigsError("",0U);
|
||||
|
||||
if (settings.isEnabled("missingInclude") && (Preprocessor::missingIncludeFlag || Preprocessor::missingSystemIncludeFlag)) {
|
||||
if (settings.isEnabled(Settings::MISSING_INCLUDE) && (Preprocessor::missingIncludeFlag || Preprocessor::missingSystemIncludeFlag)) {
|
||||
const std::list<ErrorLogger::ErrorMessage::FileLocation> callStack;
|
||||
ErrorLogger::ErrorMessage msg(callStack,
|
||||
emptyString,
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace {
|
|||
|
||||
void Check64BitPortability::pointerassignment()
|
||||
{
|
||||
if (!_settings->isEnabled("portability"))
|
||||
if (!_settings->isEnabled(Settings::PORTABILITY))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace {
|
|||
|
||||
void CheckAssert::assertWithSideEffects()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
for (const Token* tok = _tokenizer->list.front(); tok; tok = tok->next()) {
|
||||
|
|
|
@ -168,8 +168,8 @@ static bool variableIsUsedInScope(const Token* start, unsigned int varId, const
|
|||
|
||||
void CheckAutoVariables::assignFunctionArg()
|
||||
{
|
||||
const bool printStyle = _settings->isEnabled("style");
|
||||
const bool printWarning = _settings->isEnabled("warning");
|
||||
const bool printStyle = _settings->isEnabled(Settings::STYLE);
|
||||
const bool printWarning = _settings->isEnabled(Settings::WARNING);
|
||||
if (!printStyle && !printWarning)
|
||||
return;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ static bool isNonBoolStdType(const Variable* var)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckBool::checkIncrementBoolean()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -81,7 +81,7 @@ void CheckBool::incrementBooleanError(const Token *tok)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckBool::checkBitwiseOnBoolean()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
// danmar: this is inconclusive because I don't like that there are
|
||||
|
@ -125,7 +125,7 @@ void CheckBool::bitwiseOnBooleanError(const Token *tok, const std::string &varna
|
|||
|
||||
void CheckBool::checkComparisonOfBoolWithInt()
|
||||
{
|
||||
if (!_settings->isEnabled("warning") || !_tokenizer->isCPP())
|
||||
if (!_settings->isEnabled(Settings::WARNING) || !_tokenizer->isCPP())
|
||||
return;
|
||||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -176,7 +176,7 @@ static bool tokenIsFunctionReturningBool(const Token* tok)
|
|||
|
||||
void CheckBool::checkComparisonOfFuncReturningBool()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
if (!_tokenizer->isCPP())
|
||||
|
@ -240,7 +240,7 @@ void CheckBool::checkComparisonOfBoolWithBool()
|
|||
if (!_settings->experimental)
|
||||
return;
|
||||
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
if (!_tokenizer->isCPP())
|
||||
|
@ -319,7 +319,7 @@ void CheckBool::assignBoolToPointerError(const Token *tok)
|
|||
//-----------------------------------------------------------------------------
|
||||
void CheckBool::checkComparisonOfBoolExpressionWithInt()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -437,7 +437,7 @@ void CheckBool::checkAssignBoolToFloat()
|
|||
{
|
||||
if (!_tokenizer->isCPP())
|
||||
return;
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
|
|
|
@ -84,7 +84,7 @@ void CheckBufferOverrun::arrayIndexOutOfBoundsError(const Token *tok, const Arra
|
|||
}
|
||||
|
||||
if (condition != nullptr) {
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
std::ostringstream errmsg;
|
||||
|
@ -169,7 +169,7 @@ void CheckBufferOverrun::possibleBufferOverrunError(const Token *tok, const std:
|
|||
|
||||
void CheckBufferOverrun::strncatUsageError(const Token *tok)
|
||||
{
|
||||
if (_settings && !_settings->isEnabled("warning"))
|
||||
if (_settings && !_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
reportError(tok, Severity::warning, "strncatUsage",
|
||||
|
@ -220,7 +220,7 @@ void CheckBufferOverrun::pointerOutOfBoundsError(const Token *tok, const Token *
|
|||
|
||||
void CheckBufferOverrun::sizeArgumentAsCharError(const Token *tok)
|
||||
{
|
||||
if (_settings && !_settings->isEnabled("warning"))
|
||||
if (_settings && !_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
reportError(tok, Severity::warning, "sizeArgumentAsChar", "The size argument is given as a char constant.", CWE682, false);
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ void CheckBufferOverrun::checkFunctionParameter(const Token &ftok, unsigned int
|
|||
}
|
||||
|
||||
// Check 'float x[10]' arguments in declaration
|
||||
if (_settings->isEnabled("warning")) {
|
||||
if (_settings->isEnabled(Settings::WARNING)) {
|
||||
const Function* const func = ftok.function();
|
||||
|
||||
// If argument is '%type% a[num]' then check bounds against num
|
||||
|
@ -575,7 +575,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<const st
|
|||
// out of bounds then this flag will be set.
|
||||
bool pointerIsOutOfBounds = false;
|
||||
|
||||
const bool printPortability = _settings->isEnabled("portability");
|
||||
const bool printPortability = _settings->isEnabled(Settings::PORTABILITY);
|
||||
|
||||
for (const Token* const end = tok->scope()->classEnd; tok && tok != end; tok = tok->next()) {
|
||||
if (declarationId != 0 && Token::Match(tok, "%varid% = new|malloc|realloc", declarationId)) {
|
||||
|
@ -905,8 +905,8 @@ void CheckBufferOverrun::checkScope(const Token *tok, std::map<unsigned int, Arr
|
|||
|
||||
void CheckBufferOverrun::checkScope_inner(const Token *tok, const ArrayInfo &arrayInfo)
|
||||
{
|
||||
const bool printPortability = _settings->isEnabled("portability");
|
||||
const bool printWarning = _settings->isEnabled("warning");
|
||||
const bool printPortability = _settings->isEnabled(Settings::PORTABILITY);
|
||||
const bool printWarning = _settings->isEnabled(Settings::WARNING);
|
||||
const bool printInconclusive = _settings->inconclusive;
|
||||
|
||||
if (tok->strAt(1) == "[") {
|
||||
|
@ -1853,7 +1853,7 @@ MathLib::bigint CheckBufferOverrun::ArrayInfo::totalIndex(const std::vector<Valu
|
|||
|
||||
void CheckBufferOverrun::arrayIndexThenCheck()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
|
|
|
@ -80,8 +80,8 @@ CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings *settings, Err
|
|||
|
||||
void CheckClass::constructors()
|
||||
{
|
||||
const bool printStyle = _settings->isEnabled("style");
|
||||
const bool printWarnings = _settings->isEnabled("warning");
|
||||
const bool printStyle = _settings->isEnabled(Settings::STYLE);
|
||||
const bool printWarnings = _settings->isEnabled(Settings::WARNING);
|
||||
if (!printStyle && !printWarnings)
|
||||
return;
|
||||
|
||||
|
@ -238,7 +238,7 @@ void CheckClass::constructors()
|
|||
|
||||
void CheckClass::checkExplicitConstructors()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const std::size_t classes = symbolDatabase->classAndStructScopes.size();
|
||||
|
@ -286,7 +286,7 @@ void CheckClass::checkExplicitConstructors()
|
|||
|
||||
void CheckClass::copyconstructors()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const std::size_t classes = symbolDatabase->classAndStructScopes.size();
|
||||
|
@ -833,7 +833,7 @@ void CheckClass::operatorEqVarError(const Token *tok, const std::string &classna
|
|||
|
||||
void CheckClass::initializationListUsage()
|
||||
{
|
||||
if (!_settings->isEnabled("performance"))
|
||||
if (!_settings->isEnabled(Settings::PERFORMANCE))
|
||||
return;
|
||||
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
|
@ -948,7 +948,7 @@ static bool checkFunctionUsage(const Function *privfunc, const Scope* scope)
|
|||
|
||||
void CheckClass::privateFunctions()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const std::size_t classes = symbolDatabase->classAndStructScopes.size();
|
||||
|
@ -1018,7 +1018,7 @@ static const Scope* findFunctionOf(const Scope* scope)
|
|||
|
||||
void CheckClass::checkMemset()
|
||||
{
|
||||
const bool printWarnings = _settings->isEnabled("warning");
|
||||
const bool printWarnings = _settings->isEnabled(Settings::WARNING);
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
|
@ -1105,7 +1105,7 @@ void CheckClass::checkMemsetType(const Scope *start, const Token *tok, const Sco
|
|||
return;
|
||||
parsedTypes.insert(type);
|
||||
|
||||
const bool printPortability = _settings->isEnabled("portability");
|
||||
const bool printPortability = _settings->isEnabled(Settings::PORTABILITY);
|
||||
|
||||
// recursively check all parent classes
|
||||
for (std::size_t i = 0; i < type->definedType->derivedFrom.size(); i++) {
|
||||
|
@ -1209,7 +1209,7 @@ void CheckClass::memsetErrorFloat(const Token *tok, const std::string &type)
|
|||
|
||||
void CheckClass::operatorEq()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const std::size_t classes = symbolDatabase->classAndStructScopes.size();
|
||||
|
@ -1263,7 +1263,7 @@ void CheckClass::operatorEqReturnError(const Token *tok, const std::string &clas
|
|||
|
||||
void CheckClass::operatorEqRetRefThis()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const std::size_t classes = symbolDatabase->classAndStructScopes.size();
|
||||
|
@ -1399,7 +1399,7 @@ void CheckClass::operatorEqMissingReturnStatementError(const Token *tok, bool er
|
|||
|
||||
void CheckClass::operatorEqToSelf()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const std::size_t classes = symbolDatabase->classAndStructScopes.size();
|
||||
|
@ -1648,7 +1648,7 @@ void CheckClass::virtualDestructor()
|
|||
void CheckClass::virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived, bool inconclusive)
|
||||
{
|
||||
if (inconclusive) {
|
||||
if (_settings->isEnabled("warning"))
|
||||
if (_settings->isEnabled(Settings::WARNING))
|
||||
reportError(tok, Severity::warning, "virtualDestructor", "Class '" + Base + "' which has virtual members does not have a virtual destructor.", CWE404, true);
|
||||
} else {
|
||||
reportError(tok, Severity::error, "virtualDestructor", "Class '" + Base + "' which is inherited by class '" + Derived + "' does not have a virtual destructor.\n"
|
||||
|
@ -1665,7 +1665,7 @@ void CheckClass::virtualDestructorError(const Token *tok, const std::string &Bas
|
|||
|
||||
void CheckClass::thisSubtraction()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const Token *tok = _tokenizer->tokens();
|
||||
|
@ -1696,7 +1696,7 @@ void CheckClass::checkConst()
|
|||
if (!_settings->inconclusive)
|
||||
return;
|
||||
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const std::size_t classes = symbolDatabase->classAndStructScopes.size();
|
||||
|
@ -2075,7 +2075,7 @@ namespace { // avoid one-definition-rule violation
|
|||
|
||||
void CheckClass::initializerListOrder()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
// This check is not inconclusive. However it only determines if the initialization
|
||||
|
@ -2183,7 +2183,7 @@ void CheckClass::selfInitializationError(const Token* tok, const std::string& va
|
|||
|
||||
void CheckClass::checkPureVirtualFunctionCall()
|
||||
{
|
||||
if (! _settings->isEnabled("warning"))
|
||||
if (! _settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
std::map<const Function *, std::list<const Token *> > callsPureVirtualFunctionMap;
|
||||
|
@ -2305,7 +2305,7 @@ void CheckClass::callsPureVirtualFunctionError(
|
|||
|
||||
void CheckClass::checkDuplInheritedMembers()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
// Iterate over all classes
|
||||
|
@ -2359,7 +2359,7 @@ void CheckClass::duplInheritedMembersError(const Token *tok1, const Token* tok2,
|
|||
|
||||
void CheckClass::checkCopyCtorAndEqOperator()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const std::size_t classes = symbolDatabase->classAndStructScopes.size();
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace {
|
|||
|
||||
void CheckCondition::assignIf()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
@ -249,7 +249,7 @@ static bool inBooleanFunction(const Token *tok)
|
|||
|
||||
void CheckCondition::checkBadBitmaskCheck()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
@ -277,7 +277,7 @@ void CheckCondition::badBitmaskCheckError(const Token *tok)
|
|||
|
||||
void CheckCondition::comparison()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
@ -395,7 +395,7 @@ bool CheckCondition::isOverlappingCond(const Token * const cond1, const Token *
|
|||
|
||||
void CheckCondition::multiCondition()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -437,7 +437,7 @@ void CheckCondition::multiConditionError(const Token *tok, unsigned int line1)
|
|||
|
||||
void CheckCondition::oppositeInnerCondition()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -674,8 +674,8 @@ static std::string conditionString(bool not1, const Token *expr1, const std::str
|
|||
|
||||
void CheckCondition::checkIncorrectLogicOperator()
|
||||
{
|
||||
const bool printStyle = _settings->isEnabled("style");
|
||||
const bool printWarning = _settings->isEnabled("warning");
|
||||
const bool printStyle = _settings->isEnabled(Settings::STYLE);
|
||||
const bool printWarning = _settings->isEnabled(Settings::WARNING);
|
||||
if (!printWarning && !printStyle)
|
||||
return;
|
||||
const bool printInconclusive = _settings->inconclusive;
|
||||
|
@ -869,7 +869,7 @@ void CheckCondition::redundantConditionError(const Token *tok, const std::string
|
|||
//-----------------------------------------------------------------------------
|
||||
void CheckCondition::checkModuloAlwaysTrueFalse()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -923,7 +923,7 @@ static int countPar(const Token *tok1, const Token *tok2)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckCondition::clarifyCondition()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const bool isC = _tokenizer->isC();
|
||||
|
@ -990,7 +990,7 @@ void CheckCondition::clarifyConditionError(const Token *tok, bool assign, bool b
|
|||
|
||||
void CheckCondition::alwaysTrueFalse()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -1067,7 +1067,7 @@ void CheckCondition::alwaysTrueFalseError(const Token *tok, bool knownResult)
|
|||
|
||||
void CheckCondition::checkInvalidTestForOverflow()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace {
|
|||
|
||||
void CheckExceptionSafety::destructors()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -74,7 +74,7 @@ void CheckExceptionSafety::destructors()
|
|||
|
||||
void CheckExceptionSafety::deallocThrow()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const bool printInconclusive = _settings->inconclusive;
|
||||
|
@ -143,7 +143,7 @@ void CheckExceptionSafety::deallocThrow()
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckExceptionSafety::checkRethrowCopy()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -171,7 +171,7 @@ void CheckExceptionSafety::checkRethrowCopy()
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckExceptionSafety::checkCatchExceptionByValue()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -275,7 +275,7 @@ void CheckExceptionSafety::nothrowThrows()
|
|||
//--------------------------------------------------------------------------
|
||||
void CheckExceptionSafety::unhandledExceptionSpecification()
|
||||
{
|
||||
if (!_settings->isEnabled("style") || !_settings->inconclusive)
|
||||
if (!_settings->isEnabled(Settings::STYLE) || !_settings->inconclusive)
|
||||
return;
|
||||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
|
|
@ -39,7 +39,7 @@ static const CWE CWE628(628U); // Function Call with Incorrectly Specified Argu
|
|||
|
||||
void CheckFunctions::checkProhibitedFunctions()
|
||||
{
|
||||
const bool checkAlloca = _settings->isEnabled("warning") && ((_settings->standards.c >= Standards::C99 && _tokenizer->isC()) || _settings->standards.cpp >= Standards::CPP11);
|
||||
const bool checkAlloca = _settings->isEnabled(Settings::WARNING) && ((_settings->standards.c >= Standards::C99 && _tokenizer->isC()) || _settings->standards.cpp >= Standards::CPP11);
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
for (unsigned int i = 0; i < symbolDatabase->functionScopes.size(); i++) {
|
||||
|
@ -67,7 +67,7 @@ void CheckFunctions::checkProhibitedFunctions()
|
|||
|
||||
const Library::WarnInfo* wi = _settings->library.getWarnInfo(tok);
|
||||
if (wi) {
|
||||
if (_settings->isEnabled(Severity::toString(wi->severity)) && _settings->standards.c >= wi->standards.c && _settings->standards.cpp >= wi->standards.cpp) {
|
||||
if (_settings->isEnabled(wi->severity) && _settings->standards.c >= wi->standards.c && _settings->standards.cpp >= wi->standards.cpp) {
|
||||
reportError(tok, wi->severity, tok->str() + "Called", wi->message, CWE477, false);
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ void CheckFunctions::invalidFunctionArgBoolError(const Token *tok, const std::st
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckFunctions::checkIgnoredReturnValue()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -205,8 +205,8 @@ void CheckFunctions::ignoredReturnValueError(const Token* tok, const std::string
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckFunctions::checkMathFunctions()
|
||||
{
|
||||
const bool styleC99 = _settings->isEnabled("style") && _settings->standards.c != Standards::C89 && _settings->standards.cpp != Standards::CPP03;
|
||||
const bool printWarnings = _settings->isEnabled("warning");
|
||||
const bool styleC99 = _settings->isEnabled(Settings::STYLE) && _settings->standards.c != Standards::C89 && _settings->standards.cpp != Standards::CPP03;
|
||||
const bool printWarnings = _settings->isEnabled(Settings::WARNING);
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
|
@ -294,7 +294,7 @@ void CheckFunctions::mathfunctionCallWarning(const Token *tok, const std::string
|
|||
|
||||
void CheckFunctions::checkLibraryMatchFunctions()
|
||||
{
|
||||
if (!_settings->checkLibrary || !_settings->isEnabled("information"))
|
||||
if (!_settings->checkLibrary || !_settings->isEnabled(Settings::INFORMATION))
|
||||
return;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
/** Simplified checks. The token list is simplified. */
|
||||
void runSimplifiedChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) {
|
||||
if (!settings->isEnabled("internal"))
|
||||
if (!settings->isEnabled(Settings::INTERNAL))
|
||||
return;
|
||||
|
||||
CheckInternal checkInternal(tokenizer, settings, errorLogger);
|
||||
|
|
|
@ -111,8 +111,8 @@ namespace {
|
|||
void CheckIO::checkFileUsage()
|
||||
{
|
||||
const bool windows = _settings->isWindowsPlatform();
|
||||
const bool printPortability = _settings->isEnabled("portability");
|
||||
const bool printWarnings = _settings->isEnabled("warning");
|
||||
const bool printPortability = _settings->isEnabled(Settings::PORTABILITY);
|
||||
const bool printWarnings = _settings->isEnabled(Settings::WARNING);
|
||||
|
||||
std::map<unsigned int, Filepointer> filepointers;
|
||||
|
||||
|
@ -377,7 +377,7 @@ void CheckIO::seekOnAppendedFileError(const Token *tok)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckIO::invalidScanf()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -563,7 +563,7 @@ void CheckIO::checkFormatString(const Token * const tok,
|
|||
const bool scan,
|
||||
const bool scanf_s)
|
||||
{
|
||||
const bool printWarning = _settings->isEnabled("warning");
|
||||
const bool printWarning = _settings->isEnabled(Settings::WARNING);
|
||||
const std::string &formatString = formatStringTok->str();
|
||||
|
||||
// Count format string parameters..
|
||||
|
@ -1763,7 +1763,7 @@ void CheckIO::wrongPrintfScanfArgumentsError(const Token* tok,
|
|||
unsigned int numFunction)
|
||||
{
|
||||
Severity::SeverityType severity = numFormat > numFunction ? Severity::error : Severity::warning;
|
||||
if (severity != Severity::error && !_settings->isEnabled("warning"))
|
||||
if (severity != Severity::error && !_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
std::ostringstream errmsg;
|
||||
|
@ -1782,7 +1782,7 @@ void CheckIO::wrongPrintfScanfArgumentsError(const Token* tok,
|
|||
void CheckIO::wrongPrintfScanfPosixParameterPositionError(const Token* tok, const std::string& functionName,
|
||||
unsigned int index, unsigned int numFunction)
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << functionName << ": ";
|
||||
|
@ -1797,7 +1797,7 @@ void CheckIO::wrongPrintfScanfPosixParameterPositionError(const Token* tok, cons
|
|||
void CheckIO::invalidScanfArgTypeError_s(const Token* tok, unsigned int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%" << specifier << " in format string (no. " << numFormat << ") requires a \'";
|
||||
|
@ -1813,7 +1813,7 @@ void CheckIO::invalidScanfArgTypeError_s(const Token* tok, unsigned int numForma
|
|||
void CheckIO::invalidScanfArgTypeError_int(const Token* tok, unsigned int numFormat, const std::string& specifier, const ArgumentInfo* argInfo, bool isUnsigned)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%" << specifier << " in format string (no. " << numFormat << ") requires \'";
|
||||
|
@ -1858,7 +1858,7 @@ void CheckIO::invalidScanfArgTypeError_int(const Token* tok, unsigned int numFor
|
|||
void CheckIO::invalidScanfArgTypeError_float(const Token* tok, unsigned int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%" << specifier << " in format string (no. " << numFormat << ") requires \'";
|
||||
|
@ -1877,7 +1877,7 @@ void CheckIO::invalidScanfArgTypeError_float(const Token* tok, unsigned int numF
|
|||
void CheckIO::invalidPrintfArgTypeError_s(const Token* tok, unsigned int numFormat, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%s in format string (no. " << numFormat << ") requires \'char *\' but the argument type is ";
|
||||
|
@ -1888,7 +1888,7 @@ void CheckIO::invalidPrintfArgTypeError_s(const Token* tok, unsigned int numForm
|
|||
void CheckIO::invalidPrintfArgTypeError_n(const Token* tok, unsigned int numFormat, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%n in format string (no. " << numFormat << ") requires \'int *\' but the argument type is ";
|
||||
|
@ -1899,7 +1899,7 @@ void CheckIO::invalidPrintfArgTypeError_n(const Token* tok, unsigned int numForm
|
|||
void CheckIO::invalidPrintfArgTypeError_p(const Token* tok, unsigned int numFormat, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%p in format string (no. " << numFormat << ") requires an address but the argument type is ";
|
||||
|
@ -1948,7 +1948,7 @@ static void printfFormatType(std::ostream& os, const std::string& specifier, boo
|
|||
void CheckIO::invalidPrintfArgTypeError_int(const Token* tok, unsigned int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%" << specifier << " in format string (no. " << numFormat << ") requires ";
|
||||
|
@ -1961,7 +1961,7 @@ void CheckIO::invalidPrintfArgTypeError_int(const Token* tok, unsigned int numFo
|
|||
void CheckIO::invalidPrintfArgTypeError_uint(const Token* tok, unsigned int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%" << specifier << " in format string (no. " << numFormat << ") requires ";
|
||||
|
@ -1975,7 +1975,7 @@ void CheckIO::invalidPrintfArgTypeError_uint(const Token* tok, unsigned int numF
|
|||
void CheckIO::invalidPrintfArgTypeError_sint(const Token* tok, unsigned int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%" << specifier << " in format string (no. " << numFormat << ") requires ";
|
||||
|
@ -1988,7 +1988,7 @@ void CheckIO::invalidPrintfArgTypeError_sint(const Token* tok, unsigned int numF
|
|||
void CheckIO::invalidPrintfArgTypeError_float(const Token* tok, unsigned int numFormat, const std::string& specifier, const ArgumentInfo* argInfo)
|
||||
{
|
||||
const Severity::SeverityType severity = getSeverity(argInfo);
|
||||
if (!_settings->isEnabled(Severity::toString(severity)))
|
||||
if (!_settings->isEnabled(severity))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "%" << specifier << " in format string (no. " << numFormat << ") requires \'";
|
||||
|
@ -2056,7 +2056,7 @@ void CheckIO::argumentType(std::ostream& os, const ArgumentInfo * argInfo)
|
|||
|
||||
void CheckIO::invalidLengthModifierError(const Token* tok, unsigned int numFormat, const std::string& modifier)
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
std::ostringstream errmsg;
|
||||
errmsg << "'" << modifier << "' in format string (no. " << numFormat << ") is a length modifier and cannot be used without a conversion specifier.";
|
||||
|
@ -2075,7 +2075,7 @@ void CheckIO::invalidScanfFormatWidthError(const Token* tok, unsigned int numFor
|
|||
|
||||
std::ostringstream errmsg;
|
||||
if (arrlen > width) {
|
||||
if (!_settings->inconclusive || !_settings->isEnabled("warning"))
|
||||
if (!_settings->inconclusive || !_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
errmsg << "Width " << width << " given in format string (no. " << numFormat << ") is smaller than destination buffer"
|
||||
<< " '" << varname << "[" << arrlen << "]'.";
|
||||
|
|
|
@ -113,7 +113,7 @@ void CheckLeakAutoVar::deallocReturnError(const Token *tok, const std::string &v
|
|||
|
||||
void CheckLeakAutoVar::configurationInfo(const Token* tok, const std::string &functionName)
|
||||
{
|
||||
if (_settings->checkLibrary && _settings->isEnabled("information")) {
|
||||
if (_settings->checkLibrary && _settings->isEnabled(Settings::INFORMATION)) {
|
||||
reportError(tok,
|
||||
Severity::information,
|
||||
"checkLibraryUseIgnore",
|
||||
|
|
|
@ -2376,7 +2376,7 @@ void CheckMemoryLeakInClass::variable(const Scope *scope, const Token *tokVarnam
|
|||
|
||||
void CheckMemoryLeakInClass::unsafeClassError(const Token *tok, const std::string &classname, const std::string &varname)
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
reportError(tok, Severity::style, "unsafeClassCanLeak",
|
||||
|
@ -2390,7 +2390,7 @@ void CheckMemoryLeakInClass::checkPublicFunctions(const Scope *scope, const Toke
|
|||
// Check that public functions deallocate the pointers that they allocate.
|
||||
// There is no checking how these functions are used and therefore it
|
||||
// isn't established if there is real leaks or not.
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const unsigned int varid = classtok->varId();
|
||||
|
@ -2712,7 +2712,7 @@ void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope)
|
|||
void CheckMemoryLeakNoVar::checkForUnsafeArgAlloc(const Scope *scope)
|
||||
{
|
||||
// This test only applies to C++ source
|
||||
if (!_tokenizer->isCPP() || !_settings->inconclusive || !_settings->isEnabled("warning"))
|
||||
if (!_tokenizer->isCPP() || !_settings->inconclusive || !_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
for (const Token *tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
|
||||
|
|
|
@ -243,7 +243,7 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown)
|
|||
void CheckNullPointer::nullPointerLinkedList()
|
||||
{
|
||||
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -308,7 +308,7 @@ void CheckNullPointer::nullPointerLinkedList()
|
|||
|
||||
void CheckNullPointer::nullPointerByDeRefAndChec()
|
||||
{
|
||||
const bool printWarnings = _settings->isEnabled("warning");
|
||||
const bool printWarnings = _settings->isEnabled(Settings::WARNING);
|
||||
const bool printInconclusive = (_settings->inconclusive);
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
@ -472,10 +472,10 @@ void CheckNullPointer::nullPointerError(const Token *tok)
|
|||
void CheckNullPointer::nullPointerError(const Token *tok, const std::string &varname, bool inconclusive, bool defaultArg, bool possible)
|
||||
{
|
||||
if (defaultArg) {
|
||||
if (_settings->isEnabled("warning"))
|
||||
if (_settings->isEnabled(Settings::WARNING))
|
||||
reportError(tok, Severity::warning, "nullPointerDefaultArg", "Possible null pointer dereference if the default parameter value is used: " + varname, CWE476, inconclusive);
|
||||
} else if (possible) {
|
||||
if (_settings->isEnabled("warning"))
|
||||
if (_settings->isEnabled(Settings::WARNING))
|
||||
reportError(tok, Severity::warning, "nullPointer", "Possible null pointer dereference: " + varname, CWE476, inconclusive);
|
||||
} else
|
||||
reportError(tok, Severity::error, "nullPointer", "Null pointer dereference: " + varname, CWE476, inconclusive);
|
||||
|
@ -483,7 +483,7 @@ void CheckNullPointer::nullPointerError(const Token *tok, const std::string &var
|
|||
|
||||
void CheckNullPointer::nullPointerError(const Token *tok, const std::string &varname, const Token* nullCheck, bool inconclusive)
|
||||
{
|
||||
if (! _settings->isEnabled("warning"))
|
||||
if (! _settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
std::list<const Token*> callstack;
|
||||
callstack.push_back(tok);
|
||||
|
@ -510,7 +510,7 @@ void CheckNullPointer::arithmetic()
|
|||
continue;
|
||||
if (!_settings->inconclusive && value->inconclusive)
|
||||
continue;
|
||||
if (value->condition && !_settings->isEnabled("warning"))
|
||||
if (value->condition && !_settings->isEnabled(Settings::WARNING))
|
||||
continue;
|
||||
arithmeticError(tok,value);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ static const struct CWE CWE783(783U); // Operator Precedence Logic Error
|
|||
//----------------------------------------------------------------------------------
|
||||
void CheckOther::checkCastIntToCharAndBack()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -139,7 +139,7 @@ void CheckOther::checkCastIntToCharAndBackError(const Token *tok, const std::str
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::clarifyCalculation()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -193,7 +193,7 @@ void CheckOther::clarifyCalculationError(const Token *tok, const std::string &op
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::clarifyStatement()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -229,7 +229,7 @@ void CheckOther::clarifyStatementError(const Token *tok)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkSuspiciousSemicolon()
|
||||
{
|
||||
if (!_settings->inconclusive || !_settings->isEnabled("warning"))
|
||||
if (!_settings->inconclusive || !_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -261,7 +261,7 @@ void CheckOther::SuspiciousSemicolonError(const Token* tok)
|
|||
void CheckOther::warningOldStylePointerCast()
|
||||
{
|
||||
// Only valid on C++ code
|
||||
if (!_settings->isEnabled("style") || !_tokenizer->isCPP())
|
||||
if (!_settings->isEnabled(Settings::STYLE) || !_tokenizer->isCPP())
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -312,7 +312,7 @@ void CheckOther::cstyleCastError(const Token *tok)
|
|||
|
||||
void CheckOther::invalidPointerCast()
|
||||
{
|
||||
if (!_settings->isEnabled("portability"))
|
||||
if (!_settings->isEnabled(Settings::PORTABILITY))
|
||||
return;
|
||||
|
||||
const bool printInconclusive = _settings->inconclusive;
|
||||
|
@ -470,9 +470,9 @@ static bool checkExceptionHandling(const Token* tok)
|
|||
|
||||
void CheckOther::checkRedundantAssignment()
|
||||
{
|
||||
const bool printPerformance = _settings->isEnabled("performance");
|
||||
const bool printStyle = _settings->isEnabled("style");
|
||||
const bool printWarning = _settings->isEnabled("warning");
|
||||
const bool printPerformance = _settings->isEnabled(Settings::PERFORMANCE);
|
||||
const bool printStyle = _settings->isEnabled(Settings::STYLE);
|
||||
const bool printWarning = _settings->isEnabled(Settings::WARNING);
|
||||
if (!printWarning && !printPerformance && !printStyle)
|
||||
return;
|
||||
|
||||
|
@ -752,7 +752,7 @@ static inline bool isFunctionOrBreakPattern(const Token *tok)
|
|||
|
||||
void CheckOther::checkRedundantAssignmentInSwitch()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -877,7 +877,7 @@ void CheckOther::redundantBitwiseOperationInSwitchError(const Token *tok, const
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkSuspiciousCaseInSwitch()
|
||||
{
|
||||
if (!_settings->inconclusive || !_settings->isEnabled("warning"))
|
||||
if (!_settings->inconclusive || !_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -920,7 +920,7 @@ void CheckOther::suspiciousCaseInSwitchError(const Token* tok, const std::string
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkSuspiciousEqualityComparison()
|
||||
{
|
||||
if (!_settings->isEnabled("warning") || !_settings->inconclusive)
|
||||
if (!_settings->isEnabled(Settings::WARNING) || !_settings->inconclusive)
|
||||
return;
|
||||
|
||||
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -975,7 +975,7 @@ void CheckOther::suspiciousEqualityComparisonError(const Token* tok)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkUnreachableCode()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
const bool printInconclusive = _settings->inconclusive;
|
||||
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -1089,7 +1089,7 @@ void CheckOther::unreachableCodeError(const Token *tok, bool inconclusive)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkMemsetZeroBytes()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -1117,8 +1117,8 @@ void CheckOther::memsetZeroBytesError(const Token *tok)
|
|||
|
||||
void CheckOther::checkMemsetInvalid2ndParam()
|
||||
{
|
||||
const bool printPortability = _settings->isEnabled("portability");
|
||||
const bool printWarning = _settings->isEnabled("warning");
|
||||
const bool printPortability = _settings->isEnabled(Settings::PORTABILITY);
|
||||
const bool printWarning = _settings->isEnabled(Settings::WARNING);
|
||||
if (!printWarning && !printPortability)
|
||||
return;
|
||||
|
||||
|
@ -1177,7 +1177,7 @@ void CheckOther::memsetValueOutOfRangeError(const Token *tok, const std::string
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkVariableScope()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -1365,7 +1365,7 @@ void CheckOther::checkCommaSeparatedReturn()
|
|||
if (!_settings->experimental)
|
||||
return;
|
||||
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
@ -1439,7 +1439,7 @@ static std::size_t estimateSize(const Type* type, const Settings* settings, cons
|
|||
|
||||
void CheckOther::checkPassByReference()
|
||||
{
|
||||
if (!_settings->isEnabled("performance") || _tokenizer->isC())
|
||||
if (!_settings->isEnabled(Settings::PERFORMANCE) || _tokenizer->isC())
|
||||
return;
|
||||
|
||||
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -1553,8 +1553,8 @@ void CheckOther::passedByValueError(const Token *tok, const std::string &parname
|
|||
|
||||
void CheckOther::checkCharVariable()
|
||||
{
|
||||
const bool warning = _settings->isEnabled("warning");
|
||||
const bool portability = _settings->isEnabled("portability");
|
||||
const bool warning = _settings->isEnabled(Settings::WARNING);
|
||||
const bool portability = _settings->isEnabled(Settings::PORTABILITY);
|
||||
if (!warning && !portability)
|
||||
return;
|
||||
|
||||
|
@ -1642,7 +1642,7 @@ void CheckOther::charBitOpError(const Token *tok)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkIncompleteStatement()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
@ -1715,7 +1715,7 @@ void CheckOther::constStatementError(const Token *tok, const std::string &type)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkZeroDivision()
|
||||
{
|
||||
const bool printWarnings = _settings->isEnabled("warning");
|
||||
const bool printWarnings = _settings->isEnabled(Settings::WARNING);
|
||||
const bool printInconclusive = _settings->inconclusive;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
@ -1796,7 +1796,7 @@ void CheckOther::checkMisusedScopedObject()
|
|||
if (_tokenizer->isC())
|
||||
return;
|
||||
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -1837,7 +1837,7 @@ void CheckOther::checkDuplicateBranch()
|
|||
// and their conditional code is a duplicate of the condition that
|
||||
// is always true just in case it would be false. See for instance
|
||||
// abiword.
|
||||
if (!_settings->isEnabled("style") || !_settings->inconclusive)
|
||||
if (!_settings->isEnabled(Settings::STYLE) || !_settings->inconclusive)
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -2005,8 +2005,8 @@ namespace {
|
|||
|
||||
void CheckOther::checkDuplicateExpression()
|
||||
{
|
||||
const bool styleEnabled=_settings->isEnabled("style");
|
||||
const bool warningEnabled=_settings->isEnabled("warning");
|
||||
const bool styleEnabled=_settings->isEnabled(Settings::STYLE);
|
||||
const bool warningEnabled=_settings->isEnabled(Settings::WARNING);
|
||||
if (!styleEnabled && !warningEnabled)
|
||||
return;
|
||||
|
||||
|
@ -2105,7 +2105,7 @@ void CheckOther::selfAssignmentError(const Token *tok, const std::string &varnam
|
|||
//-----------------------------------------------------------------------------
|
||||
void CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -2149,7 +2149,7 @@ void CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalseError(const Token* to
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkSignOfUnsignedVariable()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const bool inconclusive = _tokenizer->codeWithTemplates();
|
||||
|
@ -2261,7 +2261,7 @@ static bool constructorTakesReference(const Scope * const classScope)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckOther::checkRedundantCopy()
|
||||
{
|
||||
if (!_settings->isEnabled("performance") || _tokenizer->isC() || !_settings->inconclusive)
|
||||
if (!_settings->isEnabled(Settings::PERFORMANCE) || _tokenizer->isC() || !_settings->inconclusive)
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -2317,7 +2317,7 @@ static bool isNegative(const Token *tok, const Settings *settings)
|
|||
|
||||
void CheckOther::checkNegativeBitwiseShift()
|
||||
{
|
||||
const bool portability = _settings->isEnabled("portability");
|
||||
const bool portability = _settings->isEnabled(Settings::PORTABILITY);
|
||||
|
||||
for (const Token* tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (!tok->astOperand1() || !tok->astOperand2())
|
||||
|
@ -2371,8 +2371,8 @@ void CheckOther::checkIncompleteArrayFill()
|
|||
{
|
||||
if (!_settings->inconclusive)
|
||||
return;
|
||||
const bool printWarning = _settings->isEnabled("warning");
|
||||
const bool printPortability = _settings->isEnabled("portability");
|
||||
const bool printWarning = _settings->isEnabled(Settings::WARNING);
|
||||
const bool printPortability = _settings->isEnabled(Settings::PORTABILITY);
|
||||
if (!printPortability && !printWarning)
|
||||
return;
|
||||
|
||||
|
@ -2420,7 +2420,7 @@ void CheckOther::incompleteArrayFillError(const Token* tok, const std::string& b
|
|||
|
||||
void CheckOther::checkVarFuncNullUB()
|
||||
{
|
||||
if (!_settings->isEnabled("portability"))
|
||||
if (!_settings->isEnabled(Settings::PORTABILITY))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -2505,7 +2505,7 @@ void CheckOther::varFuncNullUBError(const Token *tok)
|
|||
|
||||
void CheckOther::checkRedundantPointerOp()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -2586,7 +2586,7 @@ void CheckOther::raceAfterInterlockedDecrementError(const Token* tok)
|
|||
|
||||
void CheckOther::checkUnusedLabel()
|
||||
{
|
||||
if (!_settings->isEnabled("style") && !_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::STYLE) && !_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -2609,11 +2609,11 @@ void CheckOther::checkUnusedLabel()
|
|||
void CheckOther::unusedLabelError(const Token* tok, bool inSwitch)
|
||||
{
|
||||
if (inSwitch) {
|
||||
if (!tok || _settings->isEnabled("warning"))
|
||||
if (!tok || _settings->isEnabled(Settings::WARNING))
|
||||
reportError(tok, Severity::warning, "unusedLabelSwitch",
|
||||
"Label '" + (tok ? tok->str() : emptyString) + "' is not used. Should this be a 'case' of the enclosing switch()?", CWE398, false);
|
||||
} else {
|
||||
if (!tok || _settings->isEnabled("style"))
|
||||
if (!tok || _settings->isEnabled(Settings::STYLE))
|
||||
reportError(tok, Severity::style, "unusedLabel",
|
||||
"Label '" + (tok ? tok->str() : emptyString) + "' is not used.", CWE398, false);
|
||||
}
|
||||
|
@ -2667,7 +2667,7 @@ void CheckOther::checkEvaluationOrder()
|
|||
tok->str() == "=" &&
|
||||
parent->str() == "=" &&
|
||||
isSameExpression(_tokenizer->isCPP(), false, tok->astOperand1(), parent->astOperand1(), _settings->library, true)) {
|
||||
if (_settings->isEnabled("warning") &&
|
||||
if (_settings->isEnabled(Settings::WARNING) &&
|
||||
isSameExpression(_tokenizer->isCPP(), true, tok->astOperand1(), parent->astOperand1(), _settings->library, true))
|
||||
selfAssignmentError(parent, tok->astOperand1()->expressionString());
|
||||
break;
|
||||
|
@ -2710,7 +2710,7 @@ void CheckOther::unknownEvaluationOrder(const Token* tok)
|
|||
|
||||
void CheckOther::checkAccessOfMovedVariable()
|
||||
{
|
||||
if (!_tokenizer->isCPP() || _settings->standards.cpp < Standards::CPP11 || !_settings->isEnabled("warning"))
|
||||
if (!_tokenizer->isCPP() || _settings->standards.cpp < Standards::CPP11 || !_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
const bool reportInconclusive = _settings->inconclusive;
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -2789,9 +2789,9 @@ void CheckOther::accessMovedError(const Token *tok, const std::string &varname,
|
|||
|
||||
void CheckOther::checkFuncArgNamesDifferent()
|
||||
{
|
||||
const bool style = _settings->isEnabled("style");
|
||||
const bool style = _settings->isEnabled(Settings::STYLE);
|
||||
const bool inconclusive = _settings->inconclusive;
|
||||
const bool warning = _settings->isEnabled("warning");
|
||||
const bool warning = _settings->isEnabled(Settings::WARNING);
|
||||
|
||||
if (!(warning || (style && inconclusive)))
|
||||
return;
|
||||
|
|
|
@ -39,7 +39,7 @@ static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
|||
|
||||
void CheckPostfixOperator::postfixOperator()
|
||||
{
|
||||
if (!_settings->isEnabled("performance"))
|
||||
if (!_settings->isEnabled(Settings::PERFORMANCE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
|
|
@ -39,7 +39,7 @@ static const struct CWE CWE682(682U); // Incorrect Calculation
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckSizeof::checkSizeofForNumericParameter()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -69,7 +69,7 @@ void CheckSizeof::sizeofForNumericParameterError(const Token *tok)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckSizeof::checkSizeofForArrayParameter()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
|
@ -109,7 +109,7 @@ void CheckSizeof::sizeofForArrayParameterError(const Token *tok)
|
|||
|
||||
void CheckSizeof::checkSizeofForPointerSize()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -258,7 +258,7 @@ void CheckSizeof::divideBySizeofError(const Token *tok, const std::string &memfu
|
|||
//-----------------------------------------------------------------------------
|
||||
void CheckSizeof::sizeofsizeof()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
@ -282,7 +282,7 @@ void CheckSizeof::sizeofsizeofError(const Token *tok)
|
|||
|
||||
void CheckSizeof::sizeofCalculation()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const bool printInconclusive = _settings->inconclusive;
|
||||
|
@ -318,7 +318,7 @@ void CheckSizeof::sizeofCalculationError(const Token *tok, bool inconclusive)
|
|||
//-----------------------------------------------------------------------------
|
||||
void CheckSizeof::suspiciousSizeofCalculation()
|
||||
{
|
||||
if (!_settings->isEnabled("warning") || !_settings->inconclusive)
|
||||
if (!_settings->isEnabled(Settings::WARNING) || !_settings->inconclusive)
|
||||
return;
|
||||
|
||||
// TODO: Use AST here. This should be possible as soon as sizeof without brackets is correctly parsed
|
||||
|
@ -351,7 +351,7 @@ void CheckSizeof::divideSizeofError(const Token *tok)
|
|||
|
||||
void CheckSizeof::sizeofVoid()
|
||||
{
|
||||
if (!_settings->isEnabled("portability"))
|
||||
if (!_settings->isEnabled(Settings::PORTABILITY))
|
||||
return;
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
|
|
@ -698,8 +698,8 @@ static bool if_findCompare(const Token * const tokBack)
|
|||
|
||||
void CheckStl::if_find()
|
||||
{
|
||||
const bool printWarning = _settings->isEnabled("warning");
|
||||
const bool printPerformance = _settings->isEnabled("performance");
|
||||
const bool printWarning = _settings->isEnabled(Settings::WARNING);
|
||||
const bool printPerformance = _settings->isEnabled(Settings::PERFORMANCE);
|
||||
if (!printWarning && !printPerformance)
|
||||
return;
|
||||
|
||||
|
@ -792,7 +792,7 @@ static bool isCpp03ContainerSizeSlow(const Token *tok)
|
|||
|
||||
void CheckStl::size()
|
||||
{
|
||||
if (!_settings->isEnabled("performance"))
|
||||
if (!_settings->isEnabled(Settings::PERFORMANCE))
|
||||
return;
|
||||
|
||||
if (_settings->standards.cpp == Standards::CPP11)
|
||||
|
@ -852,7 +852,7 @@ void CheckStl::sizeError(const Token *tok)
|
|||
|
||||
void CheckStl::redundantCondition()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -891,7 +891,7 @@ void CheckStl::redundantIfRemoveError(const Token *tok)
|
|||
|
||||
void CheckStl::missingComparison()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -984,7 +984,7 @@ namespace {
|
|||
void CheckStl::string_c_str()
|
||||
{
|
||||
const bool printInconclusive = _settings->inconclusive;
|
||||
const bool printPerformance = _settings->isEnabled("performance");
|
||||
const bool printPerformance = _settings->isEnabled(Settings::PERFORMANCE);
|
||||
|
||||
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
|
@ -1198,7 +1198,7 @@ void CheckStl::checkAutoPointer()
|
|||
std::map<unsigned int, const std::string> mallocVarId; // variables allocated by the malloc-like function
|
||||
const char STL_CONTAINER_LIST[] = "array|bitset|deque|list|forward_list|map|multimap|multiset|priority_queue|queue|set|stack|vector|hash_map|hash_multimap|hash_set|unordered_map|unordered_multimap|unordered_set|unordered_multiset|basic_string";
|
||||
const int malloc = _settings->library.allocId("malloc"); // allocation function, which are not compatible with auto_ptr
|
||||
const bool printStyle = _settings->isEnabled("style");
|
||||
const bool printStyle = _settings->isEnabled(Settings::STYLE);
|
||||
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (Token::simpleMatch(tok, "auto_ptr <")) {
|
||||
|
@ -1320,8 +1320,8 @@ namespace {
|
|||
|
||||
void CheckStl::uselessCalls()
|
||||
{
|
||||
const bool printPerformance = _settings->isEnabled("performance");
|
||||
const bool printWarning = _settings->isEnabled("warning");
|
||||
const bool printPerformance = _settings->isEnabled(Settings::PERFORMANCE);
|
||||
const bool printWarning = _settings->isEnabled(Settings::WARNING);
|
||||
if (!printPerformance && !printWarning)
|
||||
return;
|
||||
|
||||
|
@ -1407,7 +1407,7 @@ void CheckStl::uselessCallsRemoveError(const Token *tok, const std::string& func
|
|||
// E.g. if (*i && i != str.end()) { }
|
||||
void CheckStl::checkDereferenceInvalidIterator()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
// Iterate over "if", "while", and "for" conditions where there may
|
||||
|
@ -1519,7 +1519,7 @@ void CheckStl::readingEmptyStlContainer_parseUsage(const Token* tok, const Libra
|
|||
|
||||
void CheckStl::readingEmptyStlContainer()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
if (!_settings->inconclusive)
|
||||
|
|
|
@ -84,7 +84,7 @@ void CheckString::stringLiteralWriteError(const Token *tok, const Token *strValu
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckString::checkAlwaysTrueOrFalseStringCompare()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
for (const Token* tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
|
@ -151,7 +151,7 @@ void CheckString::alwaysTrueStringVariableCompareError(const Token *tok, const s
|
|||
//-----------------------------------------------------------------------------
|
||||
void CheckString::checkSuspiciousStringCompare()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -261,7 +261,7 @@ void CheckString::strPlusCharError(const Token *tok)
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckString::checkIncorrectStringCompare()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
|
|
@ -44,7 +44,7 @@ static const struct CWE CWE190(190U); // Integer Overflow or Wraparound
|
|||
|
||||
void CheckType::checkTooBigBitwiseShift()
|
||||
{
|
||||
const bool printWarnings = _settings->isEnabled("warning");
|
||||
const bool printWarnings = _settings->isEnabled(Settings::WARNING);
|
||||
const bool printInconclusive = _settings->inconclusive;
|
||||
|
||||
// unknown sizeof(int) => can't run this checker
|
||||
|
@ -173,7 +173,7 @@ void CheckType::integerOverflowError(const Token *tok, const ValueFlow::Value &v
|
|||
|
||||
void CheckType::checkSignConversion()
|
||||
{
|
||||
if (!_settings->isEnabled("warning"))
|
||||
if (!_settings->isEnabled(Settings::WARNING))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
@ -225,7 +225,7 @@ void CheckType::signConversionError(const Token *tok, const bool constvalue)
|
|||
|
||||
void CheckType::checkLongCast()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
// Assignments..
|
||||
|
|
|
@ -273,7 +273,7 @@ void CheckUnusedFunctions::unusedFunctionError(ErrorLogger * const errorLogger,
|
|||
|
||||
Check::FileInfo *CheckUnusedFunctions::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
|
||||
{
|
||||
if (!settings->isEnabled("unusedFunction"))
|
||||
if (!settings->isEnabled(Settings::UNUSED_FUNCTION))
|
||||
return nullptr;
|
||||
if (settings->jobs == 1 && settings->buildDir.empty())
|
||||
instance.parseTokens(*tokenizer, tokenizer->list.getFiles().front().c_str(), settings);
|
||||
|
|
|
@ -1176,7 +1176,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
|
|||
|
||||
void CheckUnusedVar::checkFunctionVariableUsage()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
// Parse all executing scopes..
|
||||
|
@ -1269,7 +1269,7 @@ void CheckUnusedVar::unassignedVariableError(const Token *tok, const std::string
|
|||
//---------------------------------------------------------------------------
|
||||
void CheckUnusedVar::checkStructMemberUsage()
|
||||
{
|
||||
if (!_settings->isEnabled("style"))
|
||||
if (!_settings->isEnabled(Settings::STYLE))
|
||||
return;
|
||||
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
|
|
@ -40,7 +40,7 @@ void CheckVaarg::va_start_argument()
|
|||
{
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
const bool printWarnings = _settings->isEnabled("warning");
|
||||
const bool printWarnings = _settings->isEnabled(Settings::WARNING);
|
||||
|
||||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope* scope = symbolDatabase->functionScopes[i];
|
||||
|
|
|
@ -144,11 +144,11 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin
|
|||
// Get toolinfo
|
||||
std::string toolinfo;
|
||||
toolinfo += CPPCHECK_VERSION_STRING;
|
||||
toolinfo += _settings.isEnabled("warning") ? 'w' : ' ';
|
||||
toolinfo += _settings.isEnabled("style") ? 's' : ' ';
|
||||
toolinfo += _settings.isEnabled("performance") ? 'p' : ' ';
|
||||
toolinfo += _settings.isEnabled("portability") ? 'p' : ' ';
|
||||
toolinfo += _settings.isEnabled("information") ? 'i' : ' ';
|
||||
toolinfo += _settings.isEnabled(Settings::WARNING) ? 'w' : ' ';
|
||||
toolinfo += _settings.isEnabled(Settings::STYLE) ? 's' : ' ';
|
||||
toolinfo += _settings.isEnabled(Settings::PERFORMANCE) ? 'p' : ' ';
|
||||
toolinfo += _settings.isEnabled(Settings::PORTABILITY) ? 'p' : ' ';
|
||||
toolinfo += _settings.isEnabled(Settings::INFORMATION) ? 'i' : ' ';
|
||||
toolinfo += _settings.userDefines;
|
||||
|
||||
// Calculate checksum so it can be compared with old checksum / future checksums
|
||||
|
@ -202,7 +202,7 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin
|
|||
}
|
||||
|
||||
if (!_settings.force && configurations.size() > _settings.maxConfigs) {
|
||||
if (_settings.isEnabled("information")) {
|
||||
if (_settings.isEnabled(Settings::INFORMATION)) {
|
||||
tooManyConfigsError(Path::toNativeSeparators(filename),configurations.size());
|
||||
} else {
|
||||
tooManyConfigs = true;
|
||||
|
@ -320,7 +320,7 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin
|
|||
if (_settings.force || _settings.maxConfigs > 1) {
|
||||
const unsigned long long checksum = _tokenizer.list.calculateChecksum();
|
||||
if (checksums.find(checksum) != checksums.end()) {
|
||||
if (_settings.isEnabled("information") && (_settings.debug || _settings.verbose))
|
||||
if (_settings.isEnabled(Settings::INFORMATION) && (_settings.debug || _settings.verbose))
|
||||
purgedConfigurationMessage(filename, cfg);
|
||||
continue;
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin
|
|||
|
||||
// In jointSuppressionReport mode, unmatched suppressions are
|
||||
// collected after all files are processed
|
||||
if (!_settings.jointSuppressionReport && (_settings.isEnabled("information") || _settings.checkConfiguration)) {
|
||||
if (!_settings.jointSuppressionReport && (_settings.isEnabled(Settings::INFORMATION) || _settings.checkConfiguration)) {
|
||||
reportUnmatchedSuppressions(_settings.nomsg.getUnmatchedLocalSuppressions(filename, isUnusedFunctionCheckEnabled()));
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ void CppCheck::internalError(const std::string &filename, const std::string &msg
|
|||
const std::string fixedpath = Path::toNativeSeparators(filename);
|
||||
const std::string fullmsg("Bailing out from checking " + fixedpath + " since there was an internal error: " + msg);
|
||||
|
||||
if (_settings.isEnabled("information")) {
|
||||
if (_settings.isEnabled(Settings::INFORMATION)) {
|
||||
const ErrorLogger::ErrorMessage::FileLocation loc1(filename, 0);
|
||||
std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
|
||||
callstack.push_back(loc1);
|
||||
|
@ -584,12 +584,12 @@ Settings &CppCheck::settings()
|
|||
|
||||
void CppCheck::tooManyConfigsError(const std::string &file, const std::size_t numberOfConfigurations)
|
||||
{
|
||||
if (!_settings.isEnabled("information") && !tooManyConfigs)
|
||||
if (!_settings.isEnabled(Settings::INFORMATION) && !tooManyConfigs)
|
||||
return;
|
||||
|
||||
tooManyConfigs = false;
|
||||
|
||||
if (_settings.isEnabled("information") && file.empty())
|
||||
if (_settings.isEnabled(Settings::INFORMATION) && file.empty())
|
||||
return;
|
||||
|
||||
std::list<ErrorLogger::ErrorMessage::FileLocation> loclist;
|
||||
|
@ -627,7 +627,7 @@ void CppCheck::purgedConfigurationMessage(const std::string &file, const std::st
|
|||
{
|
||||
tooManyConfigs = false;
|
||||
|
||||
if (_settings.isEnabled("information") && file.empty())
|
||||
if (_settings.isEnabled(Settings::INFORMATION) && file.empty())
|
||||
return;
|
||||
|
||||
std::list<ErrorLogger::ErrorMessage::FileLocation> loclist;
|
||||
|
@ -752,7 +752,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::map<s
|
|||
(void)files;
|
||||
if (buildDir.empty())
|
||||
return;
|
||||
if (_settings.isEnabled("unusedFunction"))
|
||||
if (_settings.isEnabled(Settings::UNUSED_FUNCTION))
|
||||
CheckUnusedFunctions::analyseWholeProgram(this, buildDir);
|
||||
std::list<Check::FileInfo*> fileInfoList;
|
||||
|
||||
|
@ -802,5 +802,5 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::map<s
|
|||
|
||||
bool CppCheck::isUnusedFunctionCheckEnabled() const
|
||||
{
|
||||
return (_settings.jobs == 1 && _settings.isEnabled("unusedFunction"));
|
||||
return (_settings.jobs == 1 && _settings.isEnabled(Settings::UNUSED_FUNCTION));
|
||||
}
|
||||
|
|
|
@ -794,7 +794,7 @@ bool Preprocessor::validateCfg(const std::string &cfg, const std::list<simplecpp
|
|||
}
|
||||
}
|
||||
if (!directiveLocation) {
|
||||
if (_settings.isEnabled("information"))
|
||||
if (_settings.isEnabled(Settings::INFORMATION))
|
||||
validateCfgError(mu.useLocation.file(), mu.useLocation.line, cfg, macroName);
|
||||
ret = false;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
bool Settings::_terminated;
|
||||
|
||||
Settings::Settings()
|
||||
: debug(false),
|
||||
: _enabled(0),
|
||||
debug(false),
|
||||
debugnormal(false),
|
||||
debugwarnings(false),
|
||||
dump(false),
|
||||
|
@ -53,20 +54,6 @@ Settings::Settings()
|
|||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
const std::set<std::string> id = make_container< std::set<std::string> > ()
|
||||
<< "warning"
|
||||
<< "style"
|
||||
<< "performance"
|
||||
<< "portability"
|
||||
<< "information"
|
||||
<< "missingInclude"
|
||||
<< "unusedFunction"
|
||||
#ifdef CHECK_INTERNAL
|
||||
<< "internal"
|
||||
#endif
|
||||
;
|
||||
}
|
||||
std::string Settings::addEnabled(const std::string &str)
|
||||
{
|
||||
// Enable parameters may be comma separated...
|
||||
|
@ -88,18 +75,28 @@ std::string Settings::addEnabled(const std::string &str)
|
|||
}
|
||||
|
||||
if (str == "all") {
|
||||
for (std::set<std::string>::const_iterator it = id.cbegin(); it != id.cend(); ++it) {
|
||||
if (*it == "internal")
|
||||
continue;
|
||||
|
||||
_enabled.insert(*it);
|
||||
}
|
||||
} else if (id.find(str) != id.end()) {
|
||||
_enabled.insert(str);
|
||||
if (str == "information") {
|
||||
_enabled.insert("missingInclude");
|
||||
}
|
||||
} else {
|
||||
_enabled |= WARNING | STYLE | PERFORMANCE | PORTABILITY | INFORMATION | UNUSED_FUNCTION | MISSING_INCLUDE;
|
||||
} else if (str == "warning") {
|
||||
_enabled |= WARNING;
|
||||
} else if (str == "style") {
|
||||
_enabled |= STYLE;
|
||||
} else if (str == "performance") {
|
||||
_enabled |= PERFORMANCE;
|
||||
} else if (str == "portability") {
|
||||
_enabled |= PORTABILITY;
|
||||
} else if (str == "information") {
|
||||
_enabled |= INFORMATION | MISSING_INCLUDE;
|
||||
} else if (str == "unusedFunction") {
|
||||
_enabled |= UNUSED_FUNCTION;
|
||||
} else if (str == "missingInclude") {
|
||||
_enabled |= MISSING_INCLUDE;
|
||||
}
|
||||
#ifdef CHECK_INTERNAL
|
||||
else if (str == "internal") {
|
||||
_enabled |= INTERNAL;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
if (str.empty())
|
||||
return std::string("cppcheck: --enable parameter is empty");
|
||||
else
|
||||
|
@ -109,6 +106,29 @@ std::string Settings::addEnabled(const std::string &str)
|
|||
return std::string();
|
||||
}
|
||||
|
||||
bool Settings::isEnabled(Severity::SeverityType severity) const
|
||||
{
|
||||
switch (severity) {
|
||||
case Severity::none:
|
||||
return true;
|
||||
case Severity::error:
|
||||
return true;
|
||||
case Severity::warning:
|
||||
return isEnabled(WARNING);
|
||||
case Severity::style:
|
||||
return isEnabled(STYLE);
|
||||
case Severity::performance:
|
||||
return isEnabled(PERFORMANCE);
|
||||
case Severity::portability:
|
||||
return isEnabled(PORTABILITY);
|
||||
case Severity::information:
|
||||
return isEnabled(INFORMATION);
|
||||
case Severity::debug:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Settings::append(const std::string &filename)
|
||||
{
|
||||
|
|
|
@ -43,12 +43,24 @@
|
|||
* future when we might have even more detailed settings.
|
||||
*/
|
||||
class CPPCHECKLIB Settings : public cppcheck::Platform {
|
||||
public:
|
||||
enum EnabledGroup {
|
||||
WARNING = 0x1,
|
||||
STYLE = 0x2,
|
||||
PERFORMANCE = 0x4,
|
||||
PORTABILITY = 0x8,
|
||||
INFORMATION = 0x10,
|
||||
UNUSED_FUNCTION = 0x20,
|
||||
MISSING_INCLUDE = 0x40,
|
||||
INTERNAL = 0x80
|
||||
};
|
||||
|
||||
private:
|
||||
/** @brief Code to append in the checks */
|
||||
std::string _append;
|
||||
|
||||
/** @brief enable extra checks by id */
|
||||
std::set<std::string> _enabled;
|
||||
int _enabled;
|
||||
|
||||
/** @brief terminate checking */
|
||||
static bool _terminated;
|
||||
|
@ -162,14 +174,19 @@ public:
|
|||
/**
|
||||
* @brief Returns true if given id is in the list of
|
||||
* enabled extra checks (--enable)
|
||||
* @param str id for the extra check, e.g. "style"
|
||||
* @param check group to be enabled
|
||||
* @return true if the check is enabled.
|
||||
*/
|
||||
template<typename T>
|
||||
bool isEnabled(T&& str) const {
|
||||
return bool(_enabled.find(str) != _enabled.end());
|
||||
bool isEnabled(EnabledGroup group) const {
|
||||
return (_enabled & group) == group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns true if given severity is enabled
|
||||
* @return true if the check is enabled.
|
||||
*/
|
||||
bool isEnabled(Severity::SeverityType severity) const;
|
||||
|
||||
/**
|
||||
* @brief Enable extra checks by id. See isEnabled()
|
||||
* @param str single id or list of id values to be enabled
|
||||
|
@ -182,7 +199,7 @@ public:
|
|||
* @brief Disables all severities, except from error.
|
||||
*/
|
||||
void clearEnabled() {
|
||||
_enabled.clear();
|
||||
_enabled = 0;
|
||||
}
|
||||
|
||||
enum Language {
|
||||
|
|
|
@ -1413,7 +1413,7 @@ const ValueFlow::Value * Token::getValueLE(const MathLib::bigint val, const Sett
|
|||
if (settings && ret) {
|
||||
if (ret->inconclusive && !settings->inconclusive)
|
||||
return nullptr;
|
||||
if (ret->condition && !settings->isEnabled("warning"))
|
||||
if (ret->condition && !settings->isEnabled(Settings::WARNING))
|
||||
return nullptr;
|
||||
}
|
||||
return ret;
|
||||
|
@ -1436,7 +1436,7 @@ const ValueFlow::Value * Token::getValueGE(const MathLib::bigint val, const Sett
|
|||
if (settings && ret) {
|
||||
if (ret->inconclusive && !settings->inconclusive)
|
||||
return nullptr;
|
||||
if (ret->condition && !settings->isEnabled("warning"))
|
||||
if (ret->condition && !settings->isEnabled(Settings::WARNING))
|
||||
return nullptr;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -3516,7 +3516,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
}
|
||||
|
||||
// class x y {
|
||||
if (isCPP() && _settings->isEnabled("information")) {
|
||||
if (isCPP() && _settings->isEnabled(Settings::INFORMATION)) {
|
||||
for (const Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (Token::Match(tok, "class %type% %type% [:{]")) {
|
||||
unhandled_macro_class_x_y(tok);
|
||||
|
@ -7317,7 +7317,7 @@ bool Tokenizer::IsScopeNoReturn(const Token *endScopeToken, bool *unknown) const
|
|||
const bool ret = _settings->library.isScopeNoReturn(endScopeToken,&unknownFunc);
|
||||
if (unknown)
|
||||
*unknown = !unknownFunc.empty();
|
||||
if (!unknownFunc.empty() && _settings->checkLibrary && _settings->isEnabled("information")) {
|
||||
if (!unknownFunc.empty() && _settings->checkLibrary && _settings->isEnabled(Settings::INFORMATION)) {
|
||||
// Is function global?
|
||||
bool globalFunction = true;
|
||||
if (Token::simpleMatch(endScopeToken->tokAt(-2), ") ; }")) {
|
||||
|
|
|
@ -455,11 +455,11 @@ private:
|
|||
const char *argv[] = {"cppcheck", "--enable=all", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings.isEnabled("style"));
|
||||
ASSERT(settings.isEnabled("warning"));
|
||||
ASSERT(settings.isEnabled("unusedFunction"));
|
||||
ASSERT(settings.isEnabled("missingInclude"));
|
||||
ASSERT(!settings.isEnabled("internal"));
|
||||
ASSERT(settings.isEnabled(Settings::STYLE));
|
||||
ASSERT(settings.isEnabled(Settings::WARNING));
|
||||
ASSERT(settings.isEnabled(Settings::UNUSED_FUNCTION));
|
||||
ASSERT(settings.isEnabled(Settings::MISSING_INCLUDE));
|
||||
ASSERT(!settings.isEnabled(Settings::INTERNAL));
|
||||
}
|
||||
|
||||
void enabledStyle() {
|
||||
|
@ -467,12 +467,12 @@ private:
|
|||
const char *argv[] = {"cppcheck", "--enable=style", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings.isEnabled("style"));
|
||||
ASSERT(settings.isEnabled("warning"));
|
||||
ASSERT(settings.isEnabled("performance"));
|
||||
ASSERT(settings.isEnabled("portability"));
|
||||
ASSERT(!settings.isEnabled("unusedFunction"));
|
||||
ASSERT(!settings.isEnabled("missingInclude"));
|
||||
ASSERT(settings.isEnabled(Settings::STYLE));
|
||||
ASSERT(settings.isEnabled(Settings::WARNING));
|
||||
ASSERT(settings.isEnabled(Settings::PERFORMANCE));
|
||||
ASSERT(settings.isEnabled(Settings::PORTABILITY));
|
||||
ASSERT(!settings.isEnabled(Settings::UNUSED_FUNCTION));
|
||||
ASSERT(!settings.isEnabled(Settings::MISSING_INCLUDE));
|
||||
}
|
||||
|
||||
void enabledPerformance() {
|
||||
|
@ -480,12 +480,12 @@ private:
|
|||
const char *argv[] = {"cppcheck", "--enable=performance", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(!settings.isEnabled("style"));
|
||||
ASSERT(!settings.isEnabled("warning"));
|
||||
ASSERT(settings.isEnabled("performance"));
|
||||
ASSERT(!settings.isEnabled("portability"));
|
||||
ASSERT(!settings.isEnabled("unusedFunction"));
|
||||
ASSERT(!settings.isEnabled("missingInclude"));
|
||||
ASSERT(!settings.isEnabled(Settings::STYLE));
|
||||
ASSERT(!settings.isEnabled(Settings::WARNING));
|
||||
ASSERT(settings.isEnabled(Settings::PERFORMANCE));
|
||||
ASSERT(!settings.isEnabled(Settings::PORTABILITY));
|
||||
ASSERT(!settings.isEnabled(Settings::UNUSED_FUNCTION));
|
||||
ASSERT(!settings.isEnabled(Settings::MISSING_INCLUDE));
|
||||
}
|
||||
|
||||
void enabledPortability() {
|
||||
|
@ -493,12 +493,12 @@ private:
|
|||
const char *argv[] = {"cppcheck", "--enable=portability", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(!settings.isEnabled("style"));
|
||||
ASSERT(!settings.isEnabled("warning"));
|
||||
ASSERT(!settings.isEnabled("performance"));
|
||||
ASSERT(settings.isEnabled("portability"));
|
||||
ASSERT(!settings.isEnabled("unusedFunction"));
|
||||
ASSERT(!settings.isEnabled("missingInclude"));
|
||||
ASSERT(!settings.isEnabled(Settings::STYLE));
|
||||
ASSERT(!settings.isEnabled(Settings::WARNING));
|
||||
ASSERT(!settings.isEnabled(Settings::PERFORMANCE));
|
||||
ASSERT(settings.isEnabled(Settings::PORTABILITY));
|
||||
ASSERT(!settings.isEnabled(Settings::UNUSED_FUNCTION));
|
||||
ASSERT(!settings.isEnabled(Settings::MISSING_INCLUDE));
|
||||
}
|
||||
|
||||
void enabledUnusedFunction() {
|
||||
|
@ -506,7 +506,7 @@ private:
|
|||
const char *argv[] = {"cppcheck", "--enable=unusedFunction", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings.isEnabled("unusedFunction"));
|
||||
ASSERT(settings.isEnabled(Settings::UNUSED_FUNCTION));
|
||||
}
|
||||
|
||||
void enabledMissingInclude() {
|
||||
|
@ -514,7 +514,7 @@ private:
|
|||
const char *argv[] = {"cppcheck", "--enable=missingInclude", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings.isEnabled("missingInclude"));
|
||||
ASSERT(settings.isEnabled(Settings::MISSING_INCLUDE));
|
||||
}
|
||||
|
||||
#ifdef CHECK_INTERNAL
|
||||
|
@ -523,7 +523,7 @@ private:
|
|||
const char *argv[] = {"cppcheck", "--enable=internal", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(settings.isEnabled("internal"));
|
||||
ASSERT(settings.isEnabled(Settings::INTERNAL));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -532,12 +532,12 @@ private:
|
|||
const char *argv[] = {"cppcheck", "--enable=missingInclude,portability,warning", "file.cpp"};
|
||||
settings = Settings();
|
||||
ASSERT(defParser.ParseFromArgs(3, argv));
|
||||
ASSERT(!settings.isEnabled("style"));
|
||||
ASSERT(settings.isEnabled("warning"));
|
||||
ASSERT(!settings.isEnabled("performance"));
|
||||
ASSERT(settings.isEnabled("portability"));
|
||||
ASSERT(!settings.isEnabled("unusedFunction"));
|
||||
ASSERT(settings.isEnabled("missingInclude"));
|
||||
ASSERT(!settings.isEnabled(Settings::STYLE));
|
||||
ASSERT(settings.isEnabled(Settings::WARNING));
|
||||
ASSERT(!settings.isEnabled(Settings::PERFORMANCE));
|
||||
ASSERT(settings.isEnabled(Settings::PORTABILITY));
|
||||
ASSERT(!settings.isEnabled(Settings::UNUSED_FUNCTION));
|
||||
ASSERT(settings.isEnabled(Settings::MISSING_INCLUDE));
|
||||
}
|
||||
|
||||
void inconclusive() {
|
||||
|
|
Loading…
Reference in New Issue