From 0d336b868cfa32ef4ce2366c3c2336cb3810e166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 13 Mar 2022 20:07:58 +0100 Subject: [PATCH] avoid some Clang compiler warnings (#3896) --- cli/CMakeLists.txt | 5 +++++ cmake/compileroptions.cmake | 11 +++++------ externals/simplecpp/CMakeLists.txt | 3 +++ externals/tinyxml2/CMakeLists.txt | 3 +++ gui/CMakeLists.txt | 8 ++++---- gui/applicationdialog.h | 2 +- gui/applicationlist.h | 2 +- gui/checkthread.h | 2 +- gui/codeeditor.h | 2 +- gui/codeeditstylecontrols.h | 4 ++-- gui/codeeditstyledialog.h | 2 +- gui/csvreport.h | 2 +- gui/functioncontractdialog.h | 2 +- gui/helpdialog.h | 6 +++--- gui/libraryaddfunctiondialog.h | 2 +- gui/librarydialog.h | 2 +- gui/libraryeditargdialog.h | 2 +- gui/mainwindow.h | 2 +- gui/newsuppressiondialog.h | 2 +- gui/printablereport.h | 2 +- gui/projectfile.h | 2 +- gui/projectfiledialog.h | 2 +- gui/report.h | 2 +- gui/resultstree.h | 2 +- gui/resultsview.h | 4 ++-- gui/settingsdialog.h | 2 +- gui/test/benchmark/simple/CMakeLists.txt | 9 +++++++++ gui/test/cppchecklibrarydata/CMakeLists.txt | 7 ++++++- gui/test/filelist/CMakeLists.txt | 7 ++++++- gui/test/projectfile/CMakeLists.txt | 7 ++++++- gui/test/translationhandler/CMakeLists.txt | 7 ++++++- gui/threadhandler.h | 2 +- gui/threadresult.h | 2 +- gui/translationhandler.h | 2 +- gui/txtreport.h | 2 +- gui/variablecontractsdialog.h | 2 +- gui/xmlreportv2.h | 2 +- lib/checkclass.cpp | 1 + lib/programmemory.cpp | 10 +++++----- lib/programmemory.h | 4 ++-- lib/token.cpp | 1 + lib/valueflow.cpp | 2 +- tools/CMakeLists.txt | 2 +- tools/triage/CMakeLists.txt | 8 ++++---- tools/triage/mainwindow.h | 2 +- 45 files changed, 100 insertions(+), 59 deletions(-) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 731879c46..54b314f61 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -10,6 +10,11 @@ if(USE_BUNDLED_TINYXML2) endif() target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) + # false positive warning in up to Clang 13 - caused by FD_ZERO macro + set_source_files_properties(threadexecutor.cpp PROPERTIES COMPILE_FLAGS -Wno-reserved-identifier) +endif() + list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $ $ $) if(USE_BUNDLED_TINYXML2) list(APPEND cppcheck_SOURCES $) diff --git a/cmake/compileroptions.cmake b/cmake/compileroptions.cmake index c5235f357..cd8cf6b85 100644 --- a/cmake/compileroptions.cmake +++ b/cmake/compileroptions.cmake @@ -66,7 +66,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options_safe(-Wno-shadow-field-in-constructor) add_compile_options_safe(-Wno-covered-switch-default) add_compile_options_safe(-Wno-shorten-64-to-32) - add_compile_options_safe(-Wno-zero-as-null-pointer-constant) + add_compile_options_safe(-Wno-zero-as-null-pointer-constant) # TODO: enable when warnings are fixed in in simplecpp and tinyxml2 add_compile_options_safe(-Wno-format-nonliteral) add_compile_options_safe(-Wno-implicit-int-conversion) add_compile_options_safe(-Wno-double-promotion) @@ -76,12 +76,13 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options_safe(-Wno-implicit-float-conversion) add_compile_options_safe(-Wno-switch-enum) add_compile_options_safe(-Wno-float-conversion) - add_compile_options_safe(-Wno-redundant-parens) # caused by Qt moc code add_compile_options_safe(-Wno-enum-enum-conversion) add_compile_options_safe(-Wno-date-time) - add_compile_options_safe(-Wno-suggest-override) - add_compile_options_safe(-Wno-suggest-destructor-override) add_compile_options_safe(-Wno-conditional-uninitialized) + add_compile_options_safe(-Wno-suggest-override) # TODO: enable when warnings are fixed in in tinyxml2 + add_compile_options_safe(-Wno-suggest-destructor-override) # TODO: enable when warnings are fixed in in tinyxml2 + add_compile_options_safe(-Wno-extra-semi-stmt) # TODO: enable when warnings are fixed in in tinyxml2 + add_compile_options(-Wno-disabled-macro-expansion) # warnings we are not interested in add_compile_options(-Wno-four-char-constants) @@ -89,8 +90,6 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-weak-vtables) add_compile_options(-Wno-padded) add_compile_options(-Wno-c++98-compat-pedantic) - add_compile_options(-Wno-disabled-macro-expansion) - add_compile_options(-Wno-reserved-id-macro) add_compile_options_safe(-Wno-return-std-move-in-c++11) if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML) diff --git a/externals/simplecpp/CMakeLists.txt b/externals/simplecpp/CMakeLists.txt index 8c7df7497..8536a1d6f 100644 --- a/externals/simplecpp/CMakeLists.txt +++ b/externals/simplecpp/CMakeLists.txt @@ -2,3 +2,6 @@ file(GLOB hdrs "*.h") file(GLOB srcs "*.cpp") add_library(simplecpp_objs OBJECT ${srcs} ${hdrs}) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options_safe(simplecpp_objs -Wno-zero-as-null-pointer-constant) +endif() diff --git a/externals/tinyxml2/CMakeLists.txt b/externals/tinyxml2/CMakeLists.txt index e599d40fb..3488143d8 100644 --- a/externals/tinyxml2/CMakeLists.txt +++ b/externals/tinyxml2/CMakeLists.txt @@ -10,5 +10,8 @@ endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options_safe(tinyxml2_objs -Wno-extra-semi-stmt) target_compile_options_safe(tinyxml2_objs -Wno-implicit-fallthrough) + target_compile_options_safe(tinyxml2_objs -Wno-suggest-override) + target_compile_options_safe(tinyxml2_objs -Wno-suggest-destructor-override) + target_compile_options_safe(tinyxml2_objs -Wno-zero-as-null-pointer-constant) endif() diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 13d7b877a..0106d4d76 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -44,10 +44,10 @@ if (BUILD_GUI) target_link_libraries(cppcheck-gui ${QT_CHARTS_LIB}) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") - # Q_UNUSED() in generated code - target_compile_options(cppcheck-gui PRIVATE -Wno-extra-semi-stmt) - endif() + # Q_UNUSED() in generated code + target_compile_options_safe(cppcheck-gui -Wno-extra-semi-stmt) + # caused by Qt generated moc code + target_compile_options_safe(cppcheck-gui -Wno-redundant-parens) endif() install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications) diff --git a/gui/applicationdialog.h b/gui/applicationdialog.h index e05c2edff..e6d55018e 100644 --- a/gui/applicationdialog.h +++ b/gui/applicationdialog.h @@ -49,7 +49,7 @@ public: ApplicationDialog(const QString &title, Application &app, QWidget *parent = nullptr); - virtual ~ApplicationDialog(); + ~ApplicationDialog() override; protected slots: diff --git a/gui/applicationlist.h b/gui/applicationlist.h index 7bf411601..108db3667 100644 --- a/gui/applicationlist.h +++ b/gui/applicationlist.h @@ -35,7 +35,7 @@ class ApplicationList : public QObject { public: explicit ApplicationList(QObject *parent = nullptr); - virtual ~ApplicationList(); + ~ApplicationList() override; /** * @brief Load all applications diff --git a/gui/checkthread.h b/gui/checkthread.h index 1a2e339da..a319b98fe 100644 --- a/gui/checkthread.h +++ b/gui/checkthread.h @@ -39,7 +39,7 @@ class CheckThread : public QThread { Q_OBJECT public: explicit CheckThread(ThreadResult &result); - virtual ~CheckThread(); + ~CheckThread() override; /** * @brief Set settings for cppcheck diff --git a/gui/codeeditor.h b/gui/codeeditor.h index b35bfd309..291e8a7f6 100644 --- a/gui/codeeditor.h +++ b/gui/codeeditor.h @@ -80,7 +80,7 @@ public: explicit CodeEditor(QWidget *parent); CodeEditor(const CodeEditor &) = delete; CodeEditor &operator=(const CodeEditor &) = delete; - ~CodeEditor(); + ~CodeEditor() override; void lineNumberAreaPaintEvent(QPaintEvent *event); int lineNumberAreaWidth(); diff --git a/gui/codeeditstylecontrols.h b/gui/codeeditstylecontrols.h index 8487e6da8..653a526d7 100644 --- a/gui/codeeditstylecontrols.h +++ b/gui/codeeditstylecontrols.h @@ -31,7 +31,7 @@ class SelectColorButton : public QPushButton { Q_OBJECT public: explicit SelectColorButton(QWidget* parent); - virtual ~SelectColorButton() {} + ~SelectColorButton() override {} void setColor(const QColor& color); const QColor& getColor(); @@ -52,7 +52,7 @@ class SelectFontWeightCombo : public QComboBox { Q_OBJECT public: explicit SelectFontWeightCombo(QWidget* parent); - virtual ~SelectFontWeightCombo() {} + ~SelectFontWeightCombo() override {} void setWeight(const QFont::Weight& weight); const QFont::Weight& getWeight(); diff --git a/gui/codeeditstyledialog.h b/gui/codeeditstyledialog.h index fd02b5220..f25a171b3 100644 --- a/gui/codeeditstyledialog.h +++ b/gui/codeeditstyledialog.h @@ -33,7 +33,7 @@ class StyleEditDialog : public QDialog { public: explicit StyleEditDialog(const CodeEditorStyle& newStyle, QWidget *parent = nullptr); - virtual ~StyleEditDialog() {} + ~StyleEditDialog() override {} CodeEditorStyle getStyle(); diff --git a/gui/csvreport.h b/gui/csvreport.h index 3779d673a..388728561 100644 --- a/gui/csvreport.h +++ b/gui/csvreport.h @@ -37,7 +37,7 @@ class CsvReport : public Report { public: explicit CsvReport(const QString &filename); - virtual ~CsvReport(); + ~CsvReport() override; /** * @brief Create the report (file). diff --git a/gui/functioncontractdialog.h b/gui/functioncontractdialog.h index 4c34fa6a5..f67864d09 100644 --- a/gui/functioncontractdialog.h +++ b/gui/functioncontractdialog.h @@ -30,7 +30,7 @@ class FunctionContractDialog : public QDialog { public: explicit FunctionContractDialog(QWidget *parent, const QString &name, const QString &expects); - ~FunctionContractDialog(); + ~FunctionContractDialog() override; QString getExpects() const; private: Ui::FunctionContractDialog *mUi; diff --git a/gui/helpdialog.h b/gui/helpdialog.h index 4a5e6b09c..c4b0dae2b 100644 --- a/gui/helpdialog.h +++ b/gui/helpdialog.h @@ -30,9 +30,9 @@ class QHelpEngine; class HelpBrowser : public QTextBrowser { public: - HelpBrowser(QWidget* parent = 0) : QTextBrowser(parent), mHelpEngine(nullptr) {} + HelpBrowser(QWidget* parent = nullptr) : QTextBrowser(parent), mHelpEngine(nullptr) {} void setHelpEngine(QHelpEngine *helpEngine); - QVariant loadResource(int type, const QUrl& name); + QVariant loadResource(int type, const QUrl& name) override; private: QHelpEngine* mHelpEngine; }; @@ -42,7 +42,7 @@ class HelpDialog : public QDialog { public: explicit HelpDialog(QWidget *parent = nullptr); - ~HelpDialog(); + ~HelpDialog() override; private: Ui::HelpDialog *mUi; diff --git a/gui/libraryaddfunctiondialog.h b/gui/libraryaddfunctiondialog.h index 6d4318224..4cf774ce5 100644 --- a/gui/libraryaddfunctiondialog.h +++ b/gui/libraryaddfunctiondialog.h @@ -35,7 +35,7 @@ class LibraryAddFunctionDialog : public QDialog { public: explicit LibraryAddFunctionDialog(QWidget *parent = nullptr); LibraryAddFunctionDialog(const LibraryAddFunctionDialog &) = delete; - ~LibraryAddFunctionDialog(); + ~LibraryAddFunctionDialog() override; LibraryAddFunctionDialog &operator=(const LibraryAddFunctionDialog &) = delete; QString functionName() const; diff --git a/gui/librarydialog.h b/gui/librarydialog.h index 7b0eb358e..1a5845b35 100644 --- a/gui/librarydialog.h +++ b/gui/librarydialog.h @@ -35,7 +35,7 @@ class LibraryDialog : public QDialog { public: explicit LibraryDialog(QWidget *parent = nullptr); LibraryDialog(const LibraryDialog &) = delete; - ~LibraryDialog(); + ~LibraryDialog() override; LibraryDialog &operator=(const LibraryDialog &) = delete; private slots: diff --git a/gui/libraryeditargdialog.h b/gui/libraryeditargdialog.h index 6e1ad73fb..b61713acd 100644 --- a/gui/libraryeditargdialog.h +++ b/gui/libraryeditargdialog.h @@ -33,7 +33,7 @@ class LibraryEditArgDialog : public QDialog { public: LibraryEditArgDialog(QWidget *parent, const CppcheckLibraryData::Function::Arg &arg); LibraryEditArgDialog(const LibraryEditArgDialog &) = delete; - ~LibraryEditArgDialog(); + ~LibraryEditArgDialog() override; LibraryEditArgDialog &operator=(const LibraryEditArgDialog &) = delete; CppcheckLibraryData::Function::Arg getArg() const; diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 0ebc13d5f..4c5d3ae57 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -55,7 +55,7 @@ public: MainWindow(TranslationHandler* th, QSettings* settings); MainWindow(const MainWindow &) = delete; - virtual ~MainWindow(); + ~MainWindow() override; MainWindow &operator=(const MainWindow &) = delete; /** diff --git a/gui/newsuppressiondialog.h b/gui/newsuppressiondialog.h index d06fcdc98..1204525df 100644 --- a/gui/newsuppressiondialog.h +++ b/gui/newsuppressiondialog.h @@ -33,7 +33,7 @@ class NewSuppressionDialog : public QDialog { public: explicit NewSuppressionDialog(QWidget *parent = nullptr); NewSuppressionDialog(const NewSuppressionDialog &) = delete; - ~NewSuppressionDialog(); + ~NewSuppressionDialog() override; NewSuppressionDialog &operator=(const NewSuppressionDialog &) = delete; /** diff --git a/gui/printablereport.h b/gui/printablereport.h index 5293f3f8e..45d073ac4 100644 --- a/gui/printablereport.h +++ b/gui/printablereport.h @@ -32,7 +32,7 @@ class PrintableReport : public Report { public: PrintableReport(); - virtual ~PrintableReport(); + ~PrintableReport() override; /** * @brief Create the report (file). diff --git a/gui/projectfile.h b/gui/projectfile.h index 8805042aa..5d14d8e62 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -46,7 +46,7 @@ class ProjectFile : public QObject { public: explicit ProjectFile(QObject *parent = nullptr); explicit ProjectFile(const QString &filename, QObject *parent = nullptr); - ~ProjectFile() { + ~ProjectFile() override { if (this == mActiveProject) mActiveProject = nullptr; } diff --git a/gui/projectfiledialog.h b/gui/projectfiledialog.h index f0a6c7c5b..e8aa10970 100644 --- a/gui/projectfiledialog.h +++ b/gui/projectfiledialog.h @@ -42,7 +42,7 @@ class ProjectFileDialog : public QDialog { Q_OBJECT public: explicit ProjectFileDialog(ProjectFile *projectFile, QWidget *parent = nullptr); - virtual ~ProjectFileDialog(); + ~ProjectFileDialog() override; private: void loadFromProjectFile(const ProjectFile *projectFile); diff --git a/gui/report.h b/gui/report.h index efb000db0..1ec336e51 100644 --- a/gui/report.h +++ b/gui/report.h @@ -40,7 +40,7 @@ public: }; explicit Report(const QString &filename); - virtual ~Report(); + ~Report() override; /** * @brief Create the report (file). diff --git a/gui/resultstree.h b/gui/resultstree.h index a70f9774c..75cc122d0 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -49,7 +49,7 @@ class ResultsTree : public QTreeView { Q_OBJECT public: explicit ResultsTree(QWidget * parent = nullptr); - virtual ~ResultsTree(); + ~ResultsTree() override; void initialize(QSettings *settings, ApplicationList *list, ThreadHandler *checkThreadHandler); /** diff --git a/gui/resultsview.h b/gui/resultsview.h index 5d7b4570d..6834587f1 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -46,7 +46,7 @@ public: explicit ResultsView(QWidget * parent = nullptr); void initialize(QSettings *settings, ApplicationList *list, ThreadHandler *checkThreadHandler); ResultsView(const ResultsView &) = delete; - virtual ~ResultsView(); + ~ResultsView() override; ResultsView &operator=(const ResultsView &) = delete; void setAddedFunctionContracts(const QStringList &addedContracts); @@ -372,7 +372,7 @@ protected: CheckStatistics *mStatistics; - bool eventFilter(QObject *target, QEvent *event); + bool eventFilter(QObject *target, QEvent *event) override; private slots: /** * @brief Custom context menu for Analysis Log diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h index 9f8549775..489f9c52b 100644 --- a/gui/settingsdialog.h +++ b/gui/settingsdialog.h @@ -44,7 +44,7 @@ public: TranslationHandler *translator, QWidget *parent = nullptr); SettingsDialog(const SettingsDialog &) = delete; - virtual ~SettingsDialog(); + ~SettingsDialog() override; SettingsDialog &operator=(const SettingsDialog &) = delete; /** diff --git a/gui/test/benchmark/simple/CMakeLists.txt b/gui/test/benchmark/simple/CMakeLists.txt index 6bc1222cc..933a10a29 100644 --- a/gui/test/benchmark/simple/CMakeLists.txt +++ b/gui/test/benchmark/simple/CMakeLists.txt @@ -21,4 +21,13 @@ if (USE_Z3) endif() if(tinyxml2_FOUND AND NOT USE_BUNDLED_TINYXML2) target_link_libraries(benchmark-simple ${tinyxml2_LIBRARY}) +endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) + # false positive in up to CLang 13 - caused by QBENCHMARK macro + set_source_files_properties(benchmarksimple.cpp PROPERTIES COMPILE_FLAGS -Wno-reserved-identifier) + endif() + # caused by Q_UNUSED macro + set_source_files_properties(moc_benchmarksimple.cpp PROPERTIES COMPILE_FLAGS -Wno-extra-semi-stmt) endif() \ No newline at end of file diff --git a/gui/test/cppchecklibrarydata/CMakeLists.txt b/gui/test/cppchecklibrarydata/CMakeLists.txt index 9569e8017..2790788b0 100644 --- a/gui/test/cppchecklibrarydata/CMakeLists.txt +++ b/gui/test/cppchecklibrarydata/CMakeLists.txt @@ -7,4 +7,9 @@ add_executable(test-cppchecklibrarydata ${CMAKE_SOURCE_DIR}/gui/cppchecklibrarydata.cpp ) target_include_directories(test-cppchecklibrarydata PRIVATE ${CMAKE_SOURCE_DIR}/gui) -target_link_libraries(test-cppchecklibrarydata ${QT_CORE_LIB} ${QT_TEST_LIB}) \ No newline at end of file +target_link_libraries(test-cppchecklibrarydata ${QT_CORE_LIB} ${QT_TEST_LIB}) + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Q_UNUSED() in generated code + target_compile_options_safe(test-cppchecklibrarydata -Wno-extra-semi-stmt) +endif() \ No newline at end of file diff --git a/gui/test/filelist/CMakeLists.txt b/gui/test/filelist/CMakeLists.txt index 315e9954c..781629e05 100644 --- a/gui/test/filelist/CMakeLists.txt +++ b/gui/test/filelist/CMakeLists.txt @@ -12,4 +12,9 @@ add_executable(test-filelist ) target_include_directories(test-filelist PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/externals/simplecpp) target_compile_definitions(test-filelist PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") -target_link_libraries(test-filelist ${QT_CORE_LIB} ${QT_TEST_LIB}) \ No newline at end of file +target_link_libraries(test-filelist ${QT_CORE_LIB} ${QT_TEST_LIB}) + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Q_UNUSED() in generated code + target_compile_options_safe(test-filelist -Wno-extra-semi-stmt) +endif() \ No newline at end of file diff --git a/gui/test/projectfile/CMakeLists.txt b/gui/test/projectfile/CMakeLists.txt index 3947aef51..baba41718 100644 --- a/gui/test/projectfile/CMakeLists.txt +++ b/gui/test/projectfile/CMakeLists.txt @@ -8,4 +8,9 @@ add_executable(test-projectfile ) target_include_directories(test-projectfile PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib) target_compile_definitions(test-projectfile PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") -target_link_libraries(test-projectfile ${QT_CORE_LIB} ${QT_TEST_LIB}) \ No newline at end of file +target_link_libraries(test-projectfile ${QT_CORE_LIB} ${QT_TEST_LIB}) + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Q_UNUSED() in generated code + target_compile_options_safe(test-projectfile -Wno-extra-semi-stmt) +endif() \ No newline at end of file diff --git a/gui/test/translationhandler/CMakeLists.txt b/gui/test/translationhandler/CMakeLists.txt index 0aadbe702..77b1e4168 100644 --- a/gui/test/translationhandler/CMakeLists.txt +++ b/gui/test/translationhandler/CMakeLists.txt @@ -8,4 +8,9 @@ add_executable(test-translationhandler ${CMAKE_SOURCE_DIR}/gui/translationhandler.cpp ) target_include_directories(test-translationhandler PRIVATE ${CMAKE_SOURCE_DIR}/gui) -target_link_libraries(test-translationhandler ${QT_CORE_LIB} ${QT_WIDGETS_LIB} ${QT_TEST_LIB}) \ No newline at end of file +target_link_libraries(test-translationhandler ${QT_CORE_LIB} ${QT_WIDGETS_LIB} ${QT_TEST_LIB}) + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Q_UNUSED() in generated code + target_compile_options_safe(test-projectfile -Wno-extra-semi-stmt) +endif() \ No newline at end of file diff --git a/gui/threadhandler.h b/gui/threadhandler.h index b2c2c6cf7..95b4591e9 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -48,7 +48,7 @@ class ThreadHandler : public QObject { Q_OBJECT public: explicit ThreadHandler(QObject *parent = nullptr); - virtual ~ThreadHandler(); + ~ThreadHandler() override; /** * @brief Set the number of threads to use diff --git a/gui/threadresult.h b/gui/threadresult.h index 8b0fb9903..79e3557f0 100644 --- a/gui/threadresult.h +++ b/gui/threadresult.h @@ -41,7 +41,7 @@ class ThreadResult : public QObject, public ErrorLogger { Q_OBJECT public: ThreadResult(); - virtual ~ThreadResult(); + ~ThreadResult() override; /** * @brief Get next unprocessed file diff --git a/gui/translationhandler.h b/gui/translationhandler.h index 4cc4eea6e..3d2af86ae 100644 --- a/gui/translationhandler.h +++ b/gui/translationhandler.h @@ -62,7 +62,7 @@ class TranslationHandler : QObject { Q_OBJECT public: explicit TranslationHandler(QObject *parent = nullptr); - virtual ~TranslationHandler(); + ~TranslationHandler() override; /** * @brief Get a list of available translations. diff --git a/gui/txtreport.h b/gui/txtreport.h index 1ced50fad..8bb195d43 100644 --- a/gui/txtreport.h +++ b/gui/txtreport.h @@ -37,7 +37,7 @@ class TxtReport : public Report { public: explicit TxtReport(const QString &filename); - virtual ~TxtReport(); + ~TxtReport() override; /** * @brief Create the report (file). diff --git a/gui/variablecontractsdialog.h b/gui/variablecontractsdialog.h index 2bcfdb748..419caaef6 100644 --- a/gui/variablecontractsdialog.h +++ b/gui/variablecontractsdialog.h @@ -30,7 +30,7 @@ class VariableContractsDialog : public QDialog { public: explicit VariableContractsDialog(QWidget *parent, QString var); - ~VariableContractsDialog(); + ~VariableContractsDialog() override; QString getVarname() const; QString getMin() const; diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h index ce40825d0..8e9afcf4b 100644 --- a/gui/xmlreportv2.h +++ b/gui/xmlreportv2.h @@ -38,7 +38,7 @@ class QXmlStreamWriter; class XmlReportV2 : public XmlReport { public: explicit XmlReportV2(const QString &filename); - virtual ~XmlReportV2(); + ~XmlReportV2() override; /** * @brief Create the report (file). diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 728e2a306..e4cd3842f 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -88,6 +88,7 @@ static bool isVariableCopyNeeded(const Variable &var, Function::Type type) switch (type) { case Function::eOperatorEqual: isOpEqual = true; + break; case Function::eCopyConstructor: case Function::eMoveConstructor: break; diff --git a/lib/programmemory.cpp b/lib/programmemory.cpp index a577d7020..ed461deb1 100644 --- a/lib/programmemory.cpp +++ b/lib/programmemory.cpp @@ -180,11 +180,11 @@ void ProgramMemory::insert(const ProgramMemory &pm) mValues.insert(p); } -bool evaluateCondition(const std::string& op, - MathLib::bigint r, - const Token* condition, - ProgramMemory& pm, - const Settings* settings) +static bool evaluateCondition(const std::string& op, + MathLib::bigint r, + const Token* condition, + ProgramMemory& pm, + const Settings* settings) { if (!condition) return false; diff --git a/lib/programmemory.h b/lib/programmemory.h index bb1ef9869..f873f3f0f 100644 --- a/lib/programmemory.h +++ b/lib/programmemory.h @@ -147,14 +147,14 @@ void execute(const Token* expr, /** * Is condition always false when variable has given value? * \param condition top ast token in condition - * \param programMemory program memory + * \param pm program memory */ bool conditionIsFalse(const Token* condition, ProgramMemory pm, const Settings* settings = nullptr); /** * Is condition always true when variable has given value? * \param condition top ast token in condition - * \param programMemory program memory + * \param pm program memory */ bool conditionIsTrue(const Token* condition, ProgramMemory pm, const Settings* settings = nullptr); diff --git a/lib/token.cpp b/lib/token.cpp index fea57dfa1..b6be36318 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -2065,6 +2065,7 @@ static void mergeAdjacent(std::list& values) continue; } std::sort(adjValues.begin(), adjValues.end(), [&values](ValueIterator xx, ValueIterator yy) { + (void)values; assert(xx != values.end() && yy != values.end()); return xx->compareValue(*yy, ValueFlow::less{}); }); diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index c1d426102..b23993e74 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3741,7 +3741,7 @@ struct LifetimeStore { // Don't add the value a second time if (std::find(tok->values().begin(), tok->values().end(), value) != tok->values().end()) continue; - ; + setTokenValue(tok, value, tokenlist->getSettings()); update = true; } diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 100f9a9ed..e6151e96f 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -14,7 +14,7 @@ add_executable(dmake EXCLUDE_FROM_ALL ${CMAKE_SOURCE_DIR}/cli/filelister.cpp ${srcs_tools} ${CMAKE_SOURCE_DIR}/lib/utils.cpp - ${CMAKE_SOURCE_DIR}/externals/simplecpp/simplecpp.cpp + $ ) target_include_directories(dmake PRIVATE ${CMAKE_SOURCE_DIR}/cli ${CMAKE_SOURCE_DIR}/lib ${CMAKE_SOURCE_DIR}/externals/simplecpp) if (WIN32 AND NOT BORLAND) diff --git a/tools/triage/CMakeLists.txt b/tools/triage/CMakeLists.txt index 286b43ec7..32be7cf4d 100644 --- a/tools/triage/CMakeLists.txt +++ b/tools/triage/CMakeLists.txt @@ -24,9 +24,9 @@ if (BUILD_GUI AND BUILD_TESTS) target_include_directories(triage PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/gui/) target_link_libraries(triage ${QT_CORE_LIB} ${QT_GUI_LIB} ${QT_WIDGETS_LIB}) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") - # Q_UNUSED() in generated code - target_compile_options(triage PRIVATE -Wno-extra-semi-stmt) - endif() + # Q_UNUSED() in generated code + target_compile_options_safe(triage -Wno-extra-semi-stmt) + # caused by Qt generated moc code + target_compile_options_safe(triage -Wno-redundant-parens) endif() endif() diff --git a/tools/triage/mainwindow.h b/tools/triage/mainwindow.h index 7f9099864..429ed6120 100644 --- a/tools/triage/mainwindow.h +++ b/tools/triage/mainwindow.h @@ -36,7 +36,7 @@ public: explicit MainWindow(QWidget *parent = nullptr); MainWindow(const MainWindow &) = delete; MainWindow &operator=(const MainWindow &) = delete; - ~MainWindow(); + ~MainWindow() override; public slots: void loadFile();