summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-04-28 00:18:30 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-04-28 00:18:30 +0000
commitf10237b689db7afc3405e2fa4f1ba43bfee8b489 (patch)
tree05aa736d17522090f3460ff58bcfb192b52ac64c
parent893110ecafee4113b24319f6d47b3ef341d9d803 (diff)
downloadbcm5719-llvm-f10237b689db7afc3405e2fa4f1ba43bfee8b489.tar.gz
bcm5719-llvm-f10237b689db7afc3405e2fa4f1ba43bfee8b489.zip
Driver: only produce CFI -fvisibility= error when compiling.
The -fvisibility= flag only affects compile jobs, so there's no need to error out because of it if we aren't compiling (e.g. if we are only linking). llvm-svn: 267824
-rw-r--r--clang/lib/Driver/SanitizerArgs.cpp18
-rw-r--r--clang/test/Driver/fsanitize.c6
2 files changed, 14 insertions, 10 deletions
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 6f19a2fa96b..c63ff4be8a7 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -561,14 +561,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
LinkCXXRuntimes =
Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX();
- // Require -fvisibility= flag on non-Windows if vptr CFI is enabled.
- if ((Kinds & CFIClasses) && !TC.getTriple().isOSWindows() &&
- !Args.hasArg(options::OPT_fvisibility_EQ)) {
- D.Diag(clang::diag::err_drv_argument_only_allowed_with)
- << lastArgumentForMask(D, Args, Kinds & CFIClasses)
- << "-fvisibility=";
- }
-
// Finally, initialize the set of available and recoverable sanitizers.
Sanitizers.Mask |= Kinds;
RecoverableSanitizers.Mask |= RecoverableKinds;
@@ -690,6 +682,16 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
TC.getCompilerRT(Args, "stats")));
addIncludeLinkerOption(TC, Args, CmdArgs, "__sanitizer_stats_register");
}
+
+ // Require -fvisibility= flag on non-Windows when compiling if vptr CFI is
+ // enabled.
+ if (Sanitizers.hasOneOf(CFIClasses) && !TC.getTriple().isOSWindows() &&
+ !Args.hasArg(options::OPT_fvisibility_EQ)) {
+ TC.getDriver().Diag(clang::diag::err_drv_argument_only_allowed_with)
+ << lastArgumentForMask(TC.getDriver(), Args,
+ Sanitizers.Mask & CFIClasses)
+ << "-fvisibility=";
+ }
}
SanitizerMask parseArgValues(const Driver &D, const llvm::opt::Arg *A,
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index df3d71cbb06..40cd49525ef 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -309,8 +309,10 @@
// RUN: %clang -target x86_64-linux-gnu -flto -fsanitize=cfi-derived-cast -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOVIS
// CHECK-CFI-NOVIS: '-fsanitize=cfi-derived-cast' only allowed with '-fvisibility='
-// RUN: %clang -target x86_64-pc-win32 -flto -fsanitize=cfi-derived-cast -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOVIS-WIN
-// CHECK-CFI-NOVIS-WIN-NOT: only allowed with
+// RUN: %clang -target x86_64-pc-win32 -flto -fsanitize=cfi-derived-cast -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOVIS-NOERROR
+// RUN: echo > %t.o
+// RUN: %clang -target x86_64-linux-gnu -flto -fsanitize=cfi-derived-cast %t.o -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOVIS-NOERROR
+// CHECK-CFI-NOVIS-NOERROR-NOT: only allowed with
// RUN: %clang -target mips-unknown-linux -fsanitize=cfi-icall %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-ICALL-MIPS
// CHECK-CFI-ICALL-MIPS: unsupported option '-fsanitize=cfi-icall' for target 'mips-unknown-linux'
OpenPOWER on IntegriCloud