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.

llvm-svn: 235953

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

index cd3785c..f453208 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 994b2b2..280b6e6 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 7cbc37f..5fef817 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 \