This patch adds Clang's new (and GCC's old) -Wsuggest-override to the warning flags for the LLVM build. The warning is a stronger form of -Winconsistent-missing-override which warns _everywhere_ that override is missing, not just in places where it's inconsistent within a class.
Some directories in the monorepo need the warning disabled for compatibility's, or sanity's, sake; in particular, libcxx/libcxxabi, and any code implementing or interoperating with googletest, googlemock, or google benchmark (which do not themselves use override). This patch adds -Wno-suggest-override to the relevant CMakeLists.txt's to accomplish this.
Differential Revision: https://reviews.llvm.org/D84126
target_add_compile_flags_if_supported(${target} PRIVATE
-Wno-user-defined-literals
-Wno-covered-switch-default
+ -Wno-suggest-override
-Wno-ignored-attributes # FIXME: Caused by _LIBCPP_NODEBUG_TYPE not being supported on older clangs
)
if (LIBCXX_TARGETING_CLANG_CL)
target_add_compile_flags_if_supported(${target} PRIVATE
-Wno-literal-suffix
-Wno-c++14-compat
- -Wno-noexcept-type)
+ -Wno-noexcept-type
+ -Wno-suggest-override)
endif()
if (LIBCXX_ENABLE_WERROR)
target_add_compile_flags_if_supported(${target} PRIVATE -Werror)
add_compile_flags_if_supported(-Wwrite-strings)
add_compile_flags_if_supported(-Wundef)
+add_compile_flags_if_supported(-Wno-suggest-override)
+
if (LIBCXXABI_ENABLE_WERROR)
add_compile_flags_if_supported(-Werror)
add_compile_flags_if_supported(-WX)
include_directories(${LLDB_SOURCE_ROOT})
include_directories(${LLDB_PROJECT_ROOT}/unittests)
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_definitions("-Wno-suggest-override")
+endif()
+
set(LLDB_GTEST_COMMON_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/gtest_common.h)
if (MSVC)
list(APPEND LLVM_COMPILE_FLAGS /FI ${LLDB_GTEST_COMMON_INCLUDE})
# Enable -Wdelete-non-virtual-dtor if available.
add_flag_if_supported("-Wdelete-non-virtual-dtor" DELETE_NON_VIRTUAL_DTOR_FLAG)
+ # Enable -Wsuggest-override if available.
+ add_flag_if_supported("-Wsuggest-override" SUGGEST_OVERRIDE_FLAG)
+
# Check if -Wcomment is OK with an // comment ending with '\' if the next
# line is also a // comment.
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
add_cxx_compiler_flag(-fno-exceptions)
endif()
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_cxx_compiler_flag(-Wno-suggest-override)
+ endif()
+
if (HAVE_CXX_FLAG_FSTRICT_ALIASING)
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel") #ICC17u2: Many false positives for Wstrict-aliasing
add_cxx_compiler_flag(-Wstrict-aliasing)
if(CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
add_definitions("-Wno-covered-switch-default")
endif()
+if(CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_definitions("-Wno-suggest-override")
+endif()
set(LLVM_REQUIRES_RTTI 1)
add_definitions( -DGTEST_HAS_RTTI=0 )