diff options
| author | Alexey Samsonov <vonosmas@gmail.com> | 2014-08-08 22:47:17 +0000 |
|---|---|---|
| committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-08-08 22:47:17 +0000 |
| commit | 90490af21d42cc8142812ac91813828b62f0862d (patch) | |
| tree | 162974d7b76b59f44cb50b1d8d6d352169848611 /clang/lib | |
| parent | 4cbff5c76fb3236195a93dc595fbf1faa0e9e53f (diff) | |
| download | bcm5719-llvm-90490af21d42cc8142812ac91813828b62f0862d.tar.gz bcm5719-llvm-90490af21d42cc8142812ac91813828b62f0862d.zip | |
Add -link-cxx-sanitizer driver flag.
Summary:
This flag can be used to force linking of CXX-specific parts
of sanitizer runtimes into the final executable. It gives more precise
control than --driver-mode=g++ and comes handy when user links several
object files with sanitized C++ code into an executable, but wants
to provide libstdc++ himself, instead of relying on Clang dirver's
behavior.
Test Plan: clang regression test suite
Reviewers: chandlerc, rsmith
Reviewed By: rsmith
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D4824
llvm-svn: 215252
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Driver/SanitizerArgs.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/Driver/Tools.cpp | 10 |
2 files changed, 10 insertions, 9 deletions
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index b64f0275768..c192034236d 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -28,10 +28,7 @@ void SanitizerArgs::clear() { AsanZeroBaseShadow = false; UbsanTrapOnError = false; AsanSharedRuntime = false; -} - -SanitizerArgs::SanitizerArgs() { - clear(); + LinkCXXRuntimes = false; } SanitizerArgs::SanitizerArgs(const ToolChain &TC, @@ -168,6 +165,10 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC, AsanZeroBaseShadow = (TC.getTriple().getEnvironment() == llvm::Triple::Android); } + + // Parse -link-cxx-sanitizer flag. + LinkCXXRuntimes = + Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX(); } void SanitizerArgs::addArgs(const llvm::opt::ArgList &Args, diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 860454a22b7..65760b49baa 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -2273,13 +2273,13 @@ static void addDfsanRT(const ToolChain &TC, const ArgList &Args, static void addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args, ArgStringList &CmdArgs) { const SanitizerArgs &Sanitize = TC.getSanitizerArgs(); - const Driver &D = TC.getDriver(); if (Sanitize.needsUbsanRt()) - addUbsanRT(TC, Args, CmdArgs, D.CCCIsCXX(), - Sanitize.needsAsanRt() || Sanitize.needsTsanRt() || - Sanitize.needsMsanRt() || Sanitize.needsLsanRt()); + addUbsanRT(TC, Args, CmdArgs, Sanitize.linkCXXRuntimes(), + Sanitize.needsAsanRt() || Sanitize.needsTsanRt() || + Sanitize.needsMsanRt() || Sanitize.needsLsanRt()); if (Sanitize.needsAsanRt()) - addAsanRT(TC, Args, CmdArgs, Sanitize.needsSharedAsanRt(), D.CCCIsCXX()); + addAsanRT(TC, Args, CmdArgs, Sanitize.needsSharedAsanRt(), + Sanitize.linkCXXRuntimes()); if (Sanitize.needsTsanRt()) addTsanRT(TC, Args, CmdArgs); if (Sanitize.needsMsanRt()) |

