Unverified Commit b7d8c78b authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Cyphers/lastwarns (#3640) (#3673)

* 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

* fix merge issue

* remove variadic macros from kernel_selectors

* replace remaining ##__VA_ARGS__

* fix missing braces

* Remove some clang warnings

* Warnings cleanup
parent 95ce59ab
......@@ -379,6 +379,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif()
endif()
set(CMAKE_ORIGINAL_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ngraph_var(NGRAPH_WARNINGS_AS_ERRORS DEFAULT "OFF")
if (${NGRAPH_WARNINGS_AS_ERRORS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
......
......@@ -20,19 +20,20 @@ add_compile_options(-Werror=comment)
add_compile_options(-pedantic-errors)
# whitelist errors here
add_compile_options(-Weverything)
add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
add_compile_options(-Wno-c++98-compat-pedantic)
add_compile_options(-Wno-weak-vtables)
add_compile_options(-Wno-global-constructors)
add_compile_options(-Wno-exit-time-destructors)
add_compile_options(-Wno-missing-prototypes)
add_compile_options(-Wno-missing-noreturn)
add_compile_options(-Wno-covered-switch-default)
add_compile_options(-Wno-undef)
#add_compile_options(-Weverything)
add_compile_options(-Wall)
# add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
#add_compile_options(-Wno-c++98-compat-pedantic)
#add_compile_options(-Wno-weak-vtables)
#add_compile_options(-Wno-global-constructors)
#add_compile_options(-Wno-exit-time-destructors)
#add_compile_options(-Wno-missing-prototypes)
#add_compile_options(-Wno-missing-noreturn)
#add_compile_options(-Wno-covered-switch-default)
#add_compile_options(-Wno-undef)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.1.0)
add_compile_options(-Wno-zero-as-null-pointer-constant)
#add_compile_options(-Wno-zero-as-null-pointer-constant)
endif()
endif()
......
......@@ -44,7 +44,7 @@ ExternalProject_Add(
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_ORIGINAL_CXX_FLAGS}
-DONNX_GEN_PB_TYPE_STUBS=OFF
-DCMAKE_PREFIX_PATH=${Protobuf_INSTALL_PREFIX}
-DONNX_ML=TRUE
......@@ -85,7 +85,7 @@ set(ONNX_LIBRARIES ${ONNX_LIBRARY} ${ONNX_PROTO_LIBRARY})
if (NOT TARGET onnx::libonnx)
add_library(onnx::libonnx UNKNOWN IMPORTED)
set_target_properties(onnx::libonnx PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${ONNX_INCLUDE_DIR}
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${ONNX_INCLUDE_DIR}
IMPORTED_LOCATION ${ONNX_LIBRARY})
add_dependencies(onnx::libonnx ext_onnx)
endif()
......@@ -93,7 +93,7 @@ endif()
if (NOT TARGET onnx::libonnx_proto)
add_library(onnx::libonnx_proto UNKNOWN IMPORTED)
set_target_properties(onnx::libonnx_proto PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${ONNX_PROTO_INCLUDE_DIR}
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${ONNX_PROTO_INCLUDE_DIR}
IMPORTED_LOCATION ${ONNX_PROTO_LIBRARY})
add_dependencies(onnx::libonnx_proto ext_onnx)
endif()
......@@ -38,7 +38,7 @@ if (WIN32)
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_ORIGINAL_CXX_FLAGS}
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF
-Dprotobuf_WITH_ZLIB=OFF
-Dprotobuf_BUILD_TESTS=OFF
......@@ -108,7 +108,7 @@ set(Protobuf_LIBRARIES ${Protobuf_LIBRARY})
if (NOT TARGET protobuf::libprotobuf)
add_library(protobuf::libprotobuf UNKNOWN IMPORTED)
set_target_properties(protobuf::libprotobuf PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}"
IMPORTED_LOCATION "${Protobuf_LIBRARY}")
add_dependencies(protobuf::libprotobuf ext_protobuf)
endif()
......@@ -116,6 +116,7 @@ endif()
if (NOT TARGET protobuf::protoc)
add_executable(protobuf::protoc IMPORTED)
set_target_properties(protobuf::protoc PROPERTIES
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Protobuf_PROTOC_EXECUTABLE}"
IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE}")
add_dependencies(protobuf::protoc ext_protobuf)
endif()
......
......@@ -136,29 +136,106 @@ namespace ngraph
// TODO(amprocte): refactor NGRAPH_CHECK_HELPER so we don't have to introduce a locally-scoped
// variable (ss___) and risk shadowing.
//
#define NGRAPH_CHECK_HELPER(exc_class, ctx, check, ...) \
#define NGRAPH_CHECK_HELPER2(exc_class, ctx, check, ...) \
do \
{ \
if (!(check)) \
{ \
::std::stringstream ss___; \
::ngraph::write_all_to_stream(ss___, ##__VA_ARGS__); \
::ngraph::write_all_to_stream(ss___, __VA_ARGS__); \
throw exc_class( \
(::ngraph::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ss___.str()); \
} \
} while (0)
#define NGRAPH_CHECK_HELPER1(exc_class, ctx, check) \
do \
{ \
if (!(check)) \
{ \
throw exc_class((::ngraph::CheckLocInfo{__FILE__, __LINE__, #check}), (ctx), ""); \
} \
} while (0)
/// \brief Macro to check whether a boolean condition holds.
/// \param cond Condition to check
/// \param ... Additional error message info to be added to the error message via the `<<`
/// stream-insertion operator. Note that the expressions here will be evaluated lazily,
/// i.e., only if the `cond` evalutes to `false`.
/// \throws ::ngraph::CheckFailure if `cond` is false.
#define NGRAPH_CHECK(cond, ...) \
NGRAPH_CHECK_HELPER(::ngraph::CheckFailure, "", (cond), ##__VA_ARGS__)
#define NGRAPH_CHECK(...) NGRAPH_CHECK_HELPER(::ngraph::CheckFailure, "", __VA_ARGS__)
/// \brief Macro to signal a code path that is unreachable in a successful execution. It's
/// implemented with NGRAPH_CHECK macro.
/// \param ... Additional error message that should describe why that execution path is unreachable.
/// \throws ::ngraph::CheckFailure if the macro is executed.
#define NGRAPH_UNREACHABLE(...) NGRAPH_CHECK(false, "Unreachable: ", ##__VA_ARGS__)
#define NGRAPH_UNREACHABLE(...) NGRAPH_CHECK(false, "Unreachable: ", __VA_ARGS__)
#define NGRAPH_CHECK_HELPER(exc_class, ctx, ...) \
CALL_OVERLOAD(NGRAPH_CHECK_HELPER, exc_class, ctx, __VA_ARGS__)
#define GLUE(x, y) x y
#define RETURN_ARG_COUNT(_1_, \
_2_, \
_3_, \
_4_, \
_5_, \
_6, \
_7, \
_8, \
_9, \
_10, \
_11, \
_12, \
_13, \
_14, \
_15, \
_16, \
_17, \
_18, \
_19, \
_20, \
_21, \
_22, \
_23, \
_24, \
_25, \
count, \
...) \
count
#define EXPAND_ARGS(args) RETURN_ARG_COUNT args
#define COUNT_ARGS_MAXN(...) \
EXPAND_ARGS((__VA_ARGS__, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
2, \
1, \
0))
#define OVERLOAD_MACRO2(name, count) name##count
#define OVERLOAD_MACRO1(name, count) OVERLOAD_MACRO2(name, count)
#define OVERLOAD_MACRO(name, count) OVERLOAD_MACRO1(name, count)
#define CALL_OVERLOAD(name, exc_class, ctx, ...) \
GLUE(OVERLOAD_MACRO(name, COUNT_ARGS_MAXN(__VA_ARGS__)), (exc_class, ctx, __VA_ARGS__))
......@@ -218,23 +218,24 @@ add_dependencies(onnx_import_interface protobuf::libprotobuf onnx::libonnx onnx:
add_dependencies(onnx_import onnx_import_interface)
set_property(TARGET onnx_import PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(onnx_import PRIVATE ${ONNX_IMPORT_INCLUDE_DIR} ${NGRAPH_INCLUDE_PATH}
target_include_directories(onnx_import
SYSTEM PRIVATE ${ONNX_IMPORT_INCLUDE_DIR} ${NGRAPH_INCLUDE_PATH}
SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIR})
target_link_libraries(onnx_import PRIVATE ${Protobuf_LIBRARIES} ${ONNX_PROTO_LIBRARY})
target_compile_definitions(onnx_import PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION})
set_property(TARGET onnx_import_interface PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(onnx_import_interface PRIVATE ${ONNX_IMPORT_INCLUDE_DIR} ${NGRAPH_INCLUDE_PATH}
target_include_directories(onnx_import_interface SYSTEM PRIVATE ${ONNX_IMPORT_INCLUDE_DIR} ${NGRAPH_INCLUDE_PATH}
SYSTEM PRIVATE ${ONNX_INCLUDE_DIR} ${ONNX_PROTO_INCLUDE_DIR} ${Protobuf_INCLUDE_DIR})
target_compile_definitions(onnx_import_interface PRIVATE ONNX_OPSET_VERSION=${ONNX_OPSET_VERSION})
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$")
target_compile_options(onnx_import PRIVATE -Wno-undef -Wno-reserved-id-macro -Wno-switch-enum
-Wno-extended-offsetof -Wno-shorten-64-to-32 -Wno-unused-macros -Wno-missing-variable-declarations
-Wno-invalid-offsetof -Wno-shorten-64-to-32 -Wno-unused-macros -Wno-missing-variable-declarations
-Wno-unused-private-field -Wno-shadow -Wno-deprecated PUBLIC -Wno-undefined-func-template)
target_compile_options(onnx_import_interface PRIVATE -Wno-undef -Wno-reserved-id-macro -Wno-switch-enum
-Wno-extended-offsetof -Wno-shorten-64-to-32 -Wno-unused-macros -Wno-missing-variable-declarations
-Wno-invalid-offsetof -Wno-shorten-64-to-32 -Wno-unused-macros -Wno-missing-variable-declarations
-Wno-unused-private-field -Wno-shadow -Wno-deprecated PUBLIC -Wno-undefined-func-template)
endif()
......@@ -863,8 +863,8 @@ namespace ngraph
bool m_is_short;
};
}
#define NODE_VALIDATION_CHECK(node, cond, ...) \
NGRAPH_CHECK_HELPER(::ngraph::NodeValidationFailure, (node), (cond), ##__VA_ARGS__)
#define NODE_VALIDATION_CHECK(node, ...) \
NGRAPH_CHECK_HELPER(::ngraph::NodeValidationFailure, (node), __VA_ARGS__)
namespace ngraph
{
......
......@@ -71,7 +71,7 @@ shared_ptr<Node> ngraph::op::CompiledKernel::copy_with_new_args(const NodeVector
{
ck->insert_to_input_map(it.first, it.second);
}
return ck;
return std::move(ck);
}
ngraph::op::CompiledKernel::CompiledKernel(const OutputVector& node_list,
......
......@@ -282,7 +282,7 @@ shared_ptr<Node> op::v1::TopK::copy_with_new_args(const NodeVector& new_args) co
new_v1_topk->set_index_element_type(m_index_element_type);
return new_v1_topk;
return std::move(new_v1_topk);
}
op::v1::TopK::Mode op::v1::TopK::mode_from_string(const std::string& mode) const
......
......@@ -222,7 +222,7 @@ static std::shared_ptr<ngraph::Node> broadcast_value_pdpd_style(
auto value_bcast = std::make_shared<ngraph::op::Broadcast>(trimmed_value, output_shape, axes);
return value_bcast;
return std::move(value_bcast);
}
namespace ngraph
......
......@@ -41,8 +41,6 @@ namespace ngraph
external_function->get_buffer_index(args[0].get_name()); // min_val
auto arg1_buffer_index =
external_function->get_buffer_index(args[1].get_name()); // max_val
auto arg2_buffer_index =
external_function->get_buffer_index(args[2].get_name()); // output_shape
auto arg3_buffer_index =
external_function->get_buffer_index(args[3].get_name()); // use_fixed_seed
......@@ -57,7 +55,6 @@ namespace ngraph
element_count,
arg0_buffer_index,
arg1_buffer_index,
arg2_buffer_index,
arg3_buffer_index,
out_buffer_index,
fixed_seed](CPURuntimeContext* ctx, CPUExecutionContext* /* ectx */) {
......
This diff is collapsed.
......@@ -62,7 +62,7 @@ TEST(check, check_with_explanation)
catch (const CheckFailure& e)
{
check_failure_thrown = true;
EXPECT_PRED_FORMAT2(testing::IsSubstring, "Check '(false)' failed at", e.what());
EXPECT_PRED_FORMAT2(testing::IsSubstring, "Check 'false' failed at", e.what());
EXPECT_PRED_FORMAT2(testing::IsSubstring, "xyzzyxyzzy123", e.what());
}
......
......@@ -591,7 +591,8 @@ INSTANTIATE_TEST_CASE_P(
{1},
{}},
DynReplaceSliceParams{
{1, 2, 3}, {3}, {3}, {0}, {1, 1, 2}, {0, 0, 1}, {2, 2, 2}, {}, {}, {}, {0}, {2}, {1}}));
{1, 2, 3}, {3}, {3}, {0}, {1, 1, 2}, {0, 0, 1}, {2, 2, 2}, {}, {}, {}, {0}, {2}, {1}}),
PrintToDummyParamName());
void DynReplaceSlice_Test_Shape_Except(const shared_ptr<Node>& param_0,
const shared_ptr<Node>& param_1,
......
......@@ -265,12 +265,12 @@ INSTANTIATE_TEST_CASE_P(
{0, 2, 2}, /*upper_bounds_val*/
{1, 1, -1}}, /*strides_val*/
{{}, /*lower_bounds_mask*/
{}, /*upper_bounds_mask*/
{}, /*new_axis*/
{}, /*shrink_axis*/
{0}}) /*ellipsis_mask*/
));
{{}, /*lower_bounds_mask*/
{}, /*upper_bounds_mask*/
{}, /*new_axis*/
{}, /*shrink_axis*/
{0}})), /*ellipsis_mask*/
PrintToDummyParamName());
void DynSlice_Test_Shape_Except(const shared_ptr<Node>& param_0,
const shared_ptr<Node>& param_1,
......
......@@ -436,7 +436,8 @@ INSTANTIATE_TEST_CASE_P(type_prop,
RangeParams{1, 23, 2, PartialShape{11}},
RangeParams{1, 22, 2, PartialShape{11}},
RangeParams{0, 0, 1, PartialShape{0}},
RangeParams{1, 0, 2, PartialShape{0}}));
RangeParams{1, 0, 2, PartialShape{0}}),
PrintToDummyParamName());
struct RangeTestWithNegatives : ::testing::TestWithParam<RangeParams>
{
......@@ -488,7 +489,8 @@ INSTANTIATE_TEST_CASE_P(type_prop,
RangeParams{2, 0, -1, PartialShape{2}},
RangeParams{-19, 19, 1, PartialShape{38}},
RangeParams{-19, 19, 3, PartialShape{13}},
RangeParams{20, -19, 1, PartialShape{0}}));
RangeParams{20, -19, 1, PartialShape{0}}),
PrintToDummyParamName());
struct RangeTestFloating : ::testing::TestWithParam<RangeParams>
{
......@@ -518,4 +520,5 @@ INSTANTIATE_TEST_CASE_P(type_prop,
RangeTestFloating,
::testing::Values(RangeParams{0, 1, 0.25, PartialShape{4}},
RangeParams{-1, 1, 0.25, PartialShape{8}},
RangeParams{-1, 0.875, 0.25, PartialShape{8}}));
RangeParams{-1, 0.875, 0.25, PartialShape{8}}),
PrintToDummyParamName());
......@@ -20,3 +20,12 @@
#define EXPECT_HAS_SUBSTRING(haystack, needle) \
EXPECT_PRED_FORMAT2(testing::IsSubstring, needle, haystack)
struct PrintToDummyParamName
{
template <class ParamType>
std::string operator()(const ::testing::TestParamInfo<ParamType>& info) const
{
return "dummy" + std::to_string(info.index);
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment