Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 1cc365c

Browse files
authored
Cyphers/lastwarns (#3640)
* Build changes for -Wall * Use properties * Remove no-zero-as-null-pointer-constant * add ##__VAR_ARGS__ workaround * enable gnu-zero-variadic-macro-arguments warning * fix gnu-zero-variadic-macro-arguments * use PrintToDummyParamName * remove ##__VA_ARGS__ workaround * fix ##__VA_ARGS__ and enable gnu-zero-variadic-macro-arguments * handle windows build * use alternative fix to support VS compiler
1 parent 68472cc commit 1cc365c

File tree

12 files changed

+127
-36
lines changed

12 files changed

+127
-36
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
370370
endif()
371371
endif()
372372

373+
set(CMAKE_ORIGINAL_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
374+
373375
ngraph_var(NGRAPH_WARNINGS_AS_ERRORS DEFAULT "OFF")
374376
if (${NGRAPH_WARNINGS_AS_ERRORS})
375377
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")

cmake/clang_4_0_flags.cmake

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,19 @@ add_compile_options(-Werror=comment)
2020
add_compile_options(-pedantic-errors)
2121

2222
# whitelist errors here
23-
add_compile_options(-Weverything)
24-
add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
25-
add_compile_options(-Wno-c++98-compat-pedantic)
26-
add_compile_options(-Wno-weak-vtables)
27-
add_compile_options(-Wno-global-constructors)
28-
add_compile_options(-Wno-exit-time-destructors)
29-
add_compile_options(-Wno-missing-prototypes)
30-
add_compile_options(-Wno-missing-noreturn)
31-
add_compile_options(-Wno-covered-switch-default)
32-
add_compile_options(-Wno-undef)
23+
#add_compile_options(-Weverything)
24+
add_compile_options(-Wall)
25+
# add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
26+
#add_compile_options(-Wno-c++98-compat-pedantic)
27+
#add_compile_options(-Wno-weak-vtables)
28+
#add_compile_options(-Wno-global-constructors)
29+
#add_compile_options(-Wno-exit-time-destructors)
30+
#add_compile_options(-Wno-missing-prototypes)
31+
#add_compile_options(-Wno-missing-noreturn)
32+
#add_compile_options(-Wno-covered-switch-default)
33+
#add_compile_options(-Wno-undef)
3334
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
3435
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.1.0)
35-
add_compile_options(-Wno-zero-as-null-pointer-constant)
36+
#add_compile_options(-Wno-zero-as-null-pointer-constant)
3637
endif()
3738
endif()
38-
39-
# should remove these
40-
add_compile_options(-Wno-padded)
41-
add_compile_options(-Wno-conversion)
42-
add_compile_options(-Wno-double-promotion)

cmake/external_onnx.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ExternalProject_Add(
4444
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
4545
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
4646
CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}
47-
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
47+
-DCMAKE_CXX_FLAGS=${CMAKE_ORIGINAL_CXX_FLAGS}
4848
-DONNX_GEN_PB_TYPE_STUBS=OFF
4949
-DCMAKE_PREFIX_PATH=${Protobuf_INSTALL_PREFIX}
5050
-DONNX_ML=TRUE
@@ -85,15 +85,15 @@ set(ONNX_LIBRARIES ${ONNX_LIBRARY} ${ONNX_PROTO_LIBRARY})
8585
if (NOT TARGET onnx::libonnx)
8686
add_library(onnx::libonnx UNKNOWN IMPORTED)
8787
set_target_properties(onnx::libonnx PROPERTIES
88-
INTERFACE_INCLUDE_DIRECTORIES ${ONNX_INCLUDE_DIR}
88+
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${ONNX_INCLUDE_DIR}
8989
IMPORTED_LOCATION ${ONNX_LIBRARY})
9090
add_dependencies(onnx::libonnx ext_onnx)
9191
endif()
9292

9393
if (NOT TARGET onnx::libonnx_proto)
9494
add_library(onnx::libonnx_proto UNKNOWN IMPORTED)
9595
set_target_properties(onnx::libonnx_proto PROPERTIES
96-
INTERFACE_INCLUDE_DIRECTORIES ${ONNX_PROTO_INCLUDE_DIR}
96+
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${ONNX_PROTO_INCLUDE_DIR}
9797
IMPORTED_LOCATION ${ONNX_PROTO_LIBRARY})
9898
add_dependencies(onnx::libonnx_proto ext_onnx)
9999
endif()

cmake/external_protobuf.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if (WIN32)
3838
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
3939
CMAKE_ARGS
4040
${NGRAPH_FORWARD_CMAKE_ARGS}
41-
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
41+
-DCMAKE_CXX_FLAGS=${CMAKE_ORIGINAL_CXX_FLAGS}
4242
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF
4343
-Dprotobuf_WITH_ZLIB=OFF
4444
-Dprotobuf_BUILD_TESTS=OFF
@@ -108,14 +108,15 @@ set(Protobuf_LIBRARIES ${Protobuf_LIBRARY})
108108
if (NOT TARGET protobuf::libprotobuf)
109109
add_library(protobuf::libprotobuf UNKNOWN IMPORTED)
110110
set_target_properties(protobuf::libprotobuf PROPERTIES
111-
INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}"
111+
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}"
112112
IMPORTED_LOCATION "${Protobuf_LIBRARY}")
113113
add_dependencies(protobuf::libprotobuf ext_protobuf)
114114
endif()
115115

