Skip to content

Commit 742e8ad

Browse files
committed
avoid some Clang compiler warnings
1 parent df2c8f3 commit 742e8ad

45 files changed

Lines changed: 99 additions & 56 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cli/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ if(USE_BUNDLED_TINYXML2)
1010
endif()
1111
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/)
1212

13+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
14+
# false positive warning in up to Clang 13 - caused by FD_ZERO macro
15+
set_source_files_properties(threadexecutor.cpp PROPERTIES COMPILE_FLAGS -Wno-reserved-identifier)
16+
endif()
17+
1318
list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:lib_objs> $<TARGET_OBJECTS:simplecpp_objs>)
1419
if(USE_BUNDLED_TINYXML2)
1520
list(APPEND cppcheck_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)

cmake/compileroptions.cmake

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
6666
add_compile_options_safe(-Wno-shadow-field-in-constructor)
6767
add_compile_options_safe(-Wno-covered-switch-default)
6868
add_compile_options_safe(-Wno-shorten-64-to-32)
69-
add_compile_options_safe(-Wno-zero-as-null-pointer-constant)
69+
add_compile_options_safe(-Wno-zero-as-null-pointer-constant) # TODO: enable when warnings are fixed in in simplecpp and tinyxml2
7070
add_compile_options_safe(-Wno-format-nonliteral)
7171
add_compile_options_safe(-Wno-implicit-int-conversion)
7272
add_compile_options_safe(-Wno-double-promotion)
@@ -76,21 +76,20 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
7676
add_compile_options_safe(-Wno-implicit-float-conversion)
7777
add_compile_options_safe(-Wno-switch-enum)
7878
add_compile_options_safe(-Wno-float-conversion)
79-
add_compile_options_safe(-Wno-redundant-parens) # caused by Qt moc code
8079
add_compile_options_safe(-Wno-enum-enum-conversion)
8180
add_compile_options_safe(-Wno-date-time)
82-
add_compile_options_safe(-Wno-suggest-override)
83-
add_compile_options_safe(-Wno-suggest-destructor-override)
8481
add_compile_options_safe(-Wno-conditional-uninitialized)
82+
add_compile_options_safe(-Wno-suggest-override) # TODO: enable when warnings are fixed in in tinyxml2
83+
add_compile_options_safe(-Wno-suggest-destructor-override) # TODO: enable when warnings are fixed in in tinyxml2
84+
add_compile_options_safe(-Wno-extra-semi-stmt) # TODO: enable when warnings are fixed in in tinyxml2
85+
add_compile_options(-Wno-disabled-macro-expansion)
8586

8687
# warnings we are not interested in
8788
add_compile_options(-Wno-four-char-constants)
8889
add_compile_options(-Wno-c++98-compat)
8990
add_compile_options(-Wno-weak-vtables)
9091
add_compile_options(-Wno-padded)
9192
add_compile_options(-Wno-c++98-compat-pedantic)
92-
add_compile_options(-Wno-disabled-macro-expansion)
93-
add_compile_options(-Wno-reserved-id-macro)
9493
add_compile_options_safe(-Wno-return-std-move-in-c++11)
9594

9695
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)

externals/simplecpp/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ file(GLOB hdrs "*.h")
22
file(GLOB srcs "*.cpp")
33

44
add_library(simplecpp_objs OBJECT ${srcs} ${hdrs})
5+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
6+
target_compile_options_safe(simplecpp_objs -Wno-zero-as-null-pointer-constant)
7+
endif()

externals/tinyxml2/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ endif()
1010
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1111
target_compile_options_safe(tinyxml2_objs -Wno-extra-semi-stmt)
1212
target_compile_options_safe(tinyxml2_objs -Wno-implicit-fallthrough)
13+
target_compile_options_safe(tinyxml2_objs -Wno-suggest-override)
14+
target_compile_options_safe(tinyxml2_objs -Wno-suggest-destructor-override)
15+
target_compile_options_safe(tinyxml2_objs -Wno-zero-as-null-pointer-constant)
1316
endif()
1417

gui/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ if (BUILD_GUI)
4444
target_link_libraries(cppcheck-gui ${QT_CHARTS_LIB})
4545
endif()
4646
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
47-
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
48-
# Q_UNUSED() in generated code
49-
target_compile_options(cppcheck-gui PRIVATE -Wno-extra-semi-stmt)
50-
endif()
47+
# Q_UNUSED() in generated code
48+
target_compile_options_safe(cppcheck-gui -Wno-extra-semi-stmt)
49+
# caused by Qt generated moc code
50+
target_compile_options_safe(cppcheck-gui -Wno-redundant-parens)
5151
endif()
5252

5353
install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)

gui/applicationdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ApplicationDialog : public QDialog {
4949
ApplicationDialog(const QString &title,
5050
Application &app,
5151
QWidget *parent = nullptr);
52-
virtual ~ApplicationDialog();
52+
~ApplicationDialog() override;
5353

5454
protected slots:
5555

gui/applicationlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ApplicationList : public QObject {
3535
public:
3636

3737
explicit ApplicationList(QObject *parent = nullptr);
38-
virtual ~ApplicationList();
38+
~ApplicationList() override;
3939

4040
/**
4141
* @brief Load all applications

gui/checkthread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CheckThread : public QThread {
3939
Q_OBJECT
4040
public:
4141
explicit CheckThread(ThreadResult &result);
42-
virtual ~CheckThread();
42+
~CheckThread() override;
4343

4444
/**
4545
* @brief Set settings for cppcheck

gui/codeeditor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class CodeEditor : public QPlainTextEdit {
8080
explicit CodeEditor(QWidget *parent);
8181
CodeEditor(const CodeEditor &) = delete;
8282
CodeEditor &operator=(const CodeEditor &) = delete;
83-
~CodeEditor();
83+
~CodeEditor() override;
8484

8585
void lineNumberAreaPaintEvent(QPaintEvent *event);
8686
int lineNumberAreaWidth();

gui/codeeditstylecontrols.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SelectColorButton : public QPushButton {
3131
Q_OBJECT
3232
public:
3333
explicit SelectColorButton(QWidget* parent);
34-
virtual ~SelectColorButton() {}
34+
~SelectColorButton() override {}
3535

3636
void setColor(const QColor& color);
3737
const QColor& getColor();
@@ -52,7 +52,7 @@ class SelectFontWeightCombo : public QComboBox {
5252
Q_OBJECT
5353
public:
5454
explicit SelectFontWeightCombo(QWidget* parent);
55-
virtual ~SelectFontWeightCombo() {}
55+
~SelectFontWeightCombo() override {}
5656

5757
void setWeight(const QFont::Weight& weight);
5858
const QFont::Weight& getWeight();

0 commit comments

Comments
 (0)