[PATCH] D18014: Allows to build libc++ with -DLLVM_USE_SANITIZER="Address; Undefined" on OSX

Chris Bieneman via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 9 16:02:10 PST 2016


beanz added inline comments.

================
Comment at: lib/CMakeLists.txt:51
@@ -50,2 +50,3 @@
 if (APPLE AND LLVM_USE_SANITIZER)
-  if ("${LLVM_USE_SANITIZER}" STREQUAL "Address")
+  if ("${LLVM_USE_SANITIZER}" STREQUAL "Address" OR
+      "${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined" OR
----------------
Rather than doing this as a STREQUAL where you have to check both possible orders, maybe we should iterate over the list?

Something more like:


```
foreach(sanitizer in ${LLVM_USE_SANITIZER})
  if(sanitizer STREQUAL "Address")
    set(enable_address On)
  endif()
  if(sanitizer STREQUAL "Undefined")
    set(enable_ub On)
  endif()
  ... <other sanitizers>
endforeach()

if(enable_address and enable_undefined)
...
elseif(...)
endif()
```

I think doing it this way makes the code more adaptable to future changes.

Alternatively you can get rid of needing to check both orders by using the list(FIND ...) CMake command, which might be cleaner too.


Repository:
  rL LLVM

http://reviews.llvm.org/D18014





More information about the cfe-commits mailing list