[PATCH] Turn off uninitialized-use warnings for gcc in cmake build
Edwin Vane
edwin.vane at intel.com
Thu Jan 31 06:11:39 PST 2013
Vast simplification based on reviewer observation that although gcc
won't complain about unsupported -Wno-* flags it *will* complain about
unsupported -W flags. Instead of testing for -Wno-maybe-uninitialized we
test for the positive.
Someone should fix up the logic in autoconf/configure.ac the same way
too.
Hi chandlerc, gribozavr, doug.gregor,
http://llvm-reviews.chandlerc.com/D353
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D353?vs=835&id=842#toc
Files:
cmake/config-ix.cmake
cmake/modules/HandleLLVMOptions.cmake
Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -304,6 +304,24 @@
check_cxx_compiler_flag("-Wno-variadic-macros" SUPPORTS_NO_VARIADIC_MACROS_FLAG)
+set(USE_NO_MAYBE_UNINITIALIZED 0)
+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.
+ check_cxx_compiler_flag("-Wuninitialized" HAS_UNINITIALIZED)
+ set(USE_NO_UNINITIALIZED ${HAS_UNINITIALIZED})
+ endif()
+endif()
+
include(GetHostTriple)
get_host_triple(LLVM_HOST_TRIPLE)
Index: cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -178,6 +178,14 @@
elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
if (LLVM_ENABLE_WARNINGS)
add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings )
+ # Turn off missing field initializer warnings for gcc to avoid noise from
+ # false positives with empty {}. Turn them on otherwise (they're off by
+ # default for clang).
+ if (CMAKE_COMPILER_IS_GNUCXX)
+ add_llvm_definitions( -Wno-missing-field-initializers )
+ else()
+ add_llvm_definitions( -Wmissing-field-initializers )
+ endif()
if (LLVM_ENABLE_PEDANTIC)
add_llvm_definitions( -pedantic -Wno-long-long )
endif (LLVM_ENABLE_PEDANTIC)
@@ -189,6 +197,12 @@
if( C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcovered-switch-default" )
endif()
+ if (USE_NO_UNINITIALIZED)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-uninitialized")
+ endif()
+ if (USE_NO_MAYBE_UNINITIALIZED)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
+ endif()
endif (LLVM_ENABLE_WARNINGS)
if (LLVM_ENABLE_WERROR)
add_llvm_definitions( -Werror )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D353.2.patch
Type: text/x-patch
Size: 2360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130131/676bfaa8/attachment.bin>
More information about the llvm-commits
mailing list