[llvm] c027553 - [cmake] Disable GCC 9's -Wpessimizing-move
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 22 06:16:00 PDT 2021
Author: Martin Storsjö
Date: 2021-03-22T15:14:46+02:00
New Revision: c027553d95fa481e873d47186e761bddc6f12d92
URL: https://github.com/llvm/llvm-project/commit/c027553d95fa481e873d47186e761bddc6f12d92
DIFF: https://github.com/llvm/llvm-project/commit/c027553d95fa481e873d47186e761bddc6f12d92.diff
LOG: [cmake] Disable GCC 9's -Wpessimizing-move
Similar to the existing code for disabling GCC's -Wredudant-move,
also check for the -Wpessimizing-move option and disable it if
possible.
This silences another bunch of noisy warnings when building LLVM
with GCC 9.
As noted for -Wredundant-move, the code can't be fixed to silence the
warnings while retaining support for older compilers.
Differential Revision: https://reviews.llvm.org/D98942
Added:
Modified:
llvm/cmake/modules/HandleLLVMOptions.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 0c575b6608b0..8b64694757e9 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -690,14 +690,17 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
check_cxx_compiler_flag("-Wclass-memaccess" CXX_SUPPORTS_CLASS_MEMACCESS_FLAG)
append_if(CXX_SUPPORTS_CLASS_MEMACCESS_FLAG "-Wno-class-memaccess" CMAKE_CXX_FLAGS)
- # Disable -Wredundant-move on GCC>=9. GCC wants to remove std::move in code
- # like "A foo(ConvertibleToA a) { return std::move(a); }", but this code does
- # not compile (or uses the copy constructor instead) on clang<=3.8. Clang also
- # has a -Wredundant-move, but it only fires when the types match exactly, so
- # we can keep it here.
+ # Disable -Wredundant-move and -Wpessimizing-move on GCC>=9. GCC wants to
+ # remove std::move in code like "A foo(ConvertibleToA a) {
+ # return std::move(a); }", but this code does not compile (or uses the copy
+ # constructor instead) on clang<=3.8. Clang also has a -Wredundant-move and
+ # -Wpessimizing-move, but they only fire when the types match exactly, so we
+ # can keep them here.
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
check_cxx_compiler_flag("-Wredundant-move" CXX_SUPPORTS_REDUNDANT_MOVE_FLAG)
append_if(CXX_SUPPORTS_REDUNDANT_MOVE_FLAG "-Wno-redundant-move" CMAKE_CXX_FLAGS)
+ check_cxx_compiler_flag("-Wpessimizing-move" CXX_SUPPORTS_PESSIMIZING_MOVE_FLAG)
+ append_if(CXX_SUPPORTS_PESSIMIZING_MOVE_FLAG "-Wno-pessimizing-move" CMAKE_CXX_FLAGS)
endif()
# The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not useful.
More information about the llvm-commits
mailing list