From 397464e430b6576b314443fe18ce49e8a6b502bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 17 Apr 2024 17:31:21 +0200 Subject: [PATCH] Fix #12458 (checkers report: does not indicate misra checkers properly) (#6302) --- addons/cppcheckdata.py | 8 + addons/misra.py | 4 + lib/checkbufferoverrun.cpp | 4 +- lib/checkers.cpp | 818 +++++++++++++++++++++---------------- lib/checkersreport.cpp | 118 ++++-- lib/checkother.cpp | 2 +- 6 files changed, 561 insertions(+), 393 deletions(-) diff --git a/addons/cppcheckdata.py b/addons/cppcheckdata.py index 80f97c720de..fcd05c61dd6 100755 --- a/addons/cppcheckdata.py +++ b/addons/cppcheckdata.py @@ -1651,6 +1651,14 @@ def is_suppressed(location, message, errorId): return True return False +def log_checker(message, addon): + if '--cli' in sys.argv: + msg = { 'addon': addon, + 'severity': 'none', + 'message': message, + 'errorId': 'logChecker'} + sys.stdout.write(json.dumps(msg) + '\n') + def reportError(location, severity, message, addon, errorId, extra='', columnOverride=None): if '--cli' in sys.argv: msg = { 'file': location.file, diff --git a/addons/misra.py b/addons/misra.py index fcdca17e766..990059c41fd 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -4489,6 +4489,10 @@ def executeCheck(self, rule_num, check_function, *args): 1901) # misra-c2012-19.1 : misra c++2008 2-13-3 if (not self.is_cpp) or rule_num in misra_cpp: + # log checker + errmsg = 'Misra C: %i.%i' % (rule_num // 100, rule_num % 100) + cppcheckdata.log_checker(errmsg, 'misra') + check_function(*args) def parseDump(self, dumpfile, path_premium_addon=None): diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 884ca51f2f3..592ca09665f 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -462,7 +462,7 @@ void CheckBufferOverrun::negativeIndexError(const Token* tok, void CheckBufferOverrun::pointerArithmetic() { - if (!mSettings->severity.isEnabled(Severity::portability)) + if (!mSettings->severity.isEnabled(Severity::portability) && !mSettings->isPremiumEnabled("pointerOutOfBounds")) return; logChecker("CheckBufferOverrun::pointerArithmetic"); // portability @@ -820,7 +820,7 @@ void CheckBufferOverrun::terminateStrncpyError(const Token *tok, const std::stri void CheckBufferOverrun::argumentSize() { // Check '%type% x[10]' arguments - if (!mSettings->severity.isEnabled(Severity::warning)) + if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("argumentSize")) return; logChecker("CheckBufferOverrun::argumentSize"); // warning diff --git a/lib/checkers.cpp b/lib/checkers.cpp index da054e635e7..4e2f0459227 100644 --- a/lib/checkers.cpp +++ b/lib/checkers.cpp @@ -64,6 +64,7 @@ namespace checkers { {"CheckStl::checkDereferenceInvalidIterator2",""}, {"CheckStl::useStlAlgorithm","style"}, {"CheckStl::knownEmptyContainer","style"}, + {"CheckStl::eraseIteratorOutOfBounds",""}, {"CheckStl::checkMutexes","warning"}, {"CheckBoost::checkBoostForeachModification",""}, {"CheckNullPointer::nullPointer",""}, @@ -137,6 +138,7 @@ namespace checkers { {"CheckClass::checkDuplInheritedMembers","warning"}, {"CheckClass::checkMissingOverride","style,c++03"}, {"CheckClass::checkUselessOverride","style"}, + {"CheckClass::checkReturnByReference","performance"}, {"CheckClass::checkThisUseAfterFree","warning"}, {"CheckClass::checkUnsafeClassRefMember","warning,safeChecks"}, {"CheckClass::analyseWholeProgram",""}, @@ -171,7 +173,7 @@ namespace checkers { {"CheckFunctions::useStandardLibrary","style"}, {"CheckVaarg::va_start_argument",""}, {"CheckVaarg::va_list_usage","notclang"}, - {"CheckUnusedFunctions::analyseWholeProgram","unusedFunctions"}, + {"CheckUnusedFunctions::check","unusedFunction"}, {"CheckType::checkTooBigBitwiseShift","platform"}, {"CheckType::checkIntegerOverflow","platform"}, {"CheckType::checkSignConversion","warning"}, @@ -203,93 +205,93 @@ namespace checkers { }; const std::map premiumCheckers{ - {"Autosar: A0-1-3","style"}, - {"Autosar: A0-1-6","style"}, - {"Autosar: A0-4-2","style"}, - {"Autosar: A0-4-4","style"}, - {"Autosar: A10-1-1","style"}, - {"Autosar: A11-0-2","style"}, - {"Autosar: A11-3-1","style"}, - {"Autosar: A13-2-1","style"}, - {"Autosar: A13-2-3","style"}, - {"Autosar: A13-5-2","style"}, - {"Autosar: A13-5-5","style"}, - {"Autosar: A15-1-2","style"}, - {"Autosar: A15-3-5","style"}, - {"Autosar: A16-6-1","style"}, - {"Autosar: A16-7-1","style"}, - {"Autosar: A18-0-3","style"}, - {"Autosar: A18-1-1","style"}, - {"Autosar: A18-1-2","style"}, - {"Autosar: A18-1-3","style"}, - {"Autosar: A18-5-1","style"}, - {"Autosar: A18-9-1","style"}, - {"Autosar: A2-11-1","style"}, - {"Autosar: A2-13-1","style"}, - {"Autosar: A2-13-3","style"}, - {"Autosar: A2-13-5","style"}, - {"Autosar: A2-13-6","style"}, - {"Autosar: A2-5-2","style"}, + {"Autosar: A0-1-3",""}, + {"Autosar: A0-1-6",""}, + {"Autosar: A0-4-2",""}, + {"Autosar: A0-4-4",""}, + {"Autosar: A10-1-1",""}, + {"Autosar: A11-0-2",""}, + {"Autosar: A11-3-1",""}, + {"Autosar: A13-2-1",""}, + {"Autosar: A13-2-3",""}, + {"Autosar: A13-5-2",""}, + {"Autosar: A13-5-5",""}, + {"Autosar: A15-1-2",""}, + {"Autosar: A15-3-5",""}, + {"Autosar: A16-6-1",""}, + {"Autosar: A16-7-1",""}, + {"Autosar: A18-0-3",""}, + {"Autosar: A18-1-1",""}, + {"Autosar: A18-1-2",""}, + {"Autosar: A18-1-3",""}, + {"Autosar: A18-5-1",""}, + {"Autosar: A18-9-1",""}, + {"Autosar: A2-11-1",""}, + {"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"}, - {"Autosar: A20-8-4","style"}, - {"Autosar: A20-8-5","style"}, - {"Autosar: A20-8-6","style"}, + {"Autosar: A20-8-4",""}, + {"Autosar: A20-8-5",""}, + {"Autosar: A20-8-6",""}, {"Autosar: A21-8-1","warning"}, - {"Autosar: A23-0-1","style"}, + {"Autosar: A23-0-1",""}, {"Autosar: A25-1-1","warning"}, {"Autosar: A25-4-1","warning"}, - {"Autosar: A26-5-1","style"}, - {"Autosar: A26-5-2","style"}, + {"Autosar: A26-5-1",""}, + {"Autosar: A26-5-2",""}, {"Autosar: A27-0-1","warning"}, - {"Autosar: A27-0-2","style"}, - {"Autosar: A27-0-4","style"}, - {"Autosar: A3-1-3","style"}, - {"Autosar: A3-1-4","style"}, - {"Autosar: A3-3-1","style"}, - {"Autosar: A4-10-1","style"}, - {"Autosar: A4-7-1","style"}, - {"Autosar: A5-0-2","style"}, - {"Autosar: A5-0-3","style"}, - {"Autosar: A5-0-4","style"}, - {"Autosar: A5-1-1","style"}, - {"Autosar: A5-1-2","style"}, - {"Autosar: A5-1-3","style"}, - {"Autosar: A5-1-6","style"}, - {"Autosar: A5-1-7","style"}, - {"Autosar: A5-16-1","style"}, - {"Autosar: A5-2-1","style"}, - {"Autosar: A5-2-4","style"}, - {"Autosar: A6-5-3","style"}, - {"Autosar: A7-1-4","style"}, - {"Autosar: A7-1-6","style"}, - {"Autosar: A7-1-7","style"}, - {"Autosar: A8-4-1","style"}, - {"Autosar: A8-5-3","style"}, - {"Autosar: A9-3-1","style"}, + {"Autosar: A27-0-2",""}, + {"Autosar: A27-0-4",""}, + {"Autosar: A3-1-3",""}, + {"Autosar: A3-1-4",""}, + {"Autosar: A3-3-1",""}, + {"Autosar: A4-10-1",""}, + {"Autosar: A4-7-1",""}, + {"Autosar: A5-0-2",""}, + {"Autosar: A5-0-3",""}, + {"Autosar: A5-0-4",""}, + {"Autosar: A5-1-1",""}, + {"Autosar: A5-1-2",""}, + {"Autosar: A5-1-3",""}, + {"Autosar: A5-1-6",""}, + {"Autosar: A5-1-7",""}, + {"Autosar: A5-16-1",""}, + {"Autosar: A5-2-1",""}, + {"Autosar: A5-2-4",""}, + {"Autosar: A6-5-3",""}, + {"Autosar: A7-1-4",""}, + {"Autosar: A7-1-6",""}, + {"Autosar: A7-1-7",""}, + {"Autosar: A8-4-1",""}, + {"Autosar: A8-5-3",""}, + {"Autosar: A9-3-1",""}, {"Cert C++: CON51-CPP",""}, - {"Cert C++: CON52-CPP","style"}, - {"Cert C++: CON53-CPP","style"}, - {"Cert C++: CON54-CPP","style"}, - {"Cert C++: CON55-CPP","style"}, + {"Cert C++: CON52-CPP",""}, + {"Cert C++: CON53-CPP",""}, + {"Cert C++: CON54-CPP",""}, + {"Cert C++: CON55-CPP",""}, {"Cert C++: CON56-CPP",""}, {"Cert C++: CTR50-CPP",""}, {"Cert C++: CTR52-CPP",""}, {"Cert C++: CTR53-CPP",""}, - {"Cert C++: CTR56-CPP","style"}, + {"Cert C++: CTR56-CPP",""}, {"Cert C++: CTR57-CPP","warning"}, {"Cert C++: CTR58-CPP","warning"}, - {"Cert C++: DCL50-CPP","style"}, - {"Cert C++: DCL51-CPP","style"}, - {"Cert C++: DCL52-CPP","style"}, - {"Cert C++: DCL53-CPP","style"}, + {"Cert C++: DCL50-CPP",""}, + {"Cert C++: DCL51-CPP",""}, + {"Cert C++: DCL52-CPP",""}, + {"Cert C++: DCL53-CPP",""}, {"Cert C++: DCL54-CPP",""}, {"Cert C++: DCL56-CPP",""}, - {"Cert C++: DCL58-CPP","style"}, - {"Cert C++: DCL59-CPP","style"}, + {"Cert C++: DCL58-CPP",""}, + {"Cert C++: DCL59-CPP",""}, {"Cert C++: ERR50-CPP",""}, - {"Cert C++: ERR51-CPP","style"}, - {"Cert C++: ERR52-CPP","style"}, + {"Cert C++: ERR51-CPP",""}, + {"Cert C++: ERR52-CPP",""}, {"Cert C++: ERR53-CPP",""}, {"Cert C++: ERR54-CPP",""}, {"Cert C++: ERR55-CPP",""}, @@ -297,311 +299,429 @@ namespace checkers { {"Cert C++: ERR58-CPP",""}, {"Cert C++: ERR59-CPP","warning"}, {"Cert C++: ERR60-CPP","warning"}, - {"Cert C++: ERR61-CPP","style"}, - {"Cert C++: ERR62-CPP","style"}, + {"Cert C++: ERR61-CPP",""}, + {"Cert C++: ERR62-CPP",""}, {"Cert C++: EXP50-CPP",""}, {"Cert C++: EXP51-CPP",""}, {"Cert C++: EXP55-CPP",""}, {"Cert C++: EXP56-CPP",""}, - {"Cert C++: EXP57-CPP","style"}, - {"Cert C++: EXP58-CPP","style"}, + {"Cert C++: EXP57-CPP",""}, + {"Cert C++: EXP58-CPP",""}, {"Cert C++: EXP59-CPP",""}, - {"Cert C++: FIO51-CPP","style"}, - {"Cert C++: INT50-CPP","style"}, + {"Cert C++: FIO51-CPP",""}, + {"Cert C++: INT50-CPP",""}, {"Cert C++: MEM52-CPP",""}, {"Cert C++: MEM53-CPP",""}, {"Cert C++: MEM54-CPP",""}, {"Cert C++: MEM55-CPP",""}, - {"Cert C++: MEM57-CPP","style"}, - {"Cert C++: MSC50-CPP","style"}, - {"Cert C++: MSC51-CPP","style"}, + {"Cert C++: MEM57-CPP",""}, + {"Cert C++: MSC50-CPP",""}, + {"Cert C++: MSC51-CPP",""}, {"Cert C++: MSC53-CPP",""}, - {"Cert C++: MSC54-CPP","style"}, + {"Cert C++: MSC54-CPP",""}, {"Cert C++: OOP51-CPP",""}, {"Cert C++: OOP55-CPP",""}, {"Cert C++: OOP56-CPP",""}, {"Cert C++: OOP57-CPP",""}, - {"Cert C++: OOP58-CPP","style"}, + {"Cert C++: OOP58-CPP",""}, {"Cert C++: STR50-CPP",""}, {"Cert C++: STR53-CPP",""}, - {"Cert C: ARR30-C","warning"}, - {"Cert C: ARR32-C","warning"}, - {"Cert C: ARR37-C","warning"}, + {"Cert C: ARR30-C",""}, + {"Cert C: ARR32-C",""}, + {"Cert C: ARR37-C",""}, {"Cert C: ARR38-C",""}, - {"Cert C: ARR39-C","warning"}, - {"Cert C: CON30-C","style"}, - {"Cert C: CON31-C","style"}, - {"Cert C: CON32-C","style"}, - {"Cert C: CON33-C","style"}, - {"Cert C: CON34-C","warning"}, - {"Cert C: CON35-C","warning"}, - {"Cert C: CON36-C","style"}, - {"Cert C: CON37-C","style"}, - {"Cert C: CON38-C","warning"}, - {"Cert C: CON39-C","warning"}, - {"Cert C: CON40-C","warning"}, - {"Cert C: CON41-C","style"}, - {"Cert C: DCL31-C","style"}, - {"Cert C: DCL36-C","style"}, - {"Cert C: DCL37-C","style"}, - {"Cert C: DCL38-C","style"}, - {"Cert C: DCL39-C","style"}, - {"Cert C: DCL40-C","style"}, - {"Cert C: DCL41-C","style"}, - {"Cert C: ENV30-C","style"}, - {"Cert C: ENV31-C","style"}, - {"Cert C: ENV32-C","style"}, - {"Cert C: ENV33-C","style"}, - {"Cert C: ENV34-C","style"}, - {"Cert C: ERR30-C","warning"}, - {"Cert C: ERR32-C","warning"}, - {"Cert C: ERR33-C","warning"}, - {"Cert C: EXP32-C","warning"}, + {"Cert C: ARR39-C",""}, + {"Cert C: CON30-C",""}, + {"Cert C: CON31-C",""}, + {"Cert C: CON32-C",""}, + {"Cert C: CON33-C",""}, + {"Cert C: CON34-C",""}, + {"Cert C: CON35-C",""}, + {"Cert C: CON36-C",""}, + {"Cert C: CON37-C",""}, + {"Cert C: CON38-C",""}, + {"Cert C: CON39-C",""}, + {"Cert C: CON40-C",""}, + {"Cert C: CON41-C",""}, + {"Cert C: DCL31-C",""}, + {"Cert C: DCL36-C",""}, + {"Cert C: DCL37-C",""}, + {"Cert C: DCL38-C",""}, + {"Cert C: DCL39-C",""}, + {"Cert C: DCL40-C",""}, + {"Cert C: DCL41-C",""}, + {"Cert C: ENV30-C",""}, + {"Cert C: ENV31-C",""}, + {"Cert C: ENV32-C",""}, + {"Cert C: ENV33-C",""}, + {"Cert C: ENV34-C",""}, + {"Cert C: ERR30-C",""}, + {"Cert C: ERR32-C",""}, + {"Cert C: ERR33-C",""}, + {"Cert C: EXP32-C",""}, {"Cert C: EXP35-C",""}, - {"Cert C: EXP36-C","style"}, - {"Cert C: EXP37-C","style"}, - {"Cert C: EXP39-C","style"}, - {"Cert C: EXP40-C","style"}, - {"Cert C: EXP42-C","style"}, - {"Cert C: EXP43-C","style"}, - {"Cert C: EXP45-C","warning"}, - {"Cert C: FIO30-C","warning"}, - {"Cert C: FIO32-C","style"}, - {"Cert C: FIO34-C","style"}, + {"Cert C: EXP36-C",""}, + {"Cert C: EXP37-C",""}, + {"Cert C: EXP39-C",""}, + {"Cert C: EXP40-C",""}, + {"Cert C: EXP42-C",""}, + {"Cert C: EXP43-C",""}, + {"Cert C: EXP45-C",""}, + {"Cert C: FIO30-C",""}, + {"Cert C: FIO32-C",""}, + {"Cert C: FIO34-C",""}, {"Cert C: FIO37-C",""}, - {"Cert C: FIO38-C","style"}, - {"Cert C: FIO40-C","style"}, - {"Cert C: FIO41-C","style"}, - {"Cert C: FIO44-C","warning"}, - {"Cert C: FIO45-C","warning"}, - {"Cert C: FLP30-C","warning"}, + {"Cert C: FIO38-C",""}, + {"Cert C: FIO40-C",""}, + {"Cert C: FIO41-C",""}, + {"Cert C: FIO44-C",""}, + {"Cert C: FIO45-C",""}, + {"Cert C: FLP30-C",""}, {"Cert C: FLP36-C","portability"}, - {"Cert C: FLP37-C","style"}, - {"Cert C: INT30-C","warning"}, - {"Cert C: INT31-C","warning"}, - {"Cert C: INT32-C","warning"}, - {"Cert C: INT33-C","warning"}, - {"Cert C: INT34-C","warning"}, - {"Cert C: INT35-C","warning"}, - {"Cert C: INT36-C","warning"}, - {"Cert C: MEM33-C","style"}, - {"Cert C: MEM35-C","warning"}, - {"Cert C: MEM36-C","warning"}, - {"Cert C: MSC30-C","style"}, - {"Cert C: MSC32-C","style"}, - {"Cert C: MSC33-C","style"}, - {"Cert C: MSC38-C","warning"}, - {"Cert C: MSC39-C","warning"}, - {"Cert C: MSC40-C","warning"}, - {"Cert C: PRE31-C","style"}, - {"Cert C: SIG30-C","style"}, - {"Cert C: SIG31-C","warning"}, - {"Cert C: SIG34-C","style"}, - {"Cert C: SIG35-C","warning"}, - {"Cert C: STR31-C","warning"}, - {"Cert C: STR32-C","warning"}, - {"Cert C: STR34-C","warning"}, - {"Cert C: STR38-C","style"}, - {"Misra C++: M0-1-11","style"}, - {"Misra C++: M0-1-12","style"}, - {"Misra C++: M0-1-4","style"}, - {"Misra C++: M0-1-5","style"}, - {"Misra C++: M0-1-7","style"}, - {"Misra C++: M0-1-8","style"}, - {"Misra C++: M10-1-1","style"}, - {"Misra C++: M10-1-2","style"}, - {"Misra C++: M10-1-3","style"}, - {"Misra C++: M10-2-1","style"}, - {"Misra C++: M10-3-1","style"}, - {"Misra C++: M10-3-3","style"}, - {"Misra C++: M11-0-1","style"}, - {"Misra C++: M12-1-2","style"}, - {"Misra C++: M12-8-1","style"}, - {"Misra C++: M12-8-2","style"}, - {"Misra C++: M14-5-1","warning"}, - {"Misra C++: M14-5-2","warning"}, - {"Misra C++: M14-5-3","warning"}, - {"Misra C++: M14-6-1","warning"}, - {"Misra C++: M14-6-2","warning"}, - {"Misra C++: M14-7-1","style"}, - {"Misra C++: M14-7-2","style"}, - {"Misra C++: M14-7-3","style"}, - {"Misra C++: M14-8-1","style"}, - {"Misra C++: M14-8-2","style"}, - {"Misra C++: M15-0-3",""}, - {"Misra C++: M15-1-1",""}, - {"Misra C++: M15-1-2","style"}, - {"Misra C++: M15-1-3","style"}, - {"Misra C++: M15-3-2","warning"}, - {"Misra C++: M15-3-3",""}, - {"Misra C++: M15-3-4",""}, - {"Misra C++: M15-4-1","style"}, - {"Misra C++: M15-5-2",""}, - {"Misra C++: M16-0-1","style"}, - {"Misra C++: M16-0-2","style"}, - {"Misra C++: M16-0-3","style"}, - {"Misra C++: M16-0-4","style"}, - {"Misra C++: M16-1-1","style"}, - {"Misra C++: M16-2-1","style"}, - {"Misra C++: M16-2-2","style"}, - {"Misra C++: M16-2-3","style"}, - {"Misra C++: M16-2-4","style"}, - {"Misra C++: M16-2-5","style"}, - {"Misra C++: M16-2-6","style"}, - {"Misra C++: M16-3-1","style"}, - {"Misra C++: M16-3-2","style"}, - {"Misra C++: M17-0-1","style"}, - {"Misra C++: M17-0-2","style"}, - {"Misra C++: M17-0-3","style"}, - {"Misra C++: M17-0-5","style"}, - {"Misra C++: M18-0-1","style"}, - {"Misra C++: M18-0-2","style"}, - {"Misra C++: M18-0-3","style"}, - {"Misra C++: M18-0-4","style"}, - {"Misra C++: M18-0-5","style"}, - {"Misra C++: M18-2-1","style"}, - {"Misra C++: M18-4-1","style"}, - {"Misra C++: M18-7-1","style"}, - {"Misra C++: M19-3-1","style"}, - {"Misra C++: M2-10-1","style"}, - {"Misra C++: M2-10-3","style"}, - {"Misra C++: M2-10-4","style"}, - {"Misra C++: M2-10-5","style"}, - {"Misra C++: M2-10-6","style"}, - {"Misra C++: M2-13-4","style"}, - {"Misra C++: M2-13-5","style"}, - {"Misra C++: M2-7-1","style"}, - {"Misra C++: M2-7-2","style"}, - {"Misra C++: M2-7-3","style"}, - {"Misra C++: M27-0-1","style"}, - {"Misra C++: M3-1-1","style"}, - {"Misra C++: M3-1-2","style"}, - {"Misra C++: M3-1-3","style"}, - {"Misra C++: M3-2-1",""}, - {"Misra C++: M3-3-1","style"}, - {"Misra C++: M3-3-2","style"}, - {"Misra C++: M3-9-1","style"}, - {"Misra C++: M3-9-2","style"}, - {"Misra C++: M3-9-3","style"}, - {"Misra C++: M4-10-1","style"}, - {"Misra C++: M4-10-2","style"}, - {"Misra C++: M4-5-1","style"}, - {"Misra C++: M4-5-2","style"}, - {"Misra C++: M4-5-3","style"}, - {"Misra C++: M5-0-10","style"}, - {"Misra C++: M5-0-11","style"}, - {"Misra C++: M5-0-12","style"}, - {"Misra C++: M5-0-14","style"}, - {"Misra C++: M5-0-15","style"}, - {"Misra C++: M5-0-2","style"}, - {"Misra C++: M5-0-20","style"}, - {"Misra C++: M5-0-21","style"}, - {"Misra C++: M5-0-3","style"}, - {"Misra C++: M5-0-4","style"}, - {"Misra C++: M5-0-5","style"}, - {"Misra C++: M5-0-6","style"}, - {"Misra C++: M5-0-7","style"}, - {"Misra C++: M5-0-8","style"}, - {"Misra C++: M5-0-9","style"}, - {"Misra C++: M5-17-1","style"}, - {"Misra C++: M5-2-1","style"}, - {"Misra C++: M5-2-10","style"}, - {"Misra C++: M5-2-11","style"}, - {"Misra C++: M5-2-12","style"}, - {"Misra C++: M5-2-2","style"}, - {"Misra C++: M5-2-3","style"}, - {"Misra C++: M5-2-5","style"}, - {"Misra C++: M5-2-6","style"}, - {"Misra C++: M5-2-7","style"}, - {"Misra C++: M5-2-8","style"}, - {"Misra C++: M5-2-9","style"}, - {"Misra C++: M5-3-1","style"}, - {"Misra C++: M5-3-2","style"}, - {"Misra C++: M5-3-3","style"}, - {"Misra C++: M6-2-3","style"}, - {"Misra C++: M6-4-4","style"}, - {"Misra C++: M6-4-6","style"}, - {"Misra C++: M6-4-7","style"}, - {"Misra C++: M6-4-8","style"}, - {"Misra C++: M6-5-1","style"}, - {"Misra C++: M6-5-2","style"}, - {"Misra C++: M6-5-3","style"}, - {"Misra C++: M6-5-4","style"}, - {"Misra C++: M6-5-5","style"}, - {"Misra C++: M6-5-6","style"}, - {"Misra C++: M6-6-1","style"}, - {"Misra C++: M6-6-3","style"}, - {"Misra C++: M6-6-4","style"}, - {"Misra C++: M6-6-5","style"}, - {"Misra C++: M7-2-1","style"}, - {"Misra C++: M7-3-1","style"}, - {"Misra C++: M7-3-2","style"}, - {"Misra C++: M7-3-3","style"}, - {"Misra C++: M7-3-4","style"}, - {"Misra C++: M7-3-5","style"}, - {"Misra C++: M7-3-6","style"}, - {"Misra C++: M7-4-2","style"}, - {"Misra C++: M7-4-3","style"}, - {"Misra C++: M7-5-3","style"}, - {"Misra C++: M8-0-1","style"}, - {"Misra C++: M8-3-1","style"}, - {"Misra C++: M8-4-4","style"}, - {"Misra C++: M8-5-2","style"}, - {"Misra C++: M8-5-3","style"}, - {"Misra C++: M9-3-1","style"}, - {"Misra C++: M9-5-1","style"}, - {"Misra C++: M9-6-2","style"}, - {"Misra C++: M9-6-3","style"}, - {"Misra C++: M9-6-4","style"}, - {"Misra C: 1.5","style"}, - {"Misra C: 10.1","style"}, - {"Misra C: 10.2","style"}, - {"Misra C: 10.3","style"}, - {"Misra C: 10.4","style"}, - {"Misra C: 10.5","style"}, - {"Misra C: 10.6","style"}, - {"Misra C: 10.7","style"}, - {"Misra C: 10.8","style"}, - {"Misra C: 11.10","style"}, + {"Cert C: FLP37-C",""}, + {"Cert C: INT30-C",""}, + {"Cert C: INT31-C",""}, + {"Cert C: INT32-C",""}, + {"Cert C: INT33-C",""}, + {"Cert C: INT34-C",""}, + {"Cert C: INT35-C",""}, + {"Cert C: INT36-C",""}, + {"Cert C: MEM33-C",""}, + {"Cert C: MEM35-C",""}, + {"Cert C: MEM36-C",""}, + {"Cert C: MSC30-C",""}, + {"Cert C: MSC32-C",""}, + {"Cert C: MSC33-C",""}, + {"Cert C: MSC38-C",""}, + {"Cert C: MSC39-C",""}, + {"Cert C: MSC40-C",""}, + {"Cert C: PRE31-C",""}, + {"Cert C: SIG30-C",""}, + {"Cert C: SIG31-C",""}, + {"Cert C: SIG34-C",""}, + {"Cert C: SIG35-C",""}, + {"Cert C: STR31-C",""}, + {"Cert C: STR32-C",""}, + {"Cert C: STR34-C",""}, + {"Cert C: STR38-C",""}, + {"Misra C++ 2008: M0-1-11",""}, + {"Misra C++ 2008: M0-1-12",""}, + {"Misra C++ 2008: M0-1-4",""}, + {"Misra C++ 2008: M0-1-5",""}, + {"Misra C++ 2008: M0-1-7",""}, + {"Misra C++ 2008: M0-1-8",""}, + {"Misra C++ 2008: M0-3-2",""}, + {"Misra C++ 2008: M1-0-1","portability"}, + {"Misra C++ 2008: M10-1-1",""}, + {"Misra C++ 2008: M10-1-2",""}, + {"Misra C++ 2008: M10-1-3",""}, + {"Misra C++ 2008: M10-2-1",""}, + {"Misra C++ 2008: M10-3-1",""}, + {"Misra C++ 2008: M10-3-2",""}, + {"Misra C++ 2008: M10-3-3",""}, + {"Misra C++ 2008: M11-0-1",""}, + {"Misra C++ 2008: M12-1-2",""}, + {"Misra C++ 2008: M12-8-1",""}, + {"Misra C++ 2008: M12-8-2",""}, + {"Misra C++ 2008: M14-5-1","warning"}, + {"Misra C++ 2008: M14-5-2","warning"}, + {"Misra C++ 2008: M14-5-3","warning"}, + {"Misra C++ 2008: M14-6-1","warning"}, + {"Misra C++ 2008: M14-6-2","warning"}, + {"Misra C++ 2008: M14-7-1",""}, + {"Misra C++ 2008: M14-7-2",""}, + {"Misra C++ 2008: M14-7-3",""}, + {"Misra C++ 2008: M14-8-1",""}, + {"Misra C++ 2008: M14-8-2",""}, + {"Misra C++ 2008: M15-0-3",""}, + {"Misra C++ 2008: M15-1-1",""}, + {"Misra C++ 2008: M15-1-2",""}, + {"Misra C++ 2008: M15-1-3",""}, + {"Misra C++ 2008: M15-3-2","warning"}, + {"Misra C++ 2008: M15-3-3",""}, + {"Misra C++ 2008: M15-3-4",""}, + {"Misra C++ 2008: M15-3-6",""}, + {"Misra C++ 2008: M15-3-7",""}, + {"Misra C++ 2008: M15-4-1",""}, + {"Misra C++ 2008: M15-5-2",""}, + {"Misra C++ 2008: M16-0-1",""}, + {"Misra C++ 2008: M16-0-2",""}, + {"Misra C++ 2008: M16-0-3",""}, + {"Misra C++ 2008: M16-0-4",""}, + {"Misra C++ 2008: M16-0-6",""}, + {"Misra C++ 2008: M16-0-7",""}, + {"Misra C++ 2008: M16-0-8",""}, + {"Misra C++ 2008: M16-1-1",""}, + {"Misra C++ 2008: M16-1-2",""}, + {"Misra C++ 2008: M16-2-1",""}, + {"Misra C++ 2008: M16-2-2",""}, + {"Misra C++ 2008: M16-2-3",""}, + {"Misra C++ 2008: M16-2-4",""}, + {"Misra C++ 2008: M16-2-5",""}, + {"Misra C++ 2008: M16-2-6",""}, + {"Misra C++ 2008: M16-3-1",""}, + {"Misra C++ 2008: M16-3-2",""}, + {"Misra C++ 2008: M17-0-1",""}, + {"Misra C++ 2008: M17-0-2",""}, + {"Misra C++ 2008: M17-0-3",""}, + {"Misra C++ 2008: M17-0-5",""}, + {"Misra C++ 2008: M18-0-1",""}, + {"Misra C++ 2008: M18-0-2",""}, + {"Misra C++ 2008: M18-0-3",""}, + {"Misra C++ 2008: M18-0-4",""}, + {"Misra C++ 2008: M18-0-5",""}, + {"Misra C++ 2008: M18-2-1",""}, + {"Misra C++ 2008: M18-4-1",""}, + {"Misra C++ 2008: M18-7-1",""}, + {"Misra C++ 2008: M19-3-1",""}, + {"Misra C++ 2008: M2-10-1",""}, + {"Misra C++ 2008: M2-10-3",""}, + {"Misra C++ 2008: M2-10-4",""}, + {"Misra C++ 2008: M2-10-5",""}, + {"Misra C++ 2008: M2-10-6",""}, + {"Misra C++ 2008: M2-13-2",""}, + {"Misra C++ 2008: M2-13-3",""}, + {"Misra C++ 2008: M2-13-4",""}, + {"Misra C++ 2008: M2-13-5",""}, + {"Misra C++ 2008: M2-3-1",""}, + {"Misra C++ 2008: M2-7-1",""}, + {"Misra C++ 2008: M2-7-2",""}, + {"Misra C++ 2008: M2-7-3",""}, + {"Misra C++ 2008: M27-0-1",""}, + {"Misra C++ 2008: M3-1-1",""}, + {"Misra C++ 2008: M3-1-2",""}, + {"Misra C++ 2008: M3-1-3",""}, + {"Misra C++ 2008: M3-2-1",""}, + {"Misra C++ 2008: M3-3-1",""}, + {"Misra C++ 2008: M3-3-2",""}, + {"Misra C++ 2008: M3-9-1",""}, + {"Misra C++ 2008: M3-9-2",""}, + {"Misra C++ 2008: M3-9-3",""}, + {"Misra C++ 2008: M4-10-1",""}, + {"Misra C++ 2008: M4-10-2",""}, + {"Misra C++ 2008: M4-5-1",""}, + {"Misra C++ 2008: M4-5-2",""}, + {"Misra C++ 2008: M4-5-3",""}, + {"Misra C++ 2008: M5-0-10",""}, + {"Misra C++ 2008: M5-0-11",""}, + {"Misra C++ 2008: M5-0-12",""}, + {"Misra C++ 2008: M5-0-14",""}, + {"Misra C++ 2008: M5-0-15",""}, + {"Misra C++ 2008: M5-0-2",""}, + {"Misra C++ 2008: M5-0-20",""}, + {"Misra C++ 2008: M5-0-21",""}, + {"Misra C++ 2008: M5-0-3",""}, + {"Misra C++ 2008: M5-0-4",""}, + {"Misra C++ 2008: M5-0-5",""}, + {"Misra C++ 2008: M5-0-6",""}, + {"Misra C++ 2008: M5-0-7",""}, + {"Misra C++ 2008: M5-0-8",""}, + {"Misra C++ 2008: M5-0-9",""}, + {"Misra C++ 2008: M5-14-1",""}, + {"Misra C++ 2008: M5-17-1",""}, + {"Misra C++ 2008: M5-18-1",""}, + {"Misra C++ 2008: M5-19-1",""}, + {"Misra C++ 2008: M5-2-1",""}, + {"Misra C++ 2008: M5-2-10",""}, + {"Misra C++ 2008: M5-2-11",""}, + {"Misra C++ 2008: M5-2-12",""}, + {"Misra C++ 2008: M5-2-2",""}, + {"Misra C++ 2008: M5-2-3",""}, + {"Misra C++ 2008: M5-2-5",""}, + {"Misra C++ 2008: M5-2-6",""}, + {"Misra C++ 2008: M5-2-7",""}, + {"Misra C++ 2008: M5-2-8",""}, + {"Misra C++ 2008: M5-2-9",""}, + {"Misra C++ 2008: M5-3-1",""}, + {"Misra C++ 2008: M5-3-2",""}, + {"Misra C++ 2008: M5-3-3",""}, + {"Misra C++ 2008: M6-2-1",""}, + {"Misra C++ 2008: M6-2-2",""}, + {"Misra C++ 2008: M6-2-3",""}, + {"Misra C++ 2008: M6-3-1",""}, + {"Misra C++ 2008: M6-4-1",""}, + {"Misra C++ 2008: M6-4-2",""}, + {"Misra C++ 2008: M6-4-3",""}, + {"Misra C++ 2008: M6-4-4",""}, + {"Misra C++ 2008: M6-4-5",""}, + {"Misra C++ 2008: M6-4-6",""}, + {"Misra C++ 2008: M6-4-7",""}, + {"Misra C++ 2008: M6-4-8",""}, + {"Misra C++ 2008: M6-5-1",""}, + {"Misra C++ 2008: M6-5-2",""}, + {"Misra C++ 2008: M6-5-3",""}, + {"Misra C++ 2008: M6-5-4",""}, + {"Misra C++ 2008: M6-5-5",""}, + {"Misra C++ 2008: M6-5-6",""}, + {"Misra C++ 2008: M6-6-1",""}, + {"Misra C++ 2008: M6-6-2",""}, + {"Misra C++ 2008: M6-6-3",""}, + {"Misra C++ 2008: M6-6-4",""}, + {"Misra C++ 2008: M6-6-5",""}, + {"Misra C++ 2008: M7-2-1",""}, + {"Misra C++ 2008: M7-3-1",""}, + {"Misra C++ 2008: M7-3-2",""}, + {"Misra C++ 2008: M7-3-3",""}, + {"Misra C++ 2008: M7-3-4",""}, + {"Misra C++ 2008: M7-3-5",""}, + {"Misra C++ 2008: M7-3-6",""}, + {"Misra C++ 2008: M7-4-2",""}, + {"Misra C++ 2008: M7-4-3",""}, + {"Misra C++ 2008: M7-5-3",""}, + {"Misra C++ 2008: M8-0-1",""}, + {"Misra C++ 2008: M8-3-1",""}, + {"Misra C++ 2008: M8-4-4",""}, + {"Misra C++ 2008: M8-5-2",""}, + {"Misra C++ 2008: M8-5-3",""}, + {"Misra C++ 2008: M9-3-1",""}, + {"Misra C++ 2008: M9-5-1",""}, + {"Misra C++ 2008: M9-6-2",""}, + {"Misra C++ 2008: M9-6-3",""}, + {"Misra C++ 2008: M9-6-4",""}, + {"Misra C++ 2023: 0.2.1",""}, + {"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.4.1",""}, + {"Misra C++ 2023: 11.3.1",""}, + {"Misra C++ 2023: 11.6.1",""}, + {"Misra C++ 2023: 11.6.3",""}, + {"Misra C++ 2023: 12.2.1",""}, + {"Misra C++ 2023: 13.1.1",""}, + {"Misra C++ 2023: 13.3.1",""}, + {"Misra C++ 2023: 13.3.2",""}, + {"Misra C++ 2023: 13.3.3",""}, + {"Misra C++ 2023: 13.3.4",""}, + {"Misra C++ 2023: 14.1.1",""}, + {"Misra C++ 2023: 15.0.1",""}, + {"Misra C++ 2023: 15.0.2",""}, + {"Misra C++ 2023: 15.1.3",""}, + {"Misra C++ 2023: 15.1.5",""}, + {"Misra C++ 2023: 17.8.1",""}, + {"Misra C++ 2023: 18.4.1",""}, + {"Misra C++ 2023: 18.5.2",""}, + {"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: 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: 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: 28.6.1",""}, + {"Misra C++ 2023: 28.6.2",""}, + {"Misra C++ 2023: 30.0.2",""}, + {"Misra C++ 2023: 4.1.1",""}, + {"Misra C++ 2023: 4.1.2",""}, + {"Misra C++ 2023: 5.13.2",""}, + {"Misra C++ 2023: 5.13.5",""}, + {"Misra C++ 2023: 5.13.6",""}, + {"Misra C++ 2023: 5.7.3",""}, + {"Misra C++ 2023: 6.4.2",""}, + {"Misra C++ 2023: 6.4.3",""}, + {"Misra C++ 2023: 6.7.1",""}, + {"Misra C++ 2023: 6.7.2",""}, + {"Misra C++ 2023: 6.8.3",""}, + {"Misra C++ 2023: 6.8.4",""}, + {"Misra C++ 2023: 6.9.1",""}, + {"Misra C++ 2023: 6.9.2",""}, + {"Misra C++ 2023: 7.0.1",""}, + {"Misra C++ 2023: 7.0.2",""}, + {"Misra C++ 2023: 7.0.3",""}, + {"Misra C++ 2023: 7.0.5",""}, + {"Misra C++ 2023: 7.0.6",""}, + {"Misra C++ 2023: 8.1.1",""}, + {"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.8",""}, + {"Misra C++ 2023: 8.2.9",""}, + {"Misra C++ 2023: 8.3.2",""}, + {"Misra C++ 2023: 9.2.1",""}, + {"Misra C++ 2023: 9.5.1",""}, + {"Misra C++ 2023: 9.5.2",""}, + {"Misra C++ 2023: 9.6.1",""}, + {"Misra C: 1.4",""}, + {"Misra C: 1.5",""}, + {"Misra C: 10.1",""}, + {"Misra C: 10.2",""}, + {"Misra C: 10.3",""}, + {"Misra C: 10.4",""}, + {"Misra C: 10.5",""}, + {"Misra C: 10.6",""}, + {"Misra C: 10.7",""}, + {"Misra C: 10.8",""}, + {"Misra C: 11.10",""}, + {"Misra C: 12.3",""}, {"Misra C: 12.6",""}, - {"Misra C: 17.10","style"}, - {"Misra C: 17.11","style"}, - {"Misra C: 17.12","style"}, - {"Misra C: 17.9","style"}, - {"Misra C: 18.10","style"}, - {"Misra C: 18.9","style"}, - {"Misra C: 21.12","style"}, - {"Misra C: 21.22","style"}, - {"Misra C: 21.23","style"}, - {"Misra C: 21.24","style"}, + {"Misra C: 13.1",""}, + {"Misra C: 13.2",""}, + {"Misra C: 13.3",""}, + {"Misra C: 13.4",""}, + {"Misra C: 13.5",""}, + {"Misra C: 13.6",""}, + {"Misra C: 15.5",""}, + {"Misra C: 16.3",""}, + {"Misra C: 17.10",""}, + {"Misra C: 17.11",""}, + {"Misra C: 17.12",""}, + {"Misra C: 17.13",""}, + {"Misra C: 17.3",""}, + {"Misra C: 17.4",""}, + {"Misra C: 17.9",""}, + {"Misra C: 18.10",""}, + {"Misra C: 18.5",""}, + {"Misra C: 18.8",""}, + {"Misra C: 18.9",""}, + {"Misra C: 20.3",""}, + {"Misra C: 21.1",""}, + {"Misra C: 21.12",""}, + {"Misra C: 21.16",""}, + {"Misra C: 21.2",""}, + {"Misra C: 21.22",""}, + {"Misra C: 21.23",""}, + {"Misra C: 21.24",""}, {"Misra C: 21.25","warning"}, {"Misra C: 21.26","warning"}, {"Misra C: 22.11",""}, - {"Misra C: 22.12","style"}, - {"Misra C: 22.13","style"}, - {"Misra C: 22.14","style"}, - {"Misra C: 22.15","style"}, + {"Misra C: 22.12",""}, + {"Misra C: 22.13",""}, + {"Misra C: 22.14",""}, + {"Misra C: 22.15",""}, {"Misra C: 22.16","warning"}, {"Misra C: 22.17","warning"}, {"Misra C: 22.18","warning"}, {"Misra C: 22.19","warning"}, - {"Misra C: 22.20","style"}, - {"Misra C: 23.1","style"}, - {"Misra C: 23.2","style"}, - {"Misra C: 23.3","style"}, - {"Misra C: 23.4","style"}, - {"Misra C: 23.5","style"}, - {"Misra C: 23.6","style"}, - {"Misra C: 23.7","style"}, - {"Misra C: 23.8","style"}, - {"Misra C: 6.3","style"}, - {"Misra C: 7.5","style"}, - {"Misra C: 7.6","style"}, - {"Misra C: 8.10","style"}, - {"Misra C: 8.15","style"}, - {"Misra C: 8.16","style"}, - {"Misra C: 8.17","style"}, - {"Misra C: 9.6","style"}, + {"Misra C: 22.20",""}, + {"Misra C: 23.1",""}, + {"Misra C: 23.2",""}, + {"Misra C: 23.3",""}, + {"Misra C: 23.4",""}, + {"Misra C: 23.5",""}, + {"Misra C: 23.6",""}, + {"Misra C: 23.7",""}, + {"Misra C: 23.8",""}, + {"Misra C: 6.3",""}, + {"Misra C: 7.5",""}, + {"Misra C: 7.6",""}, + {"Misra C: 8.1",""}, + {"Misra C: 8.10",""}, + {"Misra C: 8.15",""}, + {"Misra C: 8.16",""}, + {"Misra C: 8.17",""}, + {"Misra C: 8.3",""}, + {"Misra C: 8.4",""}, + {"Misra C: 8.8",""}, + {"Misra C: 9.6",""}, {"Misra C: 9.7",""}, {"PremiumCheckBufferOverrun::addressOfPointerArithmetic","warning"}, {"PremiumCheckBufferOverrun::negativeBufferSizeCheckedNonZero","warning"}, diff --git a/lib/checkersreport.cpp b/lib/checkersreport.cpp index 8fd7512069b..27deb3e0b31 100644 --- a/lib/checkersreport.cpp +++ b/lib/checkersreport.cpp @@ -31,27 +31,61 @@ static bool isCppcheckPremium(const Settings& settings) { return (settings.cppcheckCfgProductName.compare(0, 16, "Cppcheck Premium") == 0); } -static std::string getMisraRuleSeverity(const std::string& rule) { - if (checkers::misraRuleSeverity.count(rule) > 0) - return checkers::misraRuleSeverity.at(rule); - return "style"; -} - -static bool isMisraRuleInconclusive(const std::string& rule) { - return rule == "8.3"; -} +static bool isMisraRuleActive(const std::set& activeCheckers, const std::string& rule) { + if (activeCheckers.count("Misra C: " + rule)) + return true; + if (rule == "1.1") + return true; // syntax error + if (rule == "1.3") + return true; // undefined behavior + if (rule == "2.1") + return activeCheckers.count("CheckCondition::alwaysTrueFalse") != 0; + if (rule == "2.6") + return activeCheckers.count("CheckOther::checkUnusedLabel") != 0; + if (rule == "2.8") + return activeCheckers.count("CheckUnusedVar::checkFunctionVariableUsage") != 0; + if (rule == "5.3") + return activeCheckers.count("CheckOther::checkShadowVariables") != 0; + if (rule == "8.13") + return activeCheckers.count("CheckOther::checkConstPointer") != 0; + if (rule == "9.1") + return true; // uninitvar + if (rule == "12.5") + return activeCheckers.count("CheckOther::checkConstPointer") != 0; + if (rule == "14.3") + return activeCheckers.count("CheckCondition::alwaysTrueFalse") != 0; + if (rule == "17.5") + return activeCheckers.count("CheckBufferOverrun::argumentSize") != 0; + if (rule == "18.1") + return activeCheckers.count("CheckBufferOverrun::pointerArithmetic") != 0; + if (rule == "18.2") + return activeCheckers.count("CheckOther::checkComparePointers") != 0; + if (rule == "18.3") + return activeCheckers.count("CheckOther::checkComparePointers") != 0; + if (rule == "18.6") + return true; // danlingLifetime => error + if (rule == "19.1") + return activeCheckers.count("CheckOther::checkOverlappingWrite") != 0; + if (rule == "20.6") + return true; // preprocessorErrorDirective + if (rule == "21.13") + return activeCheckers.count("CheckFunctions::invalidFunctionUsage") != 0; + if (rule == "21.17") + return activeCheckers.count("CheckBufferOverrun::bufferOverflow") != 0; + if (rule == "21.18") + return activeCheckers.count("CheckBufferOverrun::bufferOverflow") != 0; + if (rule == "22.1") + return true; // memleak => error + if (rule == "22.2") + return activeCheckers.count("CheckAutoVariables::autoVariables") != 0; + if (rule == "22.3") + return activeCheckers.count("CheckIO::checkFileUsage") != 0; + if (rule == "22.4") + return activeCheckers.count("CheckIO::checkFileUsage") != 0; + if (rule == "22.6") + return activeCheckers.count("CheckIO::checkFileUsage") != 0; -static bool isMisraRuleActive(const std::string& rule, int amendment, const std::string& severity, const Settings& settings) { - if (!isCppcheckPremium(settings) && amendment >= 3) - return false; - const bool inconclusive = isMisraRuleInconclusive(rule); - if (inconclusive && !settings.certainty.isEnabled(Certainty::inconclusive)) - return false; - if (severity == "warning") - return settings.severity.isEnabled(Severity::warning); - if (severity == "style") - return settings.severity.isEnabled(Severity::style); - return true; // error severity + return false; } CheckersReport::CheckersReport(const Settings& settings, const std::set& activeCheckers) @@ -91,8 +125,7 @@ void CheckersReport::countCheckers() if (mSettings.premiumArgs.find("misra-c-") != std::string::npos || mSettings.addons.count("misra")) { for (const checkers::MisraInfo& info: checkers::misraC2012Rules) { const std::string rule = std::to_string(info.a) + "." + std::to_string(info.b); - const std::string severity = getMisraRuleSeverity(rule); - const bool active = isMisraRuleActive(rule, info.amendment, severity, mSettings); + const bool active = isMisraRuleActive(mActiveCheckers, rule); if (active) ++mActiveCheckersCount; ++mAllCheckersCount; @@ -161,19 +194,27 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const continue; std::string req = checkReq.second; bool active = cppcheckPremium && activeCheckers.count(checker) > 0; - if (req == "warning") - active &= settings.severity.isEnabled(Severity::warning); - else if (req == "style") - active &= settings.severity.isEnabled(Severity::style); - else if (!req.empty()) - active = false; // FIXME: handle req + if (substring == "::") { + if (req == "warning") + active &= settings.severity.isEnabled(Severity::warning); + else if (req == "style") + active &= settings.severity.isEnabled(Severity::style); + else if (req == "portability") + active &= settings.severity.isEnabled(Severity::portability); + else if (!req.empty()) + active = false; // FIXME: handle req + } fout << (active ? "Yes " : "No ") << checker; + if (!cppcheckPremium) { + if (!req.empty()) + req = "premium," + req; + else + req = "premium"; + } if (!req.empty()) - req = "premium," + req; - else - req = "premium"; + req = "require:" + req; if (!active) - fout << std::string(maxCheckerSize + 4 - checker.size(), ' ') << "require:" + req; + fout << std::string(maxCheckerSize + 4 - checker.size(), ' ') << req; fout << std::endl; } }; @@ -202,20 +243,14 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const fout << "------------" << std::endl; for (const checkers::MisraInfo& info: checkers::misraC2012Rules) { const std::string rule = std::to_string(info.a) + "." + std::to_string(info.b); - const std::string severity = getMisraRuleSeverity(rule); - const bool active = isMisraRuleActive(rule, info.amendment, severity, mSettings); - const bool inconclusive = isMisraRuleInconclusive(rule); - fout << (active ? "Yes " : "No ") << rule; + const bool active = isMisraRuleActive(mActiveCheckers, rule); + fout << (active ? "Yes " : "No ") << "Misra C " << misra << ": " << rule; std::string extra; if (misra == 2012 && info.amendment >= 1) extra = " amendment:" + std::to_string(info.amendment); std::string reqs; if (info.amendment >= 3) reqs += ",premium"; - if (severity != "error") - reqs += "," + severity; - if (inconclusive) - reqs += ",inconclusive"; if (!active && !reqs.empty()) extra += " require:" + reqs.substr(1); if (!extra.empty()) @@ -224,7 +259,8 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const } } - reportSection("Misra C++ 2008", mSettings, mActiveCheckers, checkers::premiumCheckers, "Misra C++: "); + reportSection("Misra C++ 2008", mSettings, mActiveCheckers, checkers::premiumCheckers, "Misra C++ 2008: "); + reportSection("Misra C++ 2023", mSettings, mActiveCheckers, checkers::premiumCheckers, "Misra C++ 2023: "); return fout.str(); } diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 171437a20db..939265df200 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3557,7 +3557,7 @@ static const Token *findShadowed(const Scope *scope, const Variable& var, int li void CheckOther::checkShadowVariables() { - if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("shadowVariables")) + if (!mSettings->severity.isEnabled(Severity::style) && !mSettings->isPremiumEnabled("shadowVariable")) return; logChecker("CheckOther::checkShadowVariables"); // style const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();