Skip to content

Commit f246178

Browse files
authored
added xml.h wrapper for TinyXML2 / cleaned up suppressions of Clang compiler warnings (#5700)
1 parent 42a64d4 commit f246178

25 files changed

Lines changed: 125 additions & 81 deletions

Makefile

Lines changed: 16 additions & 16 deletions
Large diffs are not rendered by default.

cli/cmdlineparser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
#ifdef HAVE_RULES
5858
// xml is used for rules
59-
#include <tinyxml2.h>
59+
#include "xml.h"
6060
#endif
6161

6262
static bool addFilesToList(const std::string& fileList, std::vector<std::string>& pathNames)

cmake/compileroptions.cmake

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -80,53 +80,48 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
8080
add_link_options(-lc++)
8181
endif()
8282

83-
# TODO: fix and enable these warnings - or move to suppression list below
83+
# TODO: fix and enable these warnings - or move to suppression list below
8484
add_compile_options_safe(-Wno-documentation-unknown-command) # TODO: Clang currently does not support all commands
85-
add_compile_options_safe(-Wno-inconsistent-missing-destructor-override) # caused by Qt moc code
86-
add_compile_options_safe(-Wno-unused-exception-parameter)
87-
add_compile_options_safe(-Wno-old-style-cast)
88-
add_compile_options_safe(-Wno-sign-conversion)
89-
add_compile_options_safe(-Wno-shadow-field-in-constructor)
90-
add_compile_options_safe(-Wno-covered-switch-default)
91-
add_compile_options_safe(-Wno-shorten-64-to-32)
92-
add_compile_options_safe(-Wno-zero-as-null-pointer-constant) # TODO: enable when warnings are fixed in in simplecpp and tinyxml2
93-
add_compile_options_safe(-Wno-implicit-int-conversion)
94-
add_compile_options_safe(-Wno-double-promotion)
95-
add_compile_options_safe(-Wno-shadow-field)
96-
add_compile_options_safe(-Wno-shadow-uncaptured-local)
97-
add_compile_options_safe(-Wno-implicit-float-conversion)
98-
add_compile_options_safe(-Wno-switch-enum)
99-
add_compile_options_safe(-Wno-float-conversion)
100-
add_compile_options_safe(-Wno-enum-enum-conversion)
101-
add_compile_options_safe(-Wno-date-time)
102-
add_compile_options_safe(-Wno-suggest-override) # TODO: enable when warnings are fixed in in tinyxml2
103-
add_compile_options_safe(-Wno-suggest-destructor-override) # TODO: enable when warnings are fixed in in tinyxml2
104-
add_compile_options_safe(-Wno-extra-semi-stmt) # TODO: enable when warnings are fixed in in tinyxml2
105-
add_compile_options(-Wno-disabled-macro-expansion)
106-
add_compile_options_safe(-Wno-bitwise-instead-of-logical)
107-
108-
# these cannot be fixed properly without adopting later C++ standards
109-
add_compile_options_safe(-Wno-unsafe-buffer-usage)
110-
add_compile_options_safe(-Wno-global-constructors)
111-
add_compile_options_safe(-Wno-exit-time-destructors)
112-
113-
# can only be partially addressed
114-
add_compile_options(-Wno-padded)
115-
116-
# no need for C++98 compatibility
117-
add_compile_options(-Wno-c++98-compat)
118-
add_compile_options(-Wno-c++98-compat-pedantic)
119-
120-
# only need to be addressed to work around issues in older compilers
121-
add_compile_options_safe(-Wno-return-std-move-in-c++11)
85+
add_compile_options_safe(-Wno-unused-exception-parameter)
86+
add_compile_options_safe(-Wno-old-style-cast)
87+
add_compile_options_safe(-Wno-sign-conversion)
88+
add_compile_options_safe(-Wno-shadow-field-in-constructor)
89+
add_compile_options_safe(-Wno-covered-switch-default)
90+
add_compile_options_safe(-Wno-shorten-64-to-32)
91+
add_compile_options_safe(-Wno-implicit-int-conversion)
92+
add_compile_options_safe(-Wno-double-promotion)
93+
add_compile_options_safe(-Wno-shadow-field)
94+
add_compile_options_safe(-Wno-shadow-uncaptured-local)
95+
add_compile_options_safe(-Wno-implicit-float-conversion)
96+
add_compile_options_safe(-Wno-switch-enum)
97+
add_compile_options_safe(-Wno-float-conversion)
98+
add_compile_options_safe(-Wno-enum-enum-conversion)
99+
add_compile_options_safe(-Wno-date-time)
100+
add_compile_options(-Wno-disabled-macro-expansion)
101+
add_compile_options_safe(-Wno-bitwise-instead-of-logical)
102+
103+
# these cannot be fixed properly without adopting later C++ standards
104+
add_compile_options_safe(-Wno-unsafe-buffer-usage)
105+
add_compile_options_safe(-Wno-global-constructors)
106+
add_compile_options_safe(-Wno-exit-time-destructors)
107+
108+
# can only be partially addressed
109+
add_compile_options(-Wno-padded)
110+
111+
# no need for C++98 compatibility
112+
add_compile_options(-Wno-c++98-compat)
113+
add_compile_options(-Wno-c++98-compat-pedantic)
114+
115+
# only needs to be addressed to work around issues in older compilers
116+
add_compile_options_safe(-Wno-return-std-move-in-c++11)
122117

123118
# warnings we are currently not interested in
124-
add_compile_options(-Wno-four-char-constants)
125-
add_compile_options(-Wno-weak-vtables)
119+
add_compile_options(-Wno-four-char-constants)
120+
add_compile_options(-Wno-weak-vtables)
126121

127-
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
122+
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
128123
message(FATAL_ERROR "Do not use clang to generate code coverage. Use GCC instead.")
129-
endif()
124+
endif()
130125
endif()
131126

132127
if (MSVC)

gui/test/xmlreportv2/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ if (BUILD_CORE_DLL)
2828
target_compile_definitions(test-xmlreportv2 PRIVATE CPPCHECKLIB_IMPORT TINYXML2_IMPORT)
2929
target_link_libraries(test-xmlreportv2 cppcheck-core)
3030
endif()
31+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
32+
target_compile_options_safe(test-xmlreportv2 -Wno-extra-semi-stmt)
33+
endif()
3134

3235
if (REGISTER_GUI_TESTS)
3336
add_test(NAME test-xmlreportv2 COMMAND $<TARGET_FILE:test-xmlreportv2>)

lib/analyzerinfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
#include "path.h"
2424
#include "utils.h"
2525

26-
#include <tinyxml2.h>
2726
#include <cstring>
2827
#include <map>
2928
#include <sstream> // IWYU pragma: keep
3029

30+
#include "xml.h"
31+
3132
AnalyzerInformation::~AnalyzerInformation()
3233
{
3334
close();

lib/checkbufferoverrun.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
#include <iterator>
4141
#include <numeric> // std::accumulate
4242
#include <sstream>
43-
#include <tinyxml2.h>
43+
44+
#include "xml.h"
4445

4546
//---------------------------------------------------------------------------
4647

lib/checkclass.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include <utility>
3939
#include <unordered_map>
4040

41-
#include <tinyxml2.h>
41+
#include "xml.h"
4242

4343
namespace CTU {
4444
class FileInfo;
@@ -2523,14 +2523,15 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, Member
25232523
((lastVarTok->valueType()->container->getYield(end->str()) == Library::Container::Yield::START_ITERATOR) ||
25242524
(lastVarTok->valueType()->container->getYield(end->str()) == Library::Container::Yield::END_ITERATOR))
25252525
&& (tok1->previous()->isComparisonOp() ||
2526-
(tok1->previous()->isAssignmentOp() && tok1->tokAt(-2)->variable() && Token::Match(tok1->tokAt(-2)->variable()->typeEndToken(), "const_iterator|const_reverse_iterator")))))
2527-
;
2526+
(tok1->previous()->isAssignmentOp() && tok1->tokAt(-2)->variable() && Token::Match(tok1->tokAt(-2)->variable()->typeEndToken(), "const_iterator|const_reverse_iterator"))))) {
2527+
// empty body
2528+
}
25282529
else if (var->smartPointerType() && var->smartPointerType()->classScope && isConstMemberFunc(var->smartPointerType()->classScope, end)) {
2529-
;
2530+
// empty body
25302531
} else if (var->isSmartPointer() && Token::simpleMatch(tok1->next(), ".") && tok1->next()->originalName().empty() && mSettings->library.isFunctionConst(end)) {
2531-
;
2532+
// empty body
25322533
} else if (hasOverloadedMemberAccess(end, var->typeScope())) {
2533-
;
2534+
// empty body
25342535
} else if (!var->typeScope() || (end->function() != func && !isConstMemberFunc(var->typeScope(), end))) {
25352536
if (!mSettings->library.isFunctionConst(end))
25362537
return false;

lib/checkmemoryleak.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable* const vari
753753
deallocated = true;
754754
break;
755755
}
756-
};
756+
}
757757

758758
return deallocated;
759759
};

lib/checkunusedfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <utility>
4242
#include <vector>
4343

44-
#include <tinyxml2.h>
44+
#include "xml.h"
4545

4646
namespace CTU {
4747
class FileInfo;

lib/cppcheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
#include <simplecpp.h>
7272

73-
#include <tinyxml2.h>
73+
#include "xml.h"
7474

7575
#ifdef HAVE_RULES
7676
#ifdef _WIN32

0 commit comments

Comments
 (0)