Skip to content

Commit c128495

Browse files
committed
Fix #14532 (Release 2.20: Update Cppcheck Premium checkers mapping)
1 parent bd33cf5 commit c128495

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

lib/checkersidmapping.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Cppcheck - A tool for static C/C++ code analysis
3-
* Copyright (C) 2007-2025 Cppcheck team.
3+
* Copyright (C) 2007-2026 Cppcheck team.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -41,7 +41,6 @@ std::vector<checkers::IdMapping> checkers::idMappingAutosar{
4141
{"m5-0-17", "comparePointers"},
4242
{"m5-0-18", "comparePointers"},
4343
{"a5-1-4", "returnDanglingLifetime"},
44-
{"a5-2-2", "cstyleCast"},
4544
{"a5-2-5", "arrayIndexOutOfBounds,arrayIndexOutOfBoundsCond,pointerOutOfBounds,pointerOutOfBoundsCond,negativeIndex,arrayIndexThenCheck,bufferAccessOutOfBounds,objectIndex,argumentSize"},
4645
{"m5-3-4", "sizeofFunctionCall"},
4746
{"a5-3-2", "nullPointer,nullPointerRedundantCheck,nullPointerArithmetic,nullPointerArithmeticRedundantCheck,nullPointerDefaultArg"},
@@ -99,13 +98,13 @@ std::vector<checkers::IdMapping> checkers::idMappingCertCpp{
9998
{"CTR51", "eraseDereference"},
10099
{"CTR54", "comparePointers"},
101100
{"CTR55", "containerOutOfBounds"},
102-
{"DCL57", "deallocThrow,exceptThrowInDestructor"},
101+
{"DCL57", "exceptDeallocThrow,exceptThrowInDestructor"},
103102
{"DCL60", "ctuOneDefinitionRuleViolation"},
104103
{"ERR57", "memleak"},
105104
{"EXP52", "sizeofCalculation"},
106105
{"EXP53", "uninitvar,uninitdata,uninitStructMember"},
107106
{"EXP54", "uninitvar,danglingLifetime,danglingReference,danglingTemporaryLifetime,danglingTempReference,returnDanglingLifetime"},
108-
{"EXP61", "danglingLifetime,danglingReference,danglingTemporaryLifetime,danglingTempReference,returnDanglingLifetime"},
107+
{"EXP61", "danglingLifetime,danglingReference,danglingTemporaryLifetime,danglingTempReference,returnDanglingLifetime,useAfterFree"},
109108
{"EXP63", "accessMoved"},
110109
{"FIO50", "IOWithoutPositioning"},
111110
{"MEM50", "deallocuse"},
@@ -124,7 +123,7 @@ std::vector<checkers::IdMapping> checkers::idMappingMisraC{
124123
{"1.1", "syntaxError"},
125124
{"1.3", "error"},
126125
{"2.1", "duplicateBreak,unreachableCode"},
127-
{"2.2", "constStatement,redundantCondition,redundantAssignment,redundantAssignInSwitch,unreadVariable"},
126+
{"2.2", "constStatement,redundantCondition,redundantAssignment,redundantAssignInSwitch,unreadVariable,unusedFunction"},
128127
{"2.6", "unusedLabel"},
129128
{"2.8", "unusedVariable"},
130129
{"5.3", "shadowVariable"},
@@ -168,7 +167,7 @@ std::vector<checkers::IdMapping> checkers::idMappingMisraCpp2008{
168167
{"5-0-16", "pointerOutOfBounds"},
169168
{"5-0-17", "comparePointers"},
170169
{"5-0-18", "comparePointers"},
171-
{"5-2-4", "cstyleCast"},
170+
{"5-2-4", "cstyleCast,dangerousTypeCast"},
172171
{"5-3-4", "sizeofFunctionCall"},
173172
{"5-8-1", "shiftTooManyBits"},
174173
{"6-6-5", "missingReturn"},

lib/checkexceptionsafety.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void CheckExceptionSafety::destructorsError(const Token * const tok, const std::
9595

9696
void CheckExceptionSafety::deallocThrow()
9797
{
98-
if (!mSettings->severity.isEnabled(Severity::warning))
98+
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("exceptDeallocThrow"))
9999
return;
100100

101101
logChecker("CheckExceptionSafety::deallocThrow"); // warning

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ void CheckOther::warningDangerousTypeCast()
415415
// Only valid on C++ code
416416
if (!mTokenizer->isCPP())
417417
return;
418-
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("cstyleCast"))
418+
if (!mSettings->severity.isEnabled(Severity::warning) && !mSettings->isPremiumEnabled("dangerousTypeCast"))
419419
return;
420420

421421
logChecker("CheckOther::warningDangerousTypeCast"); // warning,c++

lib/settings.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ static const std::set<std::string> autosarCheckers{
354354
"bufferAccessOutOfBounds",
355355
"comparePointers",
356356
"constParameter",
357-
"cstyleCast",
358357
"ctuOneDefinitionRuleViolation",
359358
"doubleFree",
360359
"duplInheritedMember",
@@ -466,10 +465,10 @@ static const std::set<std::string> certCppCheckers{
466465
"danglingReference",
467466
"danglingTempReference",
468467
"danglingTemporaryLifetime",
469-
"deallocThrow",
470468
"deallocuse",
471469
"doubleFree",
472470
"eraseDereference",
471+
"exceptDeallocThrow",
473472
"exceptThrowInDestructor",
474473
"initializerList",
475474
"invalidContainer",
@@ -483,6 +482,7 @@ static const std::set<std::string> certCppCheckers{
483482
"uninitStructMember",
484483
"uninitdata",
485484
"uninitvar",
485+
"useAfterFree",
486486
"virtualCallInConstructor",
487487
"virtualDestructor"
488488
};
@@ -524,6 +524,7 @@ static const std::set<std::string> misrac2012Checkers{
524524
"unknownEvaluationOrder",
525525
"unreachableCode",
526526
"unreadVariable",
527+
"unusedFunction",
527528
"unusedLabel",
528529
"unusedVariable",
529530
"useClosedFile",
@@ -567,6 +568,7 @@ static const std::set<std::string> misrac2023Checkers{
567568
"unknownEvaluationOrder",
568569
"unreachableCode",
569570
"unreadVariable",
571+
"unusedFunction",
570572
"unusedLabel",
571573
"unusedVariable",
572574
"useClosedFile",
@@ -610,6 +612,7 @@ static const std::set<std::string> misrac2025Checkers{
610612
"unknownEvaluationOrder",
611613
"unreachableCode",
612614
"unreadVariable",
615+
"unusedFunction",
613616
"unusedLabel",
614617
"unusedVariable",
615618
"useClosedFile",
@@ -623,6 +626,7 @@ static const std::set<std::string> misracpp2008Checkers{
623626
"constVariable",
624627
"cstyleCast",
625628
"ctuOneDefinitionRuleViolation",
629+
"dangerousTypeCast",
626630
"danglingLifetime",
627631
"duplInheritedMember",
628632
"duplicateBreak",

0 commit comments

Comments
 (0)