add_compile_options is more sensitive to its location in the file than add_definitions--it only takes effect for sources that are added after it. This updated patch ensures that the add_compile_options is done before adding any source files that depend on it.
Using add_definitions caused the flag to be passed to rc.exe on Windows and thus broke Windows builds.
${CLANGD_BINARY_DIR}
)
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
if(CLANG_BUILT_STANDALONE)
# LLVMTestingSupport library is needed for clangd tests.
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN})
endfunction()
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
add_subdirectory(clang-apply-replacements)
add_subdirectory(clang-change-namespace)
add_subdirectory(clang-doc)
add_custom_target(ClangUnitTests)
set_target_properties(ClangUnitTests PROPERTIES FOLDER "Clang tests")
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
if(CLANG_BUILT_STANDALONE)
# LLVMTestingSupport library is needed for some of the unittests.
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS)
append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS)
+append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override COMPILER_RT_UNITTEST_CFLAGS)
if(MSVC)
# gtest use a lot of stuff marked as deprecated on Windows.
check_cxx_compiler_flag("-Werror -Wvariadic-macros" COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG)
check_cxx_compiler_flag("-Werror -Wunused-parameter" COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG)
check_cxx_compiler_flag("-Werror -Wcovered-switch-default" COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG)
+check_cxx_compiler_flag("-Werror -Wsuggest-override" COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG)
check_cxx_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC)
check_cxx_compiler_flag(/W4 COMPILER_RT_HAS_W4_FLAG)
add_unittest(FlangUnitTests ${test_dirname} ${ARGN})
endfunction()
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
add_subdirectory(Optimizer)
add_subdirectory(Decimal)
add_subdirectory(Evaluate)
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)
target_link_libraries(${test_dirname} ${LLVM_COMMON_LIBS})
endfunction()
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
add_subdirectory(DriverTests)
add_subdirectory(MachOTests)
include_directories(${LLDB_SOURCE_ROOT})
include_directories(${LLDB_PROJECT_ROOT}/unittests)
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-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 it's available, and only if it doesn't
+ # suggest adding 'override' to functions that are already marked 'final'
+ # (which means it is disabled for GCC < 9.2).
+ check_cxx_compiler_flag("-Wsuggest-override" CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=suggest-override")
+ CHECK_CXX_SOURCE_COMPILES("class base {public: virtual void anchor();};
+ class derived : base {public: void anchor() final;};
+ int main() { return 0; }"
+ CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL)
+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
+ append_if(CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL "-Wsuggest-override" CMAKE_CXX_FLAGS)
+ endif()
+
# 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_definitions(-DGTEST_LANG_CXX11=1)
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
add_llvm_library(LLVMTestingSupport
Annotations.cpp
Error.cpp
add_llvm_unittest(${test_dir_name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
endfunction()
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
add_subdirectory(ADT)
add_subdirectory(Analysis)
add_subdirectory(AsmParser)
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 )
add_unittest(MLIRUnitTests ${test_dirname} ${ARGN})
endfunction()
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
add_subdirectory(Analysis)
add_subdirectory(Dialect)
add_subdirectory(IR)
# Add warning flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
add_library(
acxxel
target_link_libraries(${test_name} PRIVATE Polly)
endfunction()
+if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
+ add_compile_options("-Wno-suggest-override")
+endif()
+
add_subdirectory(Isl)
add_subdirectory(Flatten)
add_subdirectory(DeLICM)