]> granicus.if.org Git - llvm/commitdiff
cmake: Only sanitize use-after-scope if the host compiler supports it
authorJustin Bogner <mail@justinbogner.com>
Wed, 18 Jan 2017 19:01:58 +0000 (19:01 +0000)
committerJustin Bogner <mail@justinbogner.com>
Wed, 18 Jan 2017 19:01:58 +0000 (19:01 +0000)
In r292256, we started adding -fsanitize-use-after-scope when using
the address sanitizer, but that flag wasn't always available. This
fixes the config to only add the flag if the host compiler supports
it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292423 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/HandleLLVMOptions.cmake

index 441702abcc44e64ba6a60b23ad52ac451e4ee5fd..dee9bdc6e3ecddfbd9ea6536c1e46a4f83a4bdee 100644 (file)
@@ -589,7 +589,8 @@ if(LLVM_USE_SANITIZER)
     message(FATAL_ERROR "LLVM_USE_SANITIZER is not supported on this platform.")
   endif()
   if (LLVM_USE_SANITIZER MATCHES "(Undefined;)?Address(;Undefined)?")
-    append("-fsanitize-address-use-after-scope" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+    add_flag_if_supported("-fsanitize-address-use-after-scope"
+                          FSANITIZE_USE_AFTER_SCOPE_FLAG)
   endif()
   if (LLVM_USE_SANITIZE_COVERAGE)
     append("-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)