summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/test
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Fuzzer/test')
-rw-r--r--llvm/lib/Fuzzer/test/CMakeLists.txt29
-rw-r--r--llvm/lib/Fuzzer/test/dfsan/CMakeLists.txt4
-rw-r--r--llvm/lib/Fuzzer/test/trace-bb/CMakeLists.txt2
-rw-r--r--llvm/lib/Fuzzer/test/trace-pc/CMakeLists.txt4
-rw-r--r--llvm/lib/Fuzzer/test/ubsan/CMakeLists.txt4
-rw-r--r--llvm/lib/Fuzzer/test/uninstrumented/CMakeLists.txt4
6 files changed, 35 insertions, 12 deletions
diff --git a/llvm/lib/Fuzzer/test/CMakeLists.txt b/llvm/lib/Fuzzer/test/CMakeLists.txt
index 7bba1d63a92..5703de804cf 100644
--- a/llvm/lib/Fuzzer/test/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/CMakeLists.txt
@@ -1,8 +1,31 @@
# Build all these tests with -O0, otherwise optimizations may merge some
# basic blocks and we'll fail to discover the targets.
-# Also enable the coverage instrumentation back (it is disabled
-# for the Fuzzer lib)
-set(CMAKE_CXX_FLAGS_RELEASE "${LIBFUZZER_FLAGS_BASE} -O0 -fsanitize-coverage=edge,indirect-calls")
+# We change the flags for every build type because we might be doing
+# a multi-configuration build (e.g. Xcode) where CMAKE_BUILD_TYPE doesn't
+# mean anything.
+set(variables_to_filter
+ CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_DEBUG
+ CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS_MINSIZEREL
+ LIBFUZZER_FLAGS_BASE
+ )
+foreach (VARNAME ${variables_to_filter})
+ string(REPLACE " " ";" BUILD_FLAGS_AS_LIST "${${VARNAME}}")
+ set(new_flags "")
+ foreach (flag ${BUILD_FLAGS_AS_LIST})
+ # NOTE: Use of XX here is to avoid a CMake warning due to CMP0054
+ if (NOT ("XX${flag}" MATCHES "XX-O[0123s]"))
+ set(new_flags "${new_flags} ${flag}")
+ else()
+ set(new_flags "${new_flags} -O0")
+ endif()
+ endforeach()
+ set(${VARNAME} "${new_flags}")
+endforeach()
+
+# Enable the coverage instrumentation (it is disabled for the Fuzzer lib).
+set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fsanitize-coverage=edge,indirect-calls")
set(DFSanTests
MemcmpTest
diff --git a/llvm/lib/Fuzzer/test/dfsan/CMakeLists.txt b/llvm/lib/Fuzzer/test/dfsan/CMakeLists.txt
index 2b49831fcdb..362a4566711 100644
--- a/llvm/lib/Fuzzer/test/dfsan/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/dfsan/CMakeLists.txt
@@ -1,7 +1,7 @@
# These tests depend on both coverage and dfsan instrumentation.
-set(CMAKE_CXX_FLAGS_RELEASE
- "${LIBFUZZER_FLAGS_BASE} -O0 -fno-sanitize=all -fsanitize=dataflow")
+set(CMAKE_CXX_FLAGS
+ "${LIBFUZZER_FLAGS_BASE} -fno-sanitize=all -fsanitize=dataflow")
foreach(Test ${DFSanTests})
add_executable(LLVMFuzzer-${Test}-DFSan
diff --git a/llvm/lib/Fuzzer/test/trace-bb/CMakeLists.txt b/llvm/lib/Fuzzer/test/trace-bb/CMakeLists.txt
index 99af019565b..915ae365734 100644
--- a/llvm/lib/Fuzzer/test/trace-bb/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/trace-bb/CMakeLists.txt
@@ -1,6 +1,6 @@
# These tests are not instrumented with coverage.
-set(CMAKE_CXX_FLAGS_RELEASE
+set(CMAKE_CXX_FLAGS
"${LIBFUZZER_FLAGS_BASE} -fsanitize-coverage=edge,trace-bb")
foreach(Test ${TraceBBTests})
diff --git a/llvm/lib/Fuzzer/test/trace-pc/CMakeLists.txt b/llvm/lib/Fuzzer/test/trace-pc/CMakeLists.txt
index f921a61ecba..94bd5f66877 100644
--- a/llvm/lib/Fuzzer/test/trace-pc/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/trace-pc/CMakeLists.txt
@@ -1,7 +1,7 @@
# These tests are not instrumented with coverage.
-set(CMAKE_CXX_FLAGS_RELEASE
- "${LIBFUZZER_FLAGS_BASE} -O0 -fno-sanitize-coverage=8bit-counters -fsanitize-coverage=trace-pc")
+set(CMAKE_CXX_FLAGS
+ "${LIBFUZZER_FLAGS_BASE} -fno-sanitize-coverage=8bit-counters -fsanitize-coverage=trace-pc")
foreach(Test ${TracePCTests})
add_executable(LLVMFuzzer-${Test}-TracePC
diff --git a/llvm/lib/Fuzzer/test/ubsan/CMakeLists.txt b/llvm/lib/Fuzzer/test/ubsan/CMakeLists.txt
index 5547704525e..b7d0f500a75 100644
--- a/llvm/lib/Fuzzer/test/ubsan/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/ubsan/CMakeLists.txt
@@ -1,7 +1,7 @@
# These tests are instrumented with ubsan in non-recovery mode.
-set(CMAKE_CXX_FLAGS_RELEASE
- "${LIBFUZZER_FLAGS_BASE} -O0 -fsanitize=undefined -fno-sanitize-recover=all")
+set(CMAKE_CXX_FLAGS
+ "${LIBFUZZER_FLAGS_BASE} -fsanitize=undefined -fno-sanitize-recover=all")
foreach(Test ${UbsanTests})
add_executable(LLVMFuzzer-${Test}-Ubsan
diff --git a/llvm/lib/Fuzzer/test/uninstrumented/CMakeLists.txt b/llvm/lib/Fuzzer/test/uninstrumented/CMakeLists.txt
index 28df1c688bd..b4d7e4a2a65 100644
--- a/llvm/lib/Fuzzer/test/uninstrumented/CMakeLists.txt
+++ b/llvm/lib/Fuzzer/test/uninstrumented/CMakeLists.txt
@@ -1,7 +1,7 @@
# These tests are not instrumented with coverage.
-set(CMAKE_CXX_FLAGS_RELEASE
- "${LIBFUZZER_FLAGS_BASE} -O0 -fno-sanitize=all -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")
+set(CMAKE_CXX_FLAGS
+ "${LIBFUZZER_FLAGS_BASE} -fno-sanitize=all -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")
foreach(Test ${UninstrumentedTests})
add_executable(LLVMFuzzer-${Test}-Uninstrumented
OpenPOWER on IntegriCloud