]> granicus.if.org Git - clang/commitdiff
Driver: enable support for -fsanitize=cfi on Windows.
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 8 Jul 2015 21:08:05 +0000 (21:08 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 8 Jul 2015 21:08:05 +0000 (21:08 +0000)
There are known issues, but the current implementation is good enough for
the check-cfi test suite.

Differential Revision: http://reviews.llvm.org/D11030

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

lib/Driver/MSVCToolChain.cpp
lib/Driver/SanitizerArgs.cpp
test/Driver/fsanitize.c

index f20f58a119f47cb3bc87a76ce5efcf17b13b5288..c816b29dca237dab07c4dda8d5dc3fabbce93d81 100644 (file)
@@ -526,8 +526,5 @@ MSVCToolChain::ComputeEffectiveClangTriple(const ArgList &Args,
 SanitizerMask MSVCToolChain::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
-  // CFI checks are not implemented for MSVC ABI for now.
-  Res &= ~SanitizerKind::CFI;
-  Res &= ~SanitizerKind::CFICastStrict;
   return Res;
 }
index 3043481c713240908aa3ca581b0c3be3dc19d3a0..d59c85e39dccbb17272414e6bc7346d077f3bc6f 100644 (file)
@@ -289,8 +289,12 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
   // toolchain. We don't have a good way to check the latter, so we just
   // check if the toolchan supports vptr.
   if (~Supported & Vptr) {
-    if (SanitizerMask KindsToDiagnose =
-            Kinds & ~TrappingKinds & NeedsUbsanCxxRt) {
+    SanitizerMask KindsToDiagnose = Kinds & ~TrappingKinds & NeedsUbsanCxxRt;
+    // The runtime library supports the Microsoft C++ ABI, but only well enough
+    // for CFI. FIXME: Remove this once we support vptr on Windows.
+    if (TC.getTriple().isOSWindows())
+      KindsToDiagnose &= ~CFI;
+    if (KindsToDiagnose) {
       SanitizerSet S;
       S.Mask = KindsToDiagnose;
       D.Diag(diag::err_drv_unsupported_opt_for_target)
index 96d0781016954c4ac30533788b210462931c11c8..8b5b76f0457e18aca2eb920f33ac8c3b9377e6cb 100644 (file)
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.7 -flto -fsanitize=cfi-vcall -fno-sanitize-trap=cfi -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOTRAP-OLD-MACOS
 // CHECK-CFI-NOTRAP-OLD-MACOS: error: unsupported option '-fno-sanitize-trap=cfi-vcall' for target 'x86_64-apple-darwin10'
 
+// RUN: %clang -target x86_64-pc-win32 -flto -fsanitize=cfi-vcall -fno-sanitize-trap=cfi -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOTRAP-WIN
+// CHECK-CFI-NOTRAP-WIN: -emit-llvm-bc
+// CHECK-CFI-NOTRAP-WIN-NOT: -fsanitize-trap=cfi
+
 // RUN: %clang_cl -fsanitize=address -c -MDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -MTd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL
 // RUN: %clang_cl -fsanitize=address -c -LDd -### -- %s 2>&1 | FileCheck %s -check-prefix=CHECK-ASAN-DEBUGRTL