aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authorYaxun (Sam) Liu <yaxun.liu@amd.com>2021-10-06 23:55:26 -0400
committerYaxun (Sam) Liu <yaxun.liu@amd.com>2021-11-11 17:17:08 -0500
commit0309e50f33f616baa8fcac8365b728be3ccf06dd (patch)
tree581e7b4b8c65e2b338d53a0270ef92b056ca2486 /clang/lib/Driver/ToolChain.cpp
parent92fc60bc629b02eea31853223459ca5d78bc5dd4 (diff)
downloadllvm-0309e50f33f616baa8fcac8365b728be3ccf06dd.zip
llvm-0309e50f33f616baa8fcac8365b728be3ccf06dd.tar.gz
llvm-0309e50f33f616baa8fcac8365b728be3ccf06dd.tar.bz2
[Driver] Fix ToolChain::getSanitizerArgs
The driver uses class SanitizerArgs to store parsed sanitizer arguments. It keeps a cached SanitizerArgs object in ToolChain and uses it for different jobs. This does not work if the sanitizer options are different for different jobs, which could happen when an offloading toolchain translates the options for different jobs. To fix this, SanitizerArgs should be created by using the actual arguments passed to jobs instead of the original arguments passed to the driver, since the toolchain may change the original arguments. And the sanitizer arguments should be diagnose once. This patch also fixes HIP toolchain for handling -fgpu-sanitize: a warning is emitted for GPU's not supporting sanitizer and skipped. This is for backward compatibility with existing -fsanitize options. -fgpu-sanitize is also turned on by default. Reviewed by: Artem Belevich, Evgenii Stepanov Differential Revision: https://reviews.llvm.org/D111443
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r--clang/lib/Driver/ToolChain.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index debaf9e..d9fcff7 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -114,10 +114,11 @@ bool ToolChain::isNoExecStackDefault() const {
return false;
}
-const SanitizerArgs& ToolChain::getSanitizerArgs() const {
- if (!SanitizerArguments.get())
- SanitizerArguments.reset(new SanitizerArgs(*this, Args));
- return *SanitizerArguments.get();
+SanitizerArgs
+ToolChain::getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const {
+ SanitizerArgs SanArgs(*this, JobArgs, !SanitizerArgsChecked);
+ SanitizerArgsChecked = true;
+ return SanArgs;
}
const XRayArgs& ToolChain::getXRayArgs() const {