[PATCH] D70122: [cmake] Disable GCC 9's -Winit-list-lifetime warning
Pavel Labath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 06:35:01 PST 2019
labath created this revision.
labath added reviewers: rnk, aaron.ballman.
Herald added a subscriber: mgorny.
Herald added a project: LLVM.
This is a new warning which fires when one stores a reference to the
initializer_list contents in a way which may outlive the
initializer_list which it came from. In llvm this warning is triggered
whenever someone uses the initializer_list ArrayRef constructor.
This is indeed a dangerous thing to do (I myself was bitten by that at
least once), but it is not more dangerous than calling other ArrayRef
constructors with temporary objects -- something which we are used to
and have accepted as a tradeoff for ArrayRef's efficiency.
Currently, this warnings generates so much output that it completely
obscures any actionable warnings, so this patch disables it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70122
Files:
llvm/cmake/modules/HandleLLVMOptions.cmake
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -588,6 +588,12 @@
check_cxx_compiler_flag("-Wclass-memaccess" CXX_SUPPORTS_CLASS_MEMACCESS_FLAG)
append_if(CXX_SUPPORTS_CLASS_MEMACCESS_FLAG "-Wno-class-memaccess" CMAKE_CXX_FLAGS)
+ # A GCC 9 warning triggered by ArrayRef.
+ check_cxx_compiler_flag("-Winit-list-lifetime"
+ CXX_SUPPORTS_INIT_LIST_LIFETIME_FLAG)
+ append_if(CXX_SUPPORTS_INIT_LIST_LIFETIME_FLAG "-Wno-init-list-lifetime"
+ CMAKE_CXX_FLAGS)
+
# The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not useful.
check_cxx_compiler_flag("-Wnoexcept-type" CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG)
append_if(CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG "-Wno-noexcept-type" CMAKE_CXX_FLAGS)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70122.228883.patch
Type: text/x-patch
Size: 884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191112/ee08838b/attachment.bin>
More information about the llvm-commits
mailing list