diff --git a/lib/checkbool.cpp b/lib/checkbool.cpp index efeb65b9488..acc9b5dc4e1 100644 --- a/lib/checkbool.cpp +++ b/lib/checkbool.cpp @@ -341,7 +341,7 @@ void CheckBool::assignBoolToPointerError(const Token *tok) //----------------------------------------------------------------------------- void CheckBool::checkComparisonOfBoolExpressionWithInt() { - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("compareBoolExpressionWithInt")) return; logChecker("CheckBool::checkComparisonOfBoolExpressionWithInt"); // warning diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 1f926f6ce20..19dade8114e 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/checkcondition.cpp b/lib/checkcondition.cpp index 58d0fcec718..70fa4d9ae33 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -613,7 +613,9 @@ static bool isNonConstFunctionCall(const Token *ftok, const Library &library) void CheckCondition::multiCondition2() { - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && + !mSettings->isPremiumEnabled("identicalConditionAfterEarlyExit") && + !mSettings->isPremiumEnabled("identicalInnerCondition")) return; logChecker("CheckCondition::multiCondition2"); // warning @@ -1482,7 +1484,8 @@ void CheckCondition::alwaysTrueFalse() { if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("alwaysTrue") && - !mSettings->isPremiumEnabled("alwaysFalse")) + !mSettings->isPremiumEnabled("alwaysFalse") && + !mSettings->isPremiumEnabled("knownConditionTrueFalse")) return; logChecker("CheckCondition::alwaysTrueFalse"); // style diff --git a/lib/checkers.cpp b/lib/checkers.cpp index d6f6be3b861..e54943302b7 100644 --- a/lib/checkers.cpp +++ b/lib/checkers.cpp @@ -94,6 +94,7 @@ namespace checkers { {"CheckOther::checkUnreachableCode","style"}, {"CheckOther::checkVariableScope","style,notclang"}, {"CheckOther::checkPassByReference","performance,c++"}, + {"CheckOther::checkConstVariable","style,c++"}, {"CheckOther::checkConstPointer","style"}, {"CheckOther::checkCharVariable","warning,portability"}, {"CheckOther::checkIncompleteStatement","warning"}, @@ -146,6 +147,7 @@ namespace checkers { {"CheckUnusedVar::checkStructMemberUsage","style"}, {"CheckIO::checkCoutCerrMisusage","c"}, {"CheckIO::checkFileUsage",""}, + {"CheckIO::invalidScanf",""}, {"CheckIO::checkWrongPrintfScanfArguments",""}, {"CheckCondition::assignIf","style"}, {"CheckCondition::checkBadBitmaskCheck","style"}, @@ -202,6 +204,7 @@ namespace checkers { {"CheckMemoryLeakInClass::check",""}, {"CheckMemoryLeakStructMember::check",""}, {"CheckMemoryLeakNoVar::check",""}, + {"CheckMemoryLeakNoVar::checkForUnsafeArgAlloc",""}, }; const std::map premiumCheckers{ @@ -230,7 +233,6 @@ namespace checkers { {"Autosar: A2-13-1",""}, {"Autosar: A2-13-3",""}, {"Autosar: A2-13-5",""}, - {"Autosar: A2-13-6",""}, {"Autosar: A2-5-2",""}, {"Autosar: A20-8-2","warning"}, {"Autosar: A20-8-3","warning"}, @@ -404,6 +406,9 @@ namespace checkers { {"Cert C: STR32-C",""}, {"Cert C: STR34-C",""}, {"Cert C: STR38-C",""}, + {"Misra C++ 2008: 3-2-3",""}, + {"Misra C++ 2008: 3-2-4",""}, + {"Misra C++ 2008: 7-5-4",""}, {"Misra C++ 2008: M0-1-11",""}, {"Misra C++ 2008: M0-1-12",""}, {"Misra C++ 2008: M0-1-4",""}, @@ -578,18 +583,28 @@ namespace checkers { {"Misra C++ 2008: M9-6-2",""}, {"Misra C++ 2008: M9-6-3",""}, {"Misra C++ 2008: M9-6-4",""}, + {"Misra C++ 2023: 0.1.2",""}, {"Misra C++ 2023: 0.2.1",""}, + {"Misra C++ 2023: 0.2.2",""}, + {"Misra C++ 2023: 0.2.3",""}, + {"Misra C++ 2023: 0.2.4",""}, {"Misra C++ 2023: 10.0.1",""}, {"Misra C++ 2023: 10.1.2",""}, {"Misra C++ 2023: 10.2.1",""}, {"Misra C++ 2023: 10.2.2",""}, {"Misra C++ 2023: 10.2.3",""}, + {"Misra C++ 2023: 10.3.1",""}, {"Misra C++ 2023: 10.4.1",""}, {"Misra C++ 2023: 11.3.1",""}, + {"Misra C++ 2023: 11.3.2",""}, {"Misra C++ 2023: 11.6.1",""}, {"Misra C++ 2023: 11.6.3",""}, {"Misra C++ 2023: 12.2.1",""}, + {"Misra C++ 2023: 12.2.2",""}, + {"Misra C++ 2023: 12.2.3",""}, + {"Misra C++ 2023: 12.3.1",""}, {"Misra C++ 2023: 13.1.1",""}, + {"Misra C++ 2023: 13.1.2",""}, {"Misra C++ 2023: 13.3.1",""}, {"Misra C++ 2023: 13.3.2",""}, {"Misra C++ 2023: 13.3.3",""}, @@ -597,36 +612,86 @@ namespace checkers { {"Misra C++ 2023: 14.1.1",""}, {"Misra C++ 2023: 15.0.1",""}, {"Misra C++ 2023: 15.0.2",""}, + {"Misra C++ 2023: 15.1.2",""}, {"Misra C++ 2023: 15.1.3",""}, {"Misra C++ 2023: 15.1.5",""}, + {"Misra C++ 2023: 16.5.1",""}, + {"Misra C++ 2023: 16.5.2",""}, + {"Misra C++ 2023: 16.6.1",""}, {"Misra C++ 2023: 17.8.1",""}, + {"Misra C++ 2023: 18.1.1",""}, + {"Misra C++ 2023: 18.1.2",""}, + {"Misra C++ 2023: 18.3.1",""}, + {"Misra C++ 2023: 18.3.2",""}, + {"Misra C++ 2023: 18.3.3",""}, {"Misra C++ 2023: 18.4.1",""}, + {"Misra C++ 2023: 18.5.1",""}, {"Misra C++ 2023: 18.5.2",""}, + {"Misra C++ 2023: 19.0.1",""}, + {"Misra C++ 2023: 19.0.2",""}, + {"Misra C++ 2023: 19.0.3",""}, + {"Misra C++ 2023: 19.0.4",""}, + {"Misra C++ 2023: 19.1.1",""}, + {"Misra C++ 2023: 19.1.2",""}, + {"Misra C++ 2023: 19.1.3",""}, + {"Misra C++ 2023: 19.2.1",""}, + {"Misra C++ 2023: 19.2.2",""}, + {"Misra C++ 2023: 19.2.3",""}, + {"Misra C++ 2023: 19.3.1",""}, {"Misra C++ 2023: 19.3.2",""}, {"Misra C++ 2023: 19.3.3",""}, - {"Misra C++ 2023: 21.20.1",""}, - {"Misra C++ 2023: 21.20.2",""}, + {"Misra C++ 2023: 19.3.4",""}, + {"Misra C++ 2023: 19.6.1",""}, + {"Misra C++ 2023: 21.10.1",""}, + {"Misra C++ 2023: 21.10.2",""}, + {"Misra C++ 2023: 21.10.3",""}, + {"Misra C++ 2023: 21.2.1",""}, + {"Misra C++ 2023: 21.2.2",""}, + {"Misra C++ 2023: 21.2.3",""}, + {"Misra C++ 2023: 21.2.4",""}, + {"Misra C++ 2023: 21.6.1",""}, + {"Misra C++ 2023: 21.6.2",""}, {"Misra C++ 2023: 21.6.3",""}, {"Misra C++ 2023: 21.6.4",""}, {"Misra C++ 2023: 21.6.5",""}, {"Misra C++ 2023: 22.3.1",""}, {"Misra C++ 2023: 22.4.1",""}, + {"Misra C++ 2023: 23.11.1",""}, {"Misra C++ 2023: 24.5.1",""}, {"Misra C++ 2023: 24.5.2",""}, {"Misra C++ 2023: 25.5.1",""}, {"Misra C++ 2023: 25.5.2",""}, {"Misra C++ 2023: 25.5.3",""}, + {"Misra C++ 2023: 26.3.1",""}, + {"Misra C++ 2023: 28.3.1",""}, {"Misra C++ 2023: 28.6.1",""}, {"Misra C++ 2023: 28.6.2",""}, + {"Misra C++ 2023: 30.0.1",""}, {"Misra C++ 2023: 30.0.2",""}, {"Misra C++ 2023: 4.1.1",""}, {"Misra C++ 2023: 4.1.2",""}, + {"Misra C++ 2023: 5.0.1",""}, + {"Misra C++ 2023: 5.13.1",""}, {"Misra C++ 2023: 5.13.2",""}, + {"Misra C++ 2023: 5.13.3",""}, + {"Misra C++ 2023: 5.13.4",""}, {"Misra C++ 2023: 5.13.5",""}, {"Misra C++ 2023: 5.13.6",""}, + {"Misra C++ 2023: 5.13.7",""}, + {"Misra C++ 2023: 5.7.1",""}, + {"Misra C++ 2023: 5.7.2",""}, {"Misra C++ 2023: 5.7.3",""}, + {"Misra C++ 2023: 6.0.1",""}, + {"Misra C++ 2023: 6.0.2",""}, + {"Misra C++ 2023: 6.0.3",""}, + {"Misra C++ 2023: 6.0.4",""}, + {"Misra C++ 2023: 6.2.2",""}, + {"Misra C++ 2023: 6.2.3",""}, + {"Misra C++ 2023: 6.2.4",""}, {"Misra C++ 2023: 6.4.2",""}, {"Misra C++ 2023: 6.4.3",""}, + {"Misra C++ 2023: 6.5.1",""}, + {"Misra C++ 2023: 6.5.2",""}, {"Misra C++ 2023: 6.7.1",""}, {"Misra C++ 2023: 6.7.2",""}, {"Misra C++ 2023: 6.8.3",""}, @@ -636,20 +701,42 @@ namespace checkers { {"Misra C++ 2023: 7.0.1",""}, {"Misra C++ 2023: 7.0.2",""}, {"Misra C++ 2023: 7.0.3",""}, + {"Misra C++ 2023: 7.0.4",""}, {"Misra C++ 2023: 7.0.5",""}, {"Misra C++ 2023: 7.0.6",""}, + {"Misra C++ 2023: 7.11.1",""}, + {"Misra C++ 2023: 7.11.2",""}, + {"Misra C++ 2023: 7.11.3",""}, + {"Misra C++ 2023: 8.0.1",""}, {"Misra C++ 2023: 8.1.1",""}, + {"Misra C++ 2023: 8.1.2",""}, + {"Misra C++ 2023: 8.14.1",""}, + {"Misra C++ 2023: 8.18.2",""}, + {"Misra C++ 2023: 8.19.1",""}, + {"Misra C++ 2023: 8.2.1",""}, + {"Misra C++ 2023: 8.2.10",""}, {"Misra C++ 2023: 8.2.11",""}, {"Misra C++ 2023: 8.2.2",""}, {"Misra C++ 2023: 8.2.3",""}, {"Misra C++ 2023: 8.2.4",""}, + {"Misra C++ 2023: 8.2.5",""}, + {"Misra C++ 2023: 8.2.6",""}, + {"Misra C++ 2023: 8.2.7",""}, {"Misra C++ 2023: 8.2.8",""}, {"Misra C++ 2023: 8.2.9",""}, + {"Misra C++ 2023: 8.20.1",""}, + {"Misra C++ 2023: 8.3.1",""}, {"Misra C++ 2023: 8.3.2",""}, {"Misra C++ 2023: 9.2.1",""}, + {"Misra C++ 2023: 9.3.1",""}, + {"Misra C++ 2023: 9.4.1",""}, + {"Misra C++ 2023: 9.4.2",""}, {"Misra C++ 2023: 9.5.1",""}, {"Misra C++ 2023: 9.5.2",""}, {"Misra C++ 2023: 9.6.1",""}, + {"Misra C++ 2023: 9.6.2",""}, + {"Misra C++ 2023: 9.6.3",""}, + {"Misra C++ 2023: 9.6.4",""}, {"Misra C: 1.4",""}, {"Misra C: 1.5",""}, {"Misra C: 10.1",""}, @@ -675,6 +762,7 @@ namespace checkers { {"Misra C: 17.11",""}, {"Misra C: 17.12",""}, {"Misra C: 17.13",""}, + {"Misra C: 17.2",""}, {"Misra C: 17.3",""}, {"Misra C: 17.4",""}, {"Misra C: 17.9",""}, @@ -720,6 +808,8 @@ namespace checkers { {"Misra C: 8.17",""}, {"Misra C: 8.3",""}, {"Misra C: 8.4",""}, + {"Misra C: 8.6",""}, + {"Misra C: 8.7",""}, {"Misra C: 8.8",""}, {"Misra C: 9.6",""}, {"Misra C: 9.7",""}, diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 4f7b0e8d8ad..de4e6e15c44 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 733e6053bcf..e9f7d4100aa 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 9c5d25096b5..f2421df32cd 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 6f960586a7f..ab819ce857b 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -424,7 +424,9 @@ void CheckOther::invalidPointerCastError(const Token* tok, const std::string& fr void CheckOther::checkRedundantAssignment() { - if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("redundantAssignment")) + if (!mSettings->severity.isEnabled(Severity::style) && + !mSettings->isPremiumEnabled("redundantAssignment") && + !mSettings->isPremiumEnabled("redundantAssignInSwitch")) return; logChecker("CheckOther::checkRedundantAssignment"); // style @@ -773,7 +775,7 @@ void CheckOther::checkUnreachableCode() // misra-c-2023-2.1 // misra-cpp-2008-0-1-1 // autosar - if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("unreachableCode")) + if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("duplicateBreak") && !mSettings->isPremiumEnabled("unreachableCode")) return; logChecker("CheckOther::checkUnreachableCode"); // style @@ -1326,9 +1328,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()) { @@ -1476,6 +1480,7 @@ void CheckOther::checkConstPointer() { if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("constParameter") && + !mSettings->isPremiumEnabled("constParameterReference") && !mSettings->isPremiumEnabled("constPointer")) return; @@ -3344,7 +3349,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() || mSettings->standards.cpp < Standards::CPP11) + return; + if (!mSettings->isPremiumEnabled("accessMoved") && !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 50ddd100f8f..ffd9622bdc0 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/checkunusedvar.cpp b/lib/checkunusedvar.cpp index 718221dc798..2e70a00a426 100644 --- a/lib/checkunusedvar.cpp +++ b/lib/checkunusedvar.cpp @@ -1445,7 +1445,7 @@ void CheckUnusedVar::unassignedVariableError(const Token *tok, const std::string //--------------------------------------------------------------------------- void CheckUnusedVar::checkStructMemberUsage() { - if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("unusedVariable")) + if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("unusedStructMember") && !mSettings->isPremiumEnabled("unusedVariable")) return; logChecker("CheckUnusedVar::checkStructMemberUsage"); // style diff --git a/lib/settings.cpp b/lib/settings.cpp index e1780aa0d40..805556670d3 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,11 +561,50 @@ static const std::set misracpp2008Checkers{ "unusedFunction", "unusedStructMember", "unusedVariable", - "varScope", "variableScope", "virtualCallInConstructor" }; +static const std::set misracpp2023Checkers{ + "accessForwarded", + "accessMoved", + "autoVariables", + "compareBoolExpressionWithInt", + "comparePointers", + "compareValueOutOfTypeRangeError", + "constParameter", + "constParameterReference", + "ctuOneDefinitionRuleViolation", + "danglingLifetime", + "identicalConditionAfterEarlyExit", + "identicalInnerCondition", + "ignoredReturnValue", + "invalidFunctionArg", + "invalidFunctionArgBool", + "invalidFunctionArgStr", + "knownConditionTrueFalse", + "missingReturn", + "noExplicitConstructor", + "operatorEqToSelf", + "overlappingWriteUnion", + "pointerOutOfBounds", + "pointerOutOfBoundsCond", + "preprocessorErrorDirective", + "redundantAssignInSwitch", + "redundantAssignment", + "redundantCopy", + "redundantInitialization", + "shadowVariable", + "subtractPointers", + "syntaxError", + "uninitMemberVar", + "uninitvar", + "unknownEvaluationOrder", + "unreachableCode", + "unreadVariable", + "virtualCallInConstructor" +}; + bool Settings::isPremiumEnabled(const char id[]) const { if (premiumArgs.find("autosar") != std::string::npos && autosarCheckers.count(id)) @@ -564,7 +615,9 @@ bool Settings::isPremiumEnabled(const char id[]) const return true; if (premiumArgs.find("misra-c-") != std::string::npos && (misrac2012Checkers.count(id) || misrac2023Checkers.count(id))) return true; - if (premiumArgs.find("misra-c++") != std::string::npos && misracpp2008Checkers.count(id)) + if (premiumArgs.find("misra-c++-2008") != std::string::npos && misracpp2008Checkers.count(id)) + return true; + if (premiumArgs.find("misra-c++-2023") != std::string::npos && misracpp2023Checkers.count(id)) return true; return false; } diff --git a/tools/get_checkers.py b/tools/get_checkers.py index ca0b8427689..4b7c7b3ea64 100644 --- a/tools/get_checkers.py +++ b/tools/get_checkers.py @@ -1,10 +1,11 @@ +import datetime import glob import os import re print("""/* * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2023 Cppcheck team. + * Copyright (C) 2007-%i Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,7 +27,7 @@ #include "checkers.h" namespace checkers { - const std::map allCheckers{""") + const std::map allCheckers{""" % (datetime.date.today().year,)) for filename in glob.glob(os.path.expanduser('~/cppchecksolutions/cppcheck/lib/*.cpp')): for line in open(filename,'rt'):