[llvm] r174299 - Turn off uninitialized-use warnings for gcc in cmake build
Edwin Vane
edwin.vane at intel.com
Sun Feb 3 18:32:44 PST 2013
Author: revane
Date: Sun Feb 3 20:32:44 2013
New Revision: 174299
URL: http://llvm.org/viewvc/llvm-project?rev=174299&view=rev
Log:
Turn off uninitialized-use warnings for gcc in cmake build
Added support to the cmake build to turn off uninitialized use warnings
for gcc. This cleans the build up somewhat.
Used logic simpler than found in autoconf by making use of the fact that
although gcc won't complain about unsupported -Wno-* flags it *will*
complain about unsupported -W flags.
Reviewers: gribozavr, doug.gregor, chandlerc
Modified:
llvm/trunk/cmake/config-ix.cmake
llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
Modified: llvm/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=174299&r1=174298&r2=174299&view=diff
==============================================================================
--- llvm/trunk/cmake/config-ix.cmake (original)
+++ llvm/trunk/cmake/config-ix.cmake Sun Feb 3 20:32:44 2013
@@ -305,6 +305,24 @@ include(CheckCXXCompilerFlag)
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)
Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=174299&r1=174298&r2=174299&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Sun Feb 3 20:32:44 2013
@@ -206,6 +206,12 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE
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 )
More information about the llvm-commits
mailing list