cmake: Only sanitize use-after-scope if the host compiler supports it

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.

llvm-svn: 292423
This commit is contained in:
Justin Bogner 2017-01-18 19:01:58 +00:00
parent 7960b2e19a
commit 2ceeb30eb6
1 changed files with 2 additions and 1 deletions

View File

@ -589,7 +589,8 @@ if(LLVM_USE_SANITIZER)
message(FATAL_ERROR "LLVM_USE_SANITIZER is not supported on this platform.") message(FATAL_ERROR "LLVM_USE_SANITIZER is not supported on this platform.")
endif() endif()
if (LLVM_USE_SANITIZER MATCHES "(Undefined;)?Address(;Undefined)?") 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() endif()
if (LLVM_USE_SANITIZE_COVERAGE) if (LLVM_USE_SANITIZE_COVERAGE)
append("-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) append("-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)