aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorDan Liew <dliew@apple.com>2021-02-09 23:02:50 -0800
committerDan Liew <dliew@apple.com>2021-02-25 12:02:21 -0800
commit5d64dd8e3c22e12e4f7b3d08ffe88fc41e727117 (patch)
tree33bce0075b204128335e835b35ae861fb6b93ad2 /clang/lib/Frontend/CompilerInvocation.cpp
parent169318088406510ce6816e6b022502a532b86d4b (diff)
downloadllvm-5d64dd8e3c22e12e4f7b3d08ffe88fc41e727117.zip
llvm-5d64dd8e3c22e12e4f7b3d08ffe88fc41e727117.tar.gz
llvm-5d64dd8e3c22e12e4f7b3d08ffe88fc41e727117.tar.bz2
[Clang][ASan] Introduce `-fsanitize-address-destructor-kind=` driver & frontend option.
The new `-fsanitize-address-destructor-kind=` option allows control over how module destructors are emitted by ASan. The new option is consumed by both the driver and the frontend and is propagated into codegen options by the frontend. Both the legacy and new pass manager code have been updated to consume the new option from the codegen options. It would be nice if the new utility functions (`AsanDtorKindToString` and `AsanDtorKindFromString`) could live in LLVM instead of Clang so they could be consumed by other language frontends. Unfortunately that doesn't work because the clang driver doesn't link against the LLVM instrumentation library. rdar://71609176 Differential Revision: https://reviews.llvm.org/D96572
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index eb44754..12dbd45 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1937,6 +1937,19 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
Opts.EmitVersionIdentMetadata = Args.hasFlag(OPT_Qy, OPT_Qn, true);
+ if (LangOptsRef.Sanitize.has(SanitizerKind::Address)) {
+ if (Arg *A =
+ Args.getLastArg(options::OPT_sanitize_address_destructor_kind_EQ)) {
+ auto destructorKind = AsanDtorKindFromString(A->getValue());
+ if (destructorKind == llvm::AsanDtorKind::Invalid) {
+ Diags.Report(clang::diag::err_drv_unsupported_option_argument)
+ << A->getOption().getName() << A->getValue();
+ } else {
+ Opts.setSanitizeAddressDtorKind(destructorKind);
+ }
+ }
+ }
+
if (Args.hasArg(options::OPT_ffinite_loops))
Opts.FiniteLoops = CodeGenOptions::FiniteLoopsKind::Always;
else if (Args.hasArg(options::OPT_fno_finite_loops))