[llvm] 898320d - [cmake] Disable all -Wuninitialized warnings on GCC older than 12. (#76251)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 26 06:10:48 PST 2023


Author: Jacek Caban
Date: 2023-12-26T15:10:44+01:00
New Revision: 898320d4e52c9110422a31a8afc896b9d211ed9d

URL: https://github.com/llvm/llvm-project/commit/898320d4e52c9110422a31a8afc896b9d211ed9d
DIFF: https://github.com/llvm/llvm-project/commit/898320d4e52c9110422a31a8afc896b9d211ed9d.diff

LOG: [cmake] Disable all -Wuninitialized warnings on GCC older than 12. (#76251)

As discussed in #75183, avoids dealing with GCC false positives.

Added: 
    

Modified: 
    llvm/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 7bb3e98333effb..3e12213f6e6b5d 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -431,15 +431,13 @@ set(USE_NO_UNINITIALIZED 0)
 # Disable gcc's potentially uninitialized use analysis as it presents lots of
 # false positives.
 if (CMAKE_COMPILER_IS_GNUCXX)
-  check_cxx_compiler_flag("-Wmaybe-uninitialized" HAS_MAYBE_UNINITIALIZED)
-  if (HAS_MAYBE_UNINITIALIZED)
-    set(USE_NO_MAYBE_UNINITIALIZED 1)
-  else()
-    # Only recent versions of gcc make the distinction between -Wuninitialized
-    # and -Wmaybe-uninitialized. If -Wmaybe-uninitialized isn't supported, just
-    # turn off all uninitialized use warnings.
+  # Disable all -Wuninitialized warning for old GCC versions.
+  if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)
     check_cxx_compiler_flag("-Wuninitialized" HAS_UNINITIALIZED)
     set(USE_NO_UNINITIALIZED ${HAS_UNINITIALIZED})
+  else()
+    check_cxx_compiler_flag("-Wmaybe-uninitialized" HAS_MAYBE_UNINITIALIZED)
+    set(USE_NO_MAYBE_UNINITIALIZED ${HAS_MAYBE_UNINITIALIZED})
   endif()
 endif()
 


        


More information about the llvm-commits mailing list