From 78dc4959354455f51e80ec89c13938f8fc54f300 Mon Sep 17 00:00:00 2001 From: Logan Smith Date: Mon, 27 Jul 2020 08:37:01 -0700 Subject: [PATCH] Use INTERFACE_COMPILE_OPTIONS to disable -Wsuggest-override for any target that links to gtest This cleans up several CMakeLists.txt's where -Wno-suggest-override was manually specified. These test targets now inherit this flag from the gtest target. Some unittests CMakeLists.txt's, in particular Flang and LLDB, are not touched by this patch. Flang manually adds the gtest sources itself in some configurations, rather than linking to LLVM's gtest target, so this fix would be insufficient to cover those cases. Similarly, LLDB has subdirectories that manually add the gtest headers to their include path without linking to the gtest target, so those subdirectories still need -Wno-suggest-override to be manually specified to compile without warnings. Differential Revision: https://reviews.llvm.org/D84554 --- lib/Testing/Support/CMakeLists.txt | 4 ---- unittests/CMakeLists.txt | 4 ---- utils/unittest/CMakeLists.txt | 11 ++++++++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/Testing/Support/CMakeLists.txt b/lib/Testing/Support/CMakeLists.txt index 595221a105c..fe460aeefc9 100644 --- a/lib/Testing/Support/CMakeLists.txt +++ b/lib/Testing/Support/CMakeLists.txt @@ -1,10 +1,6 @@ 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 diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index e90f07448c1..d7dbaeaa32f 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -14,10 +14,6 @@ function(add_llvm_target_unittest test_dir_name) 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) diff --git a/utils/unittest/CMakeLists.txt b/utils/unittest/CMakeLists.txt index 36761a60d9f..bcae36fa150 100644 --- a/utils/unittest/CMakeLists.txt +++ b/utils/unittest/CMakeLists.txt @@ -43,9 +43,6 @@ endif() 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 ) @@ -73,6 +70,14 @@ add_llvm_library(gtest BUILDTREE_ONLY ) +# The googletest and googlemock sources don't presently use the 'override' +# keyword, which leads to lots of warnings from -Wsuggest-override. Disable +# that warning here for any targets that link to gtest. +if(CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG) + add_definitions("-Wno-suggest-override") + set_target_properties(gtest PROPERTIES INTERFACE_COMPILE_OPTIONS "-Wno-suggest-override") +endif() + add_subdirectory(UnitTestMain) # When LLVM_LINK_LLVM_DYLIB is enabled, libLLVM.so is added to the interface