diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 441702abcc44..dee9bdc6e3ec 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -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)