Skip to content

Commit 6802050

Browse files
authored
Fix #12412 (CI: Update Cppcheck Premium to 24.2.0) (#5946)
1 parent faaabb1 commit 6802050

File tree

5 files changed

+53
-8
lines changed

5 files changed

+53
-8
lines changed

Diff for: .github/workflows/cppcheck-premium.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ jobs:
1919
runs-on: ubuntu-22.04 # run on the latest image only
2020

2121
env:
22-
PREMIUM_VERSION: 23.12.0
22+
PREMIUM_VERSION: 24.2.0
2323

2424
steps:
2525
- uses: actions/checkout@v3
2626

2727
- name: Download cppcheckpremium
2828
run: |
2929
wget https://files.cppchecksolutions.com/${{ env.PREMIUM_VERSION }}/ubuntu-22.04/cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz
30-
#wget https://files.cppchecksolutions.com/cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz
3130
tar xzf cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz
3231
3332
- name: Generate a license file

Diff for: cppcheckpremium-suppressions

+44-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ useStlAlgorithm
1515
premium-cert-dcl51-cpp
1616

1717
# TODO: Is there unsafe allocations, in case of exceptions) in cppcheck
18-
premium-cert-err58-cpp
19-
2018
# we have global objects
2119
premium-cert-err58-cpp
2220

@@ -42,6 +40,9 @@ premium-misra-cpp-2008-0-1-12
4240
# we sometimes don't care about return value from functions
4341
premium-misra-cpp-2008-0-1-7
4442

43+
# c++11
44+
premium-misra-cpp-2008-1-0-1
45+
4546
# TODO: can we prevent commented out code?
4647
premium-misra-cpp-2008-2-7-2
4748
premium-misra-cpp-2008-2-7-3
@@ -52,6 +53,9 @@ premium-misra-cpp-2008-2-10-1
5253
# objects of a class often has the lowercase name of the class.
5354
premium-misra-cpp-2008-2-10-4
5455

56+
# no suffix on numeric literals
57+
premium-misra-cpp-2008-2-13-3
58+
5559
# flag |= ..
5660
premium-misra-cpp-2008-4-5-1
5761

@@ -76,6 +80,9 @@ premium-misra-cpp-2008-5-0-11
7680
# conversion of char-to-int is intentional sometimes
7781
premium-misra-cpp-2008-5-0-12
7882

83+
# pointer-to-bool conversion in condition
84+
premium-misra-cpp-2008-5-0-13
85+
7986
# pointer-to-bool conversion is common
8087
premium-misra-cpp-2008-5-0-14
8188

@@ -106,9 +113,30 @@ premium-misra-cpp-2008-5-2-12
106113
# we write !pointer by intention
107114
premium-misra-cpp-2008-5-3-1
108115

116+
# side effects in conditional code is intentional
117+
premium-misra-cpp-2008-5-14-1
118+
119+
# intentional use of comma operator in variable declarations
120+
premium-misra-cpp-2008-5-18-1
121+
122+
# nested assignments are intentional
123+
premium-misra-cpp-2008-6-2-1
124+
109125
# for (;;)
110126
premium-misra-cpp-2008-6-2-3
111127

128+
# we don't always use braces for single statement loop/switch bodies
129+
premium-misra-cpp-2008-6-3-1
130+
131+
# we don't always use braces for single statement if/else
132+
premium-misra-cpp-2008-6-4-1
133+
134+
# we do not require a final else
135+
premium-misra-cpp-2008-6-4-2
136+
137+
# return in case
138+
premium-misra-cpp-2008-6-4-5
139+
112140
# it's not a bug to not put default at the end of a switch body
113141
premium-misra-cpp-2008-6-4-6
114142

@@ -143,15 +171,24 @@ premium-misra-cpp-2008-8-5-3
143171
# TODO Fix these
144172
premium-misra-cpp-2008-9-3-1
145173

174+
# returning non-const pointer/reference from method that is non-const
175+
premium-misra-cpp-2008-9-3-2
176+
146177
# we use unions by intention sometimes
147178
premium-misra-cpp-2008-9-5-1
148179

