[UBSan] Also use blacklist for 'Address; Undefined' setting
authorFlorian Hahn <florian.hahn@arm.com>
Fri, 20 Jul 2018 10:12:31 +0000 (10:12 +0000)
committerFlorian Hahn <florian.hahn@arm.com>
Fri, 20 Jul 2018 10:12:31 +0000 (10:12 +0000)
It looks like currently the UBSan blacklist is only applied when "Undefined" is selected.
This patch updates the cmake file to apply it whenever Undefined is selected
 (e.g. 'Address; Undefined' ). This  allows us to use the workaround added in
rL335525 when using AddressSan and UBSan together.

Reviewers: eugenis, vitalybuka

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D49558

llvm-svn: 337539

llvm/cmake/modules/HandleLLVMOptions.cmake

index efaad89..5fd318f 100644 (file)
@@ -670,11 +670,6 @@ if(LLVM_USE_SANITIZER)
       append_common_sanitizer_flags()
       append("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
               CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
-      set(BLACKLIST_FILE "${CMAKE_SOURCE_DIR}/utils/sanitizers/ubsan_blacklist.txt")
-      if (EXISTS "${BLACKLIST_FILE}")
-        append("-fsanitize-blacklist=${BLACKLIST_FILE}"
-                     CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
-      endif()
     elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
       append_common_sanitizer_flags()
       append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
@@ -706,6 +701,13 @@ if(LLVM_USE_SANITIZER)
   if (LLVM_USE_SANITIZE_COVERAGE)
     append("-fsanitize=fuzzer-no-link" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
   endif()
+  if (LLVM_USE_SANITIZER MATCHES ".*Undefined.*")
+    set(BLACKLIST_FILE "${CMAKE_SOURCE_DIR}/utils/sanitizers/ubsan_blacklist.txt")
+    if (EXISTS "${BLACKLIST_FILE}")
+      append("-fsanitize-blacklist=${BLACKLIST_FILE}"
+             CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+    endif()
+  endif()
 endif()
 
 # Turn on -gsplit-dwarf if requested