File tree 18 files changed +72
-1
lines changed
18 files changed +72
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ include_directories(
13
13
${CLANGD_BINARY_DIR}
14
14
)
15
15
16
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
17
+ add_compile_options ("-Wno-suggest-override" )
18
+ endif ()
19
+
16
20
if (CLANG_BUILT_STANDALONE)
17
21
# LLVMTestingSupport library is needed for clangd tests.
18
22
if (EXISTS ${LLVM_MAIN_SRC_DIR} /lib/Testing/Support
Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ function(add_extra_unittest test_dirname)
5
5
add_unittest(ExtraToolsUnitTests ${test_dirname} ${ARGN} )
6
6
endfunction ()
7
7
8
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
9
+ add_compile_options ("-Wno-suggest-override" )
10
+ endif ()
11
+
8
12
add_subdirectory (clang-apply-replacements)
9
13
add_subdirectory (clang-change-namespace)
10
14
add_subdirectory (clang-doc )
Original file line number Diff line number Diff line change 1
1
add_custom_target (ClangUnitTests)
2
2
set_target_properties (ClangUnitTests PROPERTIES FOLDER "Clang tests" )
3
3
4
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
5
+ add_compile_options ("-Wno-suggest-override" )
6
+ endif ()
7
+
4
8
if (CLANG_BUILT_STANDALONE)
5
9
# LLVMTestingSupport library is needed for some of the unittests.
6
10
if (EXISTS ${LLVM_MAIN_SRC_DIR} /lib/Testing/Support
Original file line number Diff line number Diff line change @@ -403,6 +403,7 @@ set(COMPILER_RT_GMOCK_CFLAGS
403
403
404
404
append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS)
405
405
append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS)
406
+ append_list_if(COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG -Wno-suggest-override COMPILER_RT_UNITTEST_CFLAGS)
406
407
407
408
if (MSVC )
408
409
# gtest use a lot of stuff marked as deprecated on Windows.
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ check_cxx_compiler_flag("-Werror -Wnon-virtual-dtor" COMPILER_RT_HAS_WNON_VIRT
106
106
check_cxx_compiler_flag("-Werror -Wvariadic-macros" COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG)
107
107
check_cxx_compiler_flag("-Werror -Wunused-parameter" COMPILER_RT_HAS_WUNUSED_PARAMETER_FLAG)
108
108
check_cxx_compiler_flag("-Werror -Wcovered-switch-default" COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG)
109
+ check_cxx_compiler_flag("-Werror -Wsuggest-override" COMPILER_RT_HAS_WSUGGEST_OVERRIDE_FLAG)
109
110
check_cxx_compiler_flag(-Wno-pedantic COMPILER_RT_HAS_WNO_PEDANTIC)
110
111
111
112
check_cxx_compiler_flag(/W4 COMPILER_RT_HAS_W4_FLAG)
Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ function(add_flang_unittest test_dirname)
5
5
add_unittest(FlangUnitTests ${test_dirname} ${ARGN} )
6
6
endfunction ()
7
7
8
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
9
+ add_compile_options ("-Wno-suggest-override" )
10
+ endif ()
11
+
8
12
add_subdirectory (Optimizer)
9
13
add_subdirectory (Decimal)
10
14
add_subdirectory (Evaluate)
Original file line number Diff line number Diff line change @@ -578,6 +578,7 @@ function(cxx_add_warning_flags target)
578
578
target_add_compile_flags_if_supported(${target} PRIVATE
579
579
-Wno-user-defined -literals
580
580
-Wno-covered-switch-default
581
+ -Wno-suggest-override
581
582
-Wno-ignored-attributes # FIXME: Caused by _LIBCPP_NODEBUG_TYPE not being supported on older clangs
582
583
)
583
584
if (LIBCXX_TARGETING_CLANG_CL)
@@ -602,7 +603,8 @@ function(cxx_add_warning_flags target)
602
603
target_add_compile_flags_if_supported(${target} PRIVATE
603
604
-Wno-literal-suffix
604
605
-Wno-c++14-compat
605
- -Wno-noexcept-type )
606
+ -Wno-noexcept-type
607
+ -Wno-suggest-override)
606
608
endif ()
607
609
if (LIBCXX_ENABLE_WERROR)
608
610
target_add_compile_flags_if_supported(${target} PRIVATE -Werror)
Original file line number Diff line number Diff line change @@ -283,6 +283,8 @@ add_compile_flags_if_supported(-Wunused-variable)
283
283
add_compile_flags_if_supported(-Wwrite-strings )
284
284
add_compile_flags_if_supported(-Wundef)
285
285
286
+ add_compile_flags_if_supported(-Wno-suggest-override)
287
+
286
288
if (LIBCXXABI_ENABLE_WERROR)
287
289
add_compile_flags_if_supported(-Werror)
288
290
add_compile_flags_if_supported(-WX)
Original file line number Diff line number Diff line change @@ -12,5 +12,9 @@ function(add_lld_unittest test_dirname)
12
12
target_link_libraries (${test_dirname} ${LLVM_COMMON_LIBS} )
13
13
endfunction ()
14
14
15
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
16
+ add_compile_options ("-Wno-suggest-override" )
17
+ endif ()
18
+
15
19
add_subdirectory (DriverTests)
16
20
add_subdirectory (MachOTests)
Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ add_dependencies(lldb-test-deps LLDBUnitTests)
5
5
include_directories (${LLDB_SOURCE_ROOT} )
6
6
include_directories (${LLDB_PROJECT_ROOT} /unittests)
7
7
8
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
9
+ add_compile_options ("-Wno-suggest-override" )
10
+ endif ()
11
+
8
12
set (LLDB_GTEST_COMMON_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR} /gtest_common.h)
9
13
if (MSVC )
10
14
list (APPEND LLVM_COMPILE_FLAGS /FI ${LLDB_GTEST_COMMON_INCLUDE} )
Original file line number Diff line number Diff line change @@ -672,6 +672,21 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
672
672
# Enable -Wdelete-non-virtual-dtor if available.
673
673
add_flag_if_supported("-Wdelete-non-virtual-dtor" DELETE_NON_VIRTUAL_DTOR_FLAG)
674
674
675
+ # Enable -Wsuggest-override if it's available, and only if it doesn't
676
+ # suggest adding 'override' to functions that are already marked 'final'
677
+ # (which means it is disabled for GCC < 9.2).
678
+ check_cxx_compiler_flag("-Wsuggest-override" CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
679
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
680
+ set (OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} )
681
+ set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=suggest-override" )
682
+ CHECK_CXX_SOURCE_COMPILES("class base {public: virtual void anchor();};
683
+ class derived : base {public: void anchor() final;};
684
+ int main() { return 0; }"
685
+ CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL)
686
+ set (CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS} )
687
+ append_if(CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL "-Wsuggest-override" CMAKE_CXX_FLAGS )
688
+ endif ()
689
+
675
690
# Check if -Wcomment is OK with an // comment ending with '\' if the next
676
691
# line is also a // comment.
677
692
set (OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} )
Original file line number Diff line number Diff line change 1
1
add_definitions (-DGTEST_LANG_CXX11=1)
2
2
add_definitions (-DGTEST_HAS_TR1_TUPLE=0)
3
3
4
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
5
+ add_compile_options ("-Wno-suggest-override" )
6
+ endif ()
7
+
4
8
add_llvm_library(LLVMTestingSupport
5
9
Annotations.cpp
6
10
Error.cpp
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ function(add_llvm_target_unittest test_dir_name)
14
14
add_llvm_unittest(${test_dir_name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN} )
15
15
endfunction ()
16
16
17
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
18
+ add_compile_options ("-Wno-suggest-override" )
19
+ endif ()
20
+
17
21
add_subdirectory (ADT)
18
22
add_subdirectory (Analysis)
19
23
add_subdirectory (AsmParser)
Original file line number Diff line number Diff line change @@ -156,6 +156,10 @@ else()
156
156
add_cxx_compiler_flag(-fno-exceptions)
157
157
endif ()
158
158
159
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
160
+ add_cxx_compiler_flag(-Wno-suggest-override)
161
+ endif ()
162
+
159
163
if (HAVE_CXX_FLAG_FSTRICT_ALIASING)
160
164
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel" ) #ICC17u2: Many false positives for Wstrict-aliasing
161
165
add_cxx_compiler_flag(-Wstrict-aliasing)
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ endif()
43
43
if (CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG)
44
44
add_definitions ("-Wno-covered-switch-default" )
45
45
endif ()
46
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
47
+ add_definitions ("-Wno-suggest-override" )
48
+ endif ()
46
49
47
50
set (LLVM_REQUIRES_RTTI 1)
48
51
add_definitions ( -DGTEST_HAS_RTTI=0 )
Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ function(add_mlir_unittest test_dirname)
5
5
add_unittest(MLIRUnitTests ${test_dirname} ${ARGN} )
6
6
endfunction ()
7
7
8
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
9
+ add_compile_options ("-Wno-suggest-override" )
10
+ endif ()
11
+
8
12
add_subdirectory (Analysis)
9
13
add_subdirectory (Dialect)
10
14
add_subdirectory (IR)
Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
36
36
37
37
# Add warning flags.
38
38
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra" )
39
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
40
+ add_compile_options ("-Wno-suggest-override" )
41
+ endif ()
39
42
40
43
add_library (
41
44
acxxel
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ function(add_polly_unittest test_name)
19
19
target_link_libraries (${test_name} PRIVATE Polly)
20
20
endfunction ()
21
21
22
+ if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
23
+ add_compile_options ("-Wno-suggest-override" )
24
+ endif ()
25
+
22
26
add_subdirectory (Isl)
23
27
add_subdirectory (Flatten)
24
28
add_subdirectory (DeLICM)
You can’t perform that action at this time.
0 commit comments