]> granicus.if.org Git - clang/commitdiff
Allow UBSan+MSan and UBSan+TSan combinations (Clang part).
authorAlexey Samsonov <vonosmas@gmail.com>
Tue, 28 Apr 2015 00:56:36 +0000 (00:56 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Tue, 28 Apr 2015 00:56:36 +0000 (00:56 +0000)
Embed UBSan runtime into TSan and MSan runtimes in the same as we do
in ASan. Extend UBSan test suite to also run tests for these
combinations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235953 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/SanitizerArgs.cpp
test/Driver/fsanitize.c
test/Driver/sanitizer-ld.c

index cd3785cd90b9d6d5d59a29340aacdb5e27ba1a22..f453208503fa5d3b736b6df59e934c9f95c44cdb 100644 (file)
@@ -160,7 +160,9 @@ static bool getDefaultBlacklist(const Driver &D, uint64_t Kinds,
 
 bool SanitizerArgs::needsUbsanRt() const {
   return !UbsanTrapOnError && hasOneOf(Sanitizers, NeedsUbsanRt) &&
-         !Sanitizers.has(SanitizerKind::Address);
+         !Sanitizers.has(SanitizerKind::Address) &&
+         !Sanitizers.has(SanitizerKind::Memory) &&
+         !Sanitizers.has(SanitizerKind::Thread);
 }
 
 bool SanitizerArgs::requiresPIE() const {
@@ -284,9 +286,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
       std::make_pair(SanitizeKind::Address, SanitizeKind::Memory),
       std::make_pair(SanitizeKind::Thread, SanitizeKind::Memory),
       std::make_pair(SanitizeKind::Leak, SanitizeKind::Thread),
-      std::make_pair(SanitizeKind::Leak, SanitizeKind::Memory),
-      std::make_pair(SanitizeKind::NeedsUbsanRt, SanitizeKind::Thread),
-      std::make_pair(SanitizeKind::NeedsUbsanRt, SanitizeKind::Memory)};
+      std::make_pair(SanitizeKind::Leak, SanitizeKind::Memory)};
   for (auto G : IncompatibleGroups) {
     uint64_t Group = G.first;
     if (Kinds & Group) {
index 994b2b236c4f408965740c2f9ebfe8e02c67f8d8..280b6e6e31310140c33c0a17388f0eb4d3fb49ef 100644 (file)
@@ -57,9 +57,6 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak,memory -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-SANM
 // CHECK-SANL-SANM: '-fsanitize=leak' not allowed with '-fsanitize=memory'
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=signed-integer-overflow,memory -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-UBSAN
-// CHECK-MSAN-UBSAN: '-fsanitize=signed-integer-overflow' not allowed with '-fsanitize=memory'
-
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'
 
index 7cbc37ff0c80568737e7b213f35365d939fa309e..5fef8170e31edcc550f45d32229fb75a2e6c9b70 100644 (file)
 // CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"
 // CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
 
+// RUN: %clangxx -fsanitize=memory,undefined %s -### -o %t.o 2>&1 \
+// RUN:     -target x86_64-unknown-linux \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-MSAN-UBSAN-LINUX-CXX %s
+// CHECK-MSAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MSAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
+// CHECK-MSAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan
+
+// RUN: %clangxx -fsanitize=thread,undefined %s -### -o %t.o 2>&1 \
+// RUN:     -target x86_64-unknown-linux \
+// RUN:     --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-TSAN-UBSAN-LINUX-CXX %s
+// CHECK-TSAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-TSAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
+// CHECK-TSAN-UBSAN-LINUX-CXX-NOT: libclang_rt.ubsan
+
 // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
 // RUN:     -target i386-unknown-linux \
 // RUN:     -resource-dir=%S/Inputs/resource_dir \