delcypher added a comment.

@jansvoboda11 I noticed that the `Options.td` file is making use of some fancy 
mixins that mean the option gets automatically marshalled by the frontend into 
the codegen options :). I tried this out using the patch to this patch and all 
my tests seem to pass. Should I be using these mixins (I don't know how stable 
they are because this looks like a new feature). Am I using them properly? It 
seems that the driver still has to parse the option manually (which is actually 
what I want) but the frontend automagically parses the option and modifies the 
right codegen option for me.

  diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
  index 57aa469ff211..0e8ea7debfca 100644
  --- a/clang/include/clang/Driver/Options.td
  +++ b/clang/include/clang/Driver/Options.td
  @@ -1481,11 +1481,17 @@ defm sanitize_address_use_odr_indicator : 
BoolOption<"f", "sanitize-address-use-
               " reports in partially sanitized programs at the cost of an 
increase in binary size">,
     NegFlag<SetFalse, [], "Disable ODR indicator globals">>,
     Group<f_clang_Group>;
  -def sanitize_address_destructor_kind_EQ : Joined<["-"], 
"fsanitize-address-destructor-kind=">,
  -  MetaVarName<"<kind>">,
  -  Flags<[CC1Option]>,
  -  HelpText<"Set destructor type used in ASan instrumentation">,
  -  Group<f_clang_Group>;
  +def sanitize_address_destructor_kind_EQ
  +    : Joined<["-"], "fsanitize-address-destructor-kind=">,
  +      MetaVarName<"<kind>">,
  +      Flags<[CC1Option]>,
  +      HelpText<"Set destructor type used in ASan instrumentation">,
  +      Group<f_clang_Group>,
  +      Values<"none,global">,
  +      NormalizedValuesScope<"llvm::AsanDtorKind">,
  +      NormalizedValues<["None", "Global"]>,
  +      MarshallingInfoString<CodeGenOpts<"SanitizeAddressDtorKind">, 
"Global">,
  +      AutoNormalizeEnum;
   // Note: This flag was introduced when it was necessary to distinguish 
between
   //       ABI for correct codegen.  This is no longer needed, but the flag is
   //       not removed since targeting either ABI will behave the same.
  diff --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
  index a6baf026a7e8..0a12705a9261 100644
  --- a/clang/lib/Frontend/CompilerInvocation.cpp
  +++ b/clang/lib/Frontend/CompilerInvocation.cpp
  @@ -1511,19 +1511,6 @@ 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);
  -      }
  -    }
  -  }
  -
     return Success;
   }
   
  diff --git a/clang/test/CodeGen/asan-destructor-kind.cpp 
b/clang/test/CodeGen/asan-destructor-kind.cpp
  index 2bdb782db2b5..567482b72643 100644
  --- a/clang/test/CodeGen/asan-destructor-kind.cpp
  +++ b/clang/test/CodeGen/asan-destructor-kind.cpp
  @@ -3,7 +3,7 @@
   // RUN:   -fsanitize-address-destructor-kind=bad_arg -emit-llvm -o - \
   // RUN:   -triple x86_64-apple-macosx10.15 %s 2>&1 | \
   // RUN:   FileCheck %s --check-prefixes=CHECK-BAD-ARG
  -// CHECK-BAD-ARG: unsupported argument 'bad_arg' to option 
'fsanitize-address-destructor-kind='
  +// CHECK-BAD-ARG: invalid value 'bad_arg' in 
'-fsanitize-address-destructor-kind=bad_arg'
   
   // Default is global dtor
   // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple 
x86_64-apple-macosx10.15 \


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96572/new/

https://reviews.llvm.org/D96572

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to