149180
# overridden methods is safe
150181
premium-misra-cpp-2008-10-3-1
151182

183+
# use override/final
184+
premium-misra-cpp-2008-10-3-2
185+
152186
# some classes have public members by intention
153187
premium-misra-cpp-2008-11-0-1
154188

189+
# intentional: clang-tidy warns for redundant base class initializations
190+
premium-misra-cpp-2008-12-1-2
191+
155192
# rule should not apply to deleted copy assignment operator
156193
premium-misra-cpp-2008-12-8-2
157194

@@ -161,8 +198,13 @@ premium-misra-cpp-2008-14-6-2
161198
# function specializations: TODO check if we should refactor
162199
premium-misra-cpp-2008-14-8-2
163200

201+
# we throw a pointer by intention
202+
premium-misra-cpp-2008-15-0-2
203+
premium-misra-cpp-2008-15-3-5
204+
164205
# we use preprocessor when it makes sense
165206
premium-misra-cpp-2008-16-0-1
207+
premium-misra-cpp-2008-16-0-7
166208
premium-misra-cpp-2008-16-2-1
167209
premium-misra-cpp-2008-16-2-2
168210
premium-misra-cpp-2008-16-3-2

Diff for: lib/cppcheck.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ static void createDumpFile(const Settings& settings,
195195
language = " language=\"cpp\"";
196196
break;
197197
case Standards::Language::None:
198+
{
198199
// TODO: error out on unknown language?
199200
const Standards::Language lang = Path::identify(filename);
200201
if (lang == Standards::Language::CPP)
@@ -203,6 +204,7 @@ static void createDumpFile(const Settings& settings,
203204
language = " language=\"c\"";
204205
break;
205206
}
207+
}
206208

207209
fdump << "<?xml version=\"1.0\"?>\n";
208210
fdump << "<dumps" << language << ">\n";

Diff for: lib/valueflow.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ static void bailoutInternal(const std::string& type, const TokenList &tokenlist,
138138
errorLogger->reportErr(errmsg);
139139
}
140140

141-
#define bailout2(type, tokenlist, errorLogger, tok, what) bailoutInternal(type, tokenlist, errorLogger, tok, what, __FILE__, __LINE__, __func__)
141+
#define bailout2(type, tokenlist, errorLogger, tok, what) bailoutInternal((type), (tokenlist), (errorLogger), (tok), (what), __FILE__, __LINE__, __func__)
142142

143-
#define bailout(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailout", tokenlist, errorLogger, tok, what)
143+
#define bailout(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailout", (tokenlist), (errorLogger), (tok), (what))
144144

145-
#define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) bailoutInternal("valueFlowBailoutIncompleteVar", tokenlist, errorLogger, tok, what, "", 0, __func__)
145+
#define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) bailoutInternal("valueFlowBailoutIncompleteVar", (tokenlist), (errorLogger), (tok), (what), "", 0, __func__)
146146

147147
static std::string debugString(const ValueFlow::Value& v)
148148
{
@@ -9500,7 +9500,7 @@ static ValueFlowPassAdaptor<F> makeValueFlowPassAdaptor(const char* name, bool c
95009500

95019501
#define VALUEFLOW_ADAPTOR(cpp, ...) \
95029502
makeValueFlowPassAdaptor(#__VA_ARGS__, \
9503-
cpp, \
9503+
(cpp), \
95049504
[](TokenList& tokenlist, \
95059505
SymbolDatabase& symboldatabase, \
95069506
ErrorLogger* errorLogger, \

Diff for: lib/vfvalue.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ namespace ValueFlow {
115115
case ValueType::LIFETIME:
116116
return "lifetime=" + tokvalue->str();
117117
case ValueType::SYMBOLIC:
118+
{
118119
std::string result = "symbolic=" + tokvalue->expressionString();
119120
if (intvalue > 0)
120121
result += "+" + std::to_string(intvalue);
121122
else if (intvalue < 0)
122123
result += "-" + std::to_string(-intvalue);
123124
return result;
124125
}
126+
}
125127
throw InternalError(nullptr, "Invalid ValueFlow Value type");
126128
}
127129

0 commit comments

Comments
 (0)