116116
if (NOT TARGET protobuf::protoc)
117117
add_executable(protobuf::protoc IMPORTED)
118118
set_target_properties(protobuf::protoc PROPERTIES
119+
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Protobuf_PROTOC_EXECUTABLE}"
119120
IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE}")
120121
add_dependencies(protobuf::protoc ext_protobuf)
121122
endif()

src/ngraph/check.hpp

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,29 +136,106 @@ namespace ngraph
136136
// TODO(amprocte): refactor NGRAPH_CHECK_HELPER so we don't have to introduce a locally-scoped
137137
// variable (ss___) and risk shadowing.
138138
//
139-
#define NGRAPH_CHECK_HELPER(exc_class, ctx, check, ...) \
139+
#define NGRAPH_CHECK_HELPER2(exc_class, ctx, check, ...) \
140140
do \
141141
{ \
142142
if (!(check)) \
143143
{ \
144144
::std::stringstream ss___; \
145-
::ngraph::write_all_to_stream(ss___, ##__VA_ARGS__); \
145+
::ngraph::write_all_to_stream(ss___, __VA_ARGS__); \
146146
throw exc_class( \
147147
(::ngraph::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ss___.str()); \
148148
} \
149149
} while (0)
150150

151+
#define NGRAPH_CHECK_HELPER1(exc_class, ctx, check) \
152+
do \
153+
{ \
154+
if (!(check)) \
155+
{ \
156+
throw exc_class((::ngraph::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ""); \
157+
} \
158+
} while (0)
159+
151160
/// \brief Macro to check whether a boolean condition holds.
152161
/// \param cond Condition to check
153162
/// \param ... Additional error message info to be added to the error message via the `<<`
154163
/// stream-insertion operator. Note that the expressions here will be evaluated lazily,
155164
/// i.e., only if the `cond` evalutes to `false`.
156165
/// \throws ::ngraph::CheckFailure if `cond` is false.
157-
#define NGRAPH_CHECK(cond, ...) \
158-
NGRAPH_CHECK_HELPER(::ngraph::CheckFailure, "", (cond), ##__VA_ARGS__)
166+
#define NGRAPH_CHECK(...) NGRAPH_CHECK_HELPER(::ngraph::CheckFailure, "", __VA_ARGS__)
159167

160168
/// \brief Macro to signal a code path that is unreachable in a successful execution. It's
161169
/// implemented with NGRAPH_CHECK macro.
162170
/// \param ... Additional error message that should describe why that execution path is unreachable.
163171
/// \throws ::ngraph::CheckFailure if the macro is executed.
164-
#define NGRAPH_UNREACHABLE(...) NGRAPH_CHECK(false, "Unreachable: ", ##__VA_ARGS__)
172+
#define NGRAPH_UNREACHABLE(...) NGRAPH_CHECK(false, "Unreachable: ", __VA_ARGS__)
173+
#define NGRAPH_CHECK_HELPER(exc_class, ctx, ...) \
174+
CALL_OVERLOAD(NGRAPH_CHECK_HELPER, exc_class, ctx, __VA_ARGS__)
175+
176+
#define GLUE(x, y) x y
177+
178+
#define RETURN_ARG_COUNT(_1_, \
179+
_2_, \
180+
_3_, \
181+
_4_, \
182+
_5_, \
183+
_6, \
184+
_7, \
185+
_8, \
186+
_9, \
187+
_10, \
188+
_11, \
189+
_12, \
190+
_13, \
191+
_14, \
192+
_15, \
193+
_16, \
194+
_17, \
195+
_18, \
196+
_19, \
197+
_20, \
198+
_21, \
199+
_22, \
200+
_23, \
201+
_24, \
202+
_25, \
203+
count, \
204+
...) \
205+
count
206+
#define EXPAND_ARGS(args) RETURN_ARG_COUNT args
207+
#define COUNT_ARGS_MAXN(...) \
208+
EXPAND_ARGS((__VA_ARGS__, \
209+
2, \
210+
2, \
211+
2, \
212+
2, \
213+
2, \
214+
2, \
215+
2, \
216+
2, \
217+
2, \
218+
2, \
219+
2, \
220+
2, \
221+
2, \
222+
2, \
223+
2, \
224+
2, \
225+
2, \
226+
2, \
227+
2, \
228+
2, \
229+
2, \
230+
2, \
231+
2, \
232+
2, \
233+
1, \
234+
0))
235+
236+
#define OVERLOAD_MACRO2(name, count) name##count
237+
#define OVERLOAD_MACRO1(name, count) OVERLOAD_MACRO2(name, count)
238+
#define OVERLOAD_MACRO(name, count) OVERLOAD_MACRO1(name, count)
239+
240+
#define CALL_OVERLOAD(name, exc_class, ctx, ...) \
241+
GLUE(OVERLOAD_MACRO(name, COUNT_ARGS_MAXN(__VA_ARGS__)), (exc_class, ctx, __VA_ARGS__))

src/ngraph/frontend/onnx_import/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,15 @@ add_dependencies(onnx_import_interface protobuf::libprotobuf onnx::libonnx onnx:
220220
add_dependencies(onnx_import onnx_import_interface)
221221

222222
set_property(TARGET onnx_import PROPERTY POSITION_INDEPENDENT_CODE ON)
223-
target_include_directories(onnx_import PRIVATE ${ONNX_IMPORT_INCLUDE_DIR} ${NGRAPH_INCLUDE_PATH}
223+
target_include_directories(onnx_import
224+
SYSTEM PRIVATE ${ONNX_IMPORT_INCLUDE_DIR} ${NGRAPH_INCLUDE_PATH}
224225
SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIR})
225226
target_link_libraries(onnx_import PRIVATE ${Protobuf_LIBRARIES} ${ONNX_PROTO_LIBRARY})
226227

227228
target_compile_definitions(onnx_import PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION})
228229

229230
set_property(TARGET onnx_import_interface PROPERTY POSITION_INDEPENDENT_CODE ON)
230-
target_include_directories(onnx_import_interface PRIVATE ${ONNX_IMPORT_INCLUDE_DIR} ${NGRAPH_INCLUDE_PATH}
231+
target_include_directories(onnx_import_interface SYSTEM PRIVATE ${ONNX_IMPORT_INCLUDE_DIR} ${NGRAPH_INCLUDE_PATH}
231232
SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIR})
232233

233234
target_compile_definitions(onnx_import_interface PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION})

src/ngraph/node.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,8 @@ namespace ngraph
782782
bool m_is_short;
783783
};
784784
}
785-
#define NODE_VALIDATION_CHECK(node, cond, ...) \
786-
NGRAPH_CHECK_HELPER(::ngraph::NodeValidationFailure, (node), (cond), ##__VA_ARGS__)
785+
#define NODE_VALIDATION_CHECK(node, ...) \
786+
NGRAPH_CHECK_HELPER(::ngraph::NodeValidationFailure, (node), __VA_ARGS__)
787787

788788
namespace ngraph
789789
{

test/check.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ TEST(check, check_with_explanation)
6262
catch (const CheckFailure& e)
6363
{
6464
check_failure_thrown = true;
65-
EXPECT_PRED_FORMAT2(testing::IsSubstring, "Check '(false)' failed at", e.what());
65+
EXPECT_PRED_FORMAT2(testing::IsSubstring, "Check 'false' failed at", e.what());
6666
EXPECT_PRED_FORMAT2(testing::IsSubstring, "xyzzyxyzzy123", e.what());
6767
}
6868

test/type_prop/dyn_replace_slice.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,8 @@ INSTANTIATE_TEST_CASE_P(
545545
{1},
546546
{}},
547547
DynReplaceSliceParams{
548-
{1, 2, 3}, {3}, {3}, {0}, {1, 1, 2}, {0, 0, 1}, {2, 2, 2}, {}, {}, {}, {0}, {2}, {1}}));
548+
{1, 2, 3}, {3}, {3}, {0}, {1, 1, 2}, {0, 0, 1}, {2, 2, 2}, {}, {}, {}, {0}, {2}, {1}}),
549+
PrintToDummyParamName());
549550

550551
void DynReplaceSlice_Test_Shape_Except(const shared_ptr<Node>& param_0,
551552
const shared_ptr<Node>& param_1,

test/type_prop/dyn_slice.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ INSTANTIATE_TEST_CASE_P(
222222
{{1}, {1}, {}, {1}, {}}),
223223
DynSliceParams({{1, 2, 3}, {3}, {3}, {0}, {1, 1, 2}},
224224
{{0, 0, 1}, {2, 2, 2}, {}},
225-
{{}, {}, {0}, {2}, {1}})));
225+
{{}, {}, {0}, {2}, {1}})),
226+
PrintToDummyParamName());
226227

227228
void DynSlice_Test_Shape_Except(const shared_ptr<Node>& param_0,
228229
const shared_ptr<Node>& param_1,

0 commit comments

Comments
 (0)