diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 4e6c8f5ee881..591f257eb94f 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1714,7 +1714,7 @@ void CheckClass::operatorEqMissingReturnStatementError(const Token *tok, bool er void CheckClass::operatorEqToSelf() { - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("operatorEqToSelf")) return; logChecker("CheckClass::operatorEqToSelf"); // warning @@ -2953,7 +2953,7 @@ void CheckClass::pureVirtualFunctionCallInConstructorError( void CheckClass::checkDuplInheritedMembers() { - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("duplInheritedMember")) return; logChecker("CheckClass::checkDuplInheritedMembers"); // warning diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 4f7b0e8d8adb..de4e6e15c44a 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -411,9 +411,11 @@ void CheckIO::incompatibleFileOpenError(const Token *tok, const std::string &fil //--------------------------------------------------------------------------- void CheckIO::invalidScanf() { - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("invalidscanf")) return; + logChecker("CheckIO::invalidScanf"); + const SymbolDatabase * const symbolDatabase = mTokenizer->getSymbolDatabase(); for (const Scope * scope : symbolDatabase->functionScopes) { for (const Token *tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) { @@ -1710,7 +1712,7 @@ void CheckIO::wrongPrintfScanfArgumentsError(const Token* tok, nonneg int numFunction) { const Severity severity = numFormat > numFunction ? Severity::error : Severity::warning; - if (severity != Severity::error && !mSettings->severity.isEnabled(Severity::warning)) + if (severity != Severity::error && !mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("wrongPrintfScanfArgNum")) return; std::ostringstream errmsg; @@ -1729,7 +1731,7 @@ void CheckIO::wrongPrintfScanfArgumentsError(const Token* tok, void CheckIO::wrongPrintfScanfPosixParameterPositionError(const Token* tok, const std::string& functionName, nonneg int index, nonneg int numFunction) { - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("wrongPrintfScanfParameterPositionError")) return; std::ostringstream errmsg; errmsg << functionName << ": "; @@ -1992,7 +1994,7 @@ void CheckIO::argumentType(std::ostream& os, const ArgumentInfo * argInfo) void CheckIO::invalidLengthModifierError(const Token* tok, nonneg int numFormat, const std::string& modifier) { - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("invalidLengthModifierError")) return; std::ostringstream errmsg; errmsg << "'" << modifier << "' in format string (no. " << numFormat << ") is a length modifier and cannot be used without a conversion specifier."; diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 733e6053bcf1..e9f7d4100aab 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1093,9 +1093,14 @@ void CheckMemoryLeakNoVar::checkForUnusedReturnValue(const Scope *scope) void CheckMemoryLeakNoVar::checkForUnsafeArgAlloc(const Scope *scope) { // This test only applies to C++ source - if (!mTokenizer->isCPP() || !mSettings->certainty.isEnabled(Certainty::inconclusive) || !mSettings->severity.isEnabled(Severity::warning)) + if (!mTokenizer->isCPP()) return; + if (!mSettings->isPremiumEnabled("leakUnsafeArgAlloc") && (!mSettings->certainty.isEnabled(Certainty::inconclusive) || !mSettings->severity.isEnabled(Severity::warning))) + return; + + logChecker("CheckMemoryLeakNoVar::checkForUnsafeArgAlloc"); + for (const Token *tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) { if (Token::Match(tok, "%name% (")) { const Token *endParamToken = tok->next()->link(); diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 9c5d25096b55..f2421df32cdd 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -441,7 +441,7 @@ void CheckNullPointer::nullPointerError(const Token *tok, const std::string &var return; } - if (!mSettings->isEnabled(value, inconclusive)) + if (!mSettings->isEnabled(value, inconclusive) && !mSettings->isPremiumEnabled("nullPointer")) return; const ErrorPath errorPath = getErrorPath(tok, value, "Null pointer dereference"); diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 6f960586a7fa..4cb7663dcf37 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1326,9 +1326,11 @@ static bool isVariableMutableInInitializer(const Token* start, const Token * end void CheckOther::checkConstVariable() { - if (!mSettings->severity.isEnabled(Severity::style) || mTokenizer->isC()) + if ((!mSettings->severity.isEnabled(Severity::style) || mTokenizer->isC()) && !mSettings->isPremiumEnabled("constVariable")) return; + logChecker("CheckOther::checkConstVariable"); // style,c++ + const SymbolDatabase *const symbolDatabase = mTokenizer->getSymbolDatabase(); for (const Variable *var : symbolDatabase->variableList()) { @@ -3344,7 +3346,9 @@ void CheckOther::unknownEvaluationOrder(const Token* tok) void CheckOther::checkAccessOfMovedVariable() { - if (!mTokenizer->isCPP() || mSettings->standards.cpp < Standards::CPP11 || !mSettings->severity.isEnabled(Severity::warning)) + if (!mTokenizer->isCPP()) + return; + if (!mSettings->isPremiumEnabled("accessMoved") && (!mSettings->standards.cpp < Standards::CPP11 || !mSettings->severity.isEnabled(Severity::warning))) return; logChecker("CheckOther::checkAccessOfMovedVariable"); // c++11,warning const bool reportInconclusive = mSettings->certainty.isEnabled(Certainty::inconclusive); diff --git a/lib/checksizeof.cpp b/lib/checksizeof.cpp index 50ddd100f8f7..ffd9622bdc02 100644 --- a/lib/checksizeof.cpp +++ b/lib/checksizeof.cpp @@ -358,7 +358,7 @@ void CheckSizeof::sizeofCalculationError(const Token *tok, bool inconclusive) void CheckSizeof::sizeofFunction() { - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("sizeofFunctionCall")) return; logChecker("CheckSizeof::sizeofFunction"); // warning diff --git a/lib/settings.cpp b/lib/settings.cpp index e1780aa0d405..9ff5d94497b5 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -313,10 +313,11 @@ static const std::set autosarCheckers{ "comparePointers", "constParameter", "cstyleCast", - "ctuOneDefinitionViolation", + "ctuOneDefinitionRuleViolation", "doubleFree", "duplInheritedMember", "duplicateBreak", + "exceptThrowInDestructor", "funcArgNamesDifferent", "functionConst", "functionStatic", @@ -340,9 +341,11 @@ static const std::set autosarCheckers{ "redundantAssignment", "redundantInitialization", "returnDanglingLifetime", + "shadowArgument", + "shadowFunction", + "shadowVariable", "shiftTooManyBits", - "sizeofSideEffects", - "throwInDestructor", + "sizeofFunctionCall", "throwInNoexceptFunction", "uninitData", "uninitMember", @@ -353,7 +356,7 @@ static const std::set autosarCheckers{ "unusedStructMember", "unusedValue", "unusedVariable", - "useInitializerList", + "useInitializationList", "variableScope", "virtualCallInConstructor", "zerodiv", @@ -405,8 +408,11 @@ static const std::set certCppCheckers{ "accessMoved", "comparePointers", "containerOutOfBounds", - "ctuOneDefinitionViolation", - "deallocMismatch", + "ctuOneDefinitionRuleViolation", + "danglingLifetime", + "danglingReference", + "danglingTempReference", + "danglingTemporaryLifetime", "deallocThrow", "deallocuse", "doubleFree", @@ -414,11 +420,12 @@ static const std::set certCppCheckers{ "exceptThrowInDestructor", "initializerList", "invalidContainer", - "lifetime", "memleak", + "mismatchAllocDealloc", "missingReturn", "nullPointer", "operatorEqToSelf", + "returnDanglingLifetime", "sizeofCalculation", "uninitvar", "virtualCallInConstructor", @@ -433,10 +440,10 @@ static const std::set misrac2012Checkers{ "bufferAccessOutOfBounds", "comparePointers", "compareValueOutOfTypeRangeError", - "constPointer", + "constParameterPointer", "danglingLifetime", + "danglingTemporaryLifetime", "duplicateBreak", - "error", "funcArgNamesDifferent", "incompatibleFileOpen", "invalidFunctionArg", @@ -454,11 +461,14 @@ static const std::set misrac2012Checkers{ "redundantAssignment", "redundantCondition", "resourceLeak", + "returnDanglingLifetime", "shadowVariable", "sizeofCalculation", + "sizeofwithsilentarraypointer", "syntaxError", "uninitvar", "unknownEvaluationOrder", + "unreachableCode", "unreadVariable", "unusedLabel", "unusedVariable", @@ -474,10 +484,10 @@ static const std::set misrac2023Checkers{ "bufferAccessOutOfBounds", "comparePointers", "compareValueOutOfTypeRangeError", - "constPointer", + "constParameterPointer", "danglingLifetime", + "danglingTemporaryLifetime", "duplicateBreak", - "error", "funcArgNamesDifferent", "incompatibleFileOpen", "invalidFunctionArg", @@ -495,11 +505,14 @@ static const std::set misrac2023Checkers{ "redundantAssignment", "redundantCondition", "resourceLeak", + "returnDanglingLifetime", "shadowVariable", "sizeofCalculation", + "sizeofwithsilentarraypointer", "syntaxError", "uninitvar", "unknownEvaluationOrder", + "unreachableCode", "unreadVariable", "unusedLabel", "unusedVariable", @@ -513,7 +526,7 @@ static const std::set misracpp2008Checkers{ "constParameter", "constVariable", "cstyleCast", - "ctuOneDefinitionViolation", + "ctuOneDefinitionRuleViolation", "danglingLifetime", "duplInheritedMember", "duplicateBreak", @@ -522,7 +535,7 @@ static const std::set misracpp2008Checkers{ "functionConst", "functionStatic", "missingReturn", - "noExplicit", + "noExplicitConstructor", "overlappingWriteFunction", "overlappingWriteUnion", "pointerOutOfBounds", @@ -533,8 +546,7 @@ static const std::set misracpp2008Checkers{ "returnTempReference", "shadowVariable", "shiftTooManyBits", - "sizeofSideEffects", - "throwInDestructor", + "sizeofFunctionCall", "uninitDerivedMemberVar", "uninitDerivedMemberVarPrivate", "uninitMemberVar", @@ -549,7 +561,6 @@ static const std::set misracpp2008Checkers{ "unusedFunction", "unusedStructMember", "unusedVariable", - "varScope", "variableScope", "virtualCallInConstructor" };