Skip to content

Commit 8825355

Browse files
committed
Fix Qt property CI checks
1 parent 69effb8 commit 8825355

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ $(libcppdir)/pathmatch.o: lib/pathmatch.cpp lib/config.h lib/path.h lib/pathmatc
642642
$(libcppdir)/platform.o: lib/platform.cpp externals/tinyxml2/tinyxml2.h lib/config.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/utils.h lib/xml.h
643643
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/platform.cpp
644644

645-
$(libcppdir)/preprocessor.o: lib/preprocessor.cpp externals/simplecpp/simplecpp.h lib/checkers.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h
645+
$(libcppdir)/preprocessor.o: lib/preprocessor.cpp externals/simplecpp/simplecpp.h lib/checkers.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/smallvector.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h
646646
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/preprocessor.cpp
647647

648648
$(libcppdir)/programmemory.o: lib/programmemory.cpp lib/astutils.h lib/calculate.h lib/checkers.h lib/config.h lib/errortypes.h lib/infer.h lib/library.h lib/mathlib.h lib/platform.h lib/programmemory.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vfvalue.h

lib/cppcheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
12711271
}
12721272

12731273
const std::set<std::string> exportedFunctions = mSettings.checks.isEnabled(Checks::unusedFunction) ?
1274-
preprocessor.getExportedFunctions() : std::set<std::string>{};
1274+
preprocessor.getExportedFunctions() : std::set<std::string>{};
12751275

12761276
// Macro-only references can differ even when the simplified tokens match.
12771277
if (maxConfigs > 1) {
@@ -1385,7 +1385,7 @@ void CppCheck::internalError(const std::string &filename, const std::string &msg
13851385
//---------------------------------------------------------------------------
13861386

13871387
void CppCheck::checkNormalTokens(const Tokenizer &tokenizer, AnalyzerInformation* analyzerInformation, const std::string& currentConfig,
1388-
const std::set<std::string>& exportedFunctions)
1388+
const std::set<std::string>& exportedFunctions)
13891389
{
13901390
const ProgressReporter progressReporter(mErrorLogger, mSettings.reportProgress, tokenizer.list.getSourceFilePath(), "Run checkers");
13911391

lib/preprocessor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ static std::set<std::string> qtPropertyFunctions(const simplecpp::Token* tok, co
961961
std::set<std::string> functions;
962962
tok = qtPropertyAttributes(tok);
963963
while (tok && tok->str() != ")") {
964-
const std::string attribute = tok->str();
964+
const std::string& attribute = tok->str();
965965
tok = tok->next;
966966
if (attribute == "CONSTANT" || attribute == "FINAL" || attribute == "REQUIRED" ||
967967
attribute == "VIRTUAL" || attribute == "OVERRIDE")
@@ -1040,7 +1040,7 @@ void Preprocessor::readQtAnnotations(simplecpp::TokenList& tokens)
10401040
tok = tok->next;
10411041
continue;
10421042
}
1043-
simplecpp::Token* end = tok->next;
1043+
const simplecpp::Token* end = tok->next;
10441044
unsigned int depth = 0;
10451045
do {
10461046
if (end->str() == "(")

oss-fuzz/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ $(libcppdir)/pathmatch.o: ../lib/pathmatch.cpp ../lib/config.h ../lib/path.h ../
312312
$(libcppdir)/platform.o: ../lib/platform.cpp ../externals/tinyxml2/tinyxml2.h ../lib/config.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/standards.h ../lib/utils.h ../lib/xml.h
313313
$(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/platform.cpp
314314

315-
$(libcppdir)/preprocessor.o: ../lib/preprocessor.cpp ../externals/simplecpp/simplecpp.h ../lib/checkers.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/preprocessor.h ../lib/settings.h ../lib/standards.h ../lib/suppressions.h ../lib/utils.h
315+
$(libcppdir)/preprocessor.o: ../lib/preprocessor.cpp ../externals/simplecpp/simplecpp.h ../lib/checkers.h ../lib/config.h ../lib/errorlogger.h ../lib/errortypes.h ../lib/library.h ../lib/mathlib.h ../lib/path.h ../lib/platform.h ../lib/preprocessor.h ../lib/settings.h ../lib/smallvector.h ../lib/standards.h ../lib/suppressions.h ../lib/templatesimplifier.h ../lib/token.h ../lib/utils.h ../lib/vfvalue.h
316316
$(CXX) ${LIB_FUZZING_ENGINE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/preprocessor.cpp
317317

318318
$(libcppdir)/programmemory.o: ../lib/programmemory.cpp ../lib/astutils.h ../lib/calculate.h ../lib/checkers.h ../lib/config.h ../lib/errortypes.h ../lib/infer.h ../lib/library.h ../lib/mathlib.h ../lib/platform.h ../lib/programmemory.h ../lib/settings.h ../lib/smallvector.h ../lib/sourcelocation.h ../lib/standards.h ../lib/symboldatabase.h ../lib/templatesimplifier.h ../lib/token.h ../lib/tokenlist.h ../lib/utils.h ../lib/valueflow.h ../lib/valueptr.h ../lib/vfvalue.h

test/cli/unused_function_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_unused_functions_qt_property(tmp_path, header, builddir):
8080
(tmp_path / 'build').mkdir()
8181
args += ['--cppcheck-build-dir=' + str(tmp_path / 'build')]
8282
else:
83-
args += ['--no-cppcheck-build-dir']
83+
args += ['-j1', '--no-cppcheck-build-dir']
8484
# Also check the saved whole-program data when the build directory is reused.
8585
for _ in range(2 if builddir else 1):
8686
ret, stdout, stderr = cppcheck(args)
@@ -106,7 +106,7 @@ class MyType {
106106
int main() { MyType t; }
107107
''')
108108
args = ['-q', '--template={id}:{message}', '--enable=unusedFunction',
109-
'--no-cppcheck-build-dir', str(source)]
109+
'-j1', '--no-cppcheck-build-dir', str(source)]
110110
if library:
111111
args += ['--library=qt']
112112
ret, stdout, stderr = cppcheck(args)
@@ -135,7 +135,7 @@ def test_unused_functions_qt_property_configurations(tmp_path):
135135
# Both configurations have identical C++ tokens after Q_PROPERTY is erased.
136136
ret, stdout, stderr = cppcheck(['-q', '--template={id}:{message}',
137137
'--enable=unusedFunction', '--library=qt',
138-
'--no-cppcheck-build-dir', str(source)])
138+
'-j1', '--no-cppcheck-build-dir', str(source)])
139139
assert ret == 0, stdout
140140
assert stdout == ''
141141
assert stderr == "unusedFunction:The function 'unused' is never used.\n"
@@ -168,7 +168,7 @@ class MyType {
168168
.replace('@RETURN_TYPE@', '::READ' if property_type == 'READ' else property_type))
169169
ret, stdout, stderr = cppcheck(['-q', '--template={id}:{message}',
170170
'--enable=unusedFunction', '--library=qt',
171-
'--no-cppcheck-build-dir', str(source)])
171+
'-j1', '--no-cppcheck-build-dir', str(source)])
172172
assert ret == 0, stdout
173173
assert stderr == ("unusedFunction:The function 'property' is never used.\n"
174174
"unusedFunction:The function 'NOTIFY' is never used.\n")
@@ -188,7 +188,7 @@ def test_unused_functions_qt_property_reset_keyword_name(tmp_path):
188188
# The reset method named READ must not be read as another READ attribute.
189189
ret, stdout, stderr = cppcheck(['-q', '--template={id}:{message}',
190190
'--enable=unusedFunction', '--library=qt',
191-
'--no-cppcheck-build-dir', str(source)])
191+
'-j1', '--no-cppcheck-build-dir', str(source)])
192192
assert ret == 0, stdout
193193
assert stderr == "unusedFunction:The function 'property' is never used.\n"
194194

@@ -226,7 +226,7 @@ class MyType {
226226
'''.replace('@ATTRIBUTES@', attributes))
227227
ret, stdout, stderr = cppcheck(['-q', '--template={id}:{message}',
228228
'--enable=unusedFunction', '--library=qt',
229-
'--no-cppcheck-build-dir', str(source)])
229+
'-j1', '--no-cppcheck-build-dir', str(source)])
230230
assert ret == 0, stdout
231231
reported = re.findall(r"unusedFunction:The function '([^']+)' is never used\.", stderr)
232232
assert set(reported) == {'field', 'value', 'setValue', 'resetValue', 'bindValue', 'enabled', 'property'} - set(used)
@@ -261,7 +261,7 @@ class MyType {
261261
'''.replace('@PROPERTY@', invocation))
262262
ret, stdout, stderr = cppcheck(['-q', '--template={id}:{message}',
263263
'--enable=unusedFunction', '--library=qt',
264-
'--no-cppcheck-build-dir', str(source)])
264+
'-j1', '--no-cppcheck-build-dir', str(source)])
265265
assert ret == 0, stdout
266266
assert stderr == "unusedFunction:The function 'property' is never used.\n"
267267

@@ -283,7 +283,7 @@ class MyType {
283283
'''.replace('@PROPERTY@', invocation))
284284
ret, stdout, stderr = cppcheck(['-q', '--template={id}:{message}',
285285
'--enable=unusedFunction', '--library=qt',
286-
'--no-cppcheck-build-dir', str(source)])
286+
'-j1', '--no-cppcheck-build-dir', str(source)])
287287
assert ret == 0, stdout
288288
assert stderr == "unusedFunction:The function 'value' is never used.\n"
289289

@@ -343,7 +343,7 @@ class MyType : public Base {
343343
''')
344344
ret, stdout, stderr = cppcheck(['-q', '--template={id}:{message}',
345345
'--enable=unusedFunction', '--library=qt',
346-
'--no-cppcheck-build-dir', str(source)])
346+
'-j1', '--no-cppcheck-build-dir', str(source)])
347347
assert ret == 0, stdout
348348
assert stderr == "unusedFunction:The function 'unused' is never used.\n"
349349

0 commit comments

Comments
 (0)