[clang] 2d42b2e - [ASan] Rename `-fsanitize-address-destructor-kind=` to drop the `-kind` suffix.

Dan Liew via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 29 11:56:01 PDT 2021


Author: Dan Liew
Date: 2021-04-29T11:55:42-07:00
New Revision: 2d42b2ee7bafe76d6b2c792b73f7371cb1cf8d94

URL: https://github.com/llvm/llvm-project/commit/2d42b2ee7bafe76d6b2c792b73f7371cb1cf8d94
DIFF: https://github.com/llvm/llvm-project/commit/2d42b2ee7bafe76d6b2c792b73f7371cb1cf8d94.diff

LOG: [ASan] Rename `-fsanitize-address-destructor-kind=` to drop the `-kind` suffix.

Renaming the option is based on discussions in https://reviews.llvm.org/D101122.

It is normally not a good idea to rename driver flags but this flag is
new enough and obscure enough that it is very unlikely to have adopters.

While we're here also drop the `<kind>` metavar. It's not necessary and
is actually inconsistent with the documentation in
`clang/docs/ClangCommandLineReference.rst`.

Differential Revision: https://reviews.llvm.org/D101491

Added: 
    clang/test/Driver/fsanitize-address-destructor.c

Modified: 
    clang/docs/ClangCommandLineReference.rst
    clang/include/clang/Driver/Options.td
    clang/lib/Driver/SanitizerArgs.cpp
    clang/test/CodeGen/asan-destructor-kind.cpp
    clang/test/Driver/darwin-asan-mkernel-kext.c

Removed: 
    clang/test/Driver/fsanitize-address-destructor-kind.c


################################################################################
diff  --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst
index 24e0040a4f50d..6b67dc07982bd 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -870,7 +870,7 @@ Enable use-after-scope detection in AddressSanitizer
 
 Enable ODR indicator globals to avoid false ODR violation reports in partially sanitized programs at the cost of an increase in binary size
 
-.. option:: -fsanitize-address-destructor-kind=<arg>
+.. option:: -fsanitize-address-destructor=<arg>
 
 Set the kind of module destructors emitted by AddressSanitizer instrumentation.
 These destructors are emitted to unregister instrumented global variables when

diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index eaebed5978368..8c9033ded10b6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1539,9 +1539,8 @@ 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>">,
+def sanitize_address_destructor_EQ
+    : Joined<["-"], "fsanitize-address-destructor=">,
       Flags<[CC1Option]>,
       HelpText<"Set destructor type used in ASan instrumentation">,
       Group<f_clang_Group>,

diff  --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 0f9f5d87696c4..8cb4f50eaac47 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -832,7 +832,7 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
     }
 
     if (const auto *Arg =
-            Args.getLastArg(options::OPT_sanitize_address_destructor_kind_EQ)) {
+            Args.getLastArg(options::OPT_sanitize_address_destructor_EQ)) {
       auto parsedAsanDtorKind = AsanDtorKindFromString(Arg->getValue());
       if (parsedAsanDtorKind == llvm::AsanDtorKind::Invalid) {
         TC.getDriver().Diag(clang::diag::err_drv_unsupported_option_argument)
@@ -1098,7 +1098,7 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
   // Only pass the option to the frontend if the user requested,
   // otherwise the frontend will just use the codegen default.
   if (AsanDtorKind != llvm::AsanDtorKind::Invalid) {
-    CmdArgs.push_back(Args.MakeArgString("-fsanitize-address-destructor-kind=" +
+    CmdArgs.push_back(Args.MakeArgString("-fsanitize-address-destructor=" +
                                          AsanDtorKindToString(AsanDtorKind)));
   }
 

diff  --git a/clang/test/CodeGen/asan-destructor-kind.cpp b/clang/test/CodeGen/asan-destructor-kind.cpp
index 567482b726435..8d70b663f67a2 100644
--- a/clang/test/CodeGen/asan-destructor-kind.cpp
+++ b/clang/test/CodeGen/asan-destructor-kind.cpp
@@ -1,9 +1,9 @@
 // Frontend rejects invalid option
 // RUN: not %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=bad_arg -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=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: invalid value 'bad_arg' in '-fsanitize-address-destructor-kind=bad_arg'
+// CHECK-BAD-ARG: invalid value 'bad_arg' in '-fsanitize-address-destructor=bad_arg'
 
 // Default is global dtor
 // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-apple-macosx10.15 \
@@ -16,12 +16,12 @@
 
 // Explictly ask for global dtor
 // RUN: %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=global -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
 // RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
 //
 // RUN: %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=global -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=global -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
 // RUN:   FileCheck %s --check-prefixes=CHECK-GLOBAL-DTOR
 
@@ -30,12 +30,12 @@
 
 // Explictly ask for no dtors
 // RUN: %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=none -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=none -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 -fno-legacy-pass-manager %s | \
 // RUN:   FileCheck %s --check-prefixes=CHECK-NONE-DTOR
 //
 // RUN: %clang_cc1 -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=none -emit-llvm -o - \
+// RUN:   -fsanitize-address-destructor=none -emit-llvm -o - \
 // RUN:   -triple x86_64-apple-macosx10.15 -flegacy-pass-manager %s | \
 // RUN:   FileCheck %s --check-prefixes=CHECK-NONE-DTOR
 

diff  --git a/clang/test/Driver/darwin-asan-mkernel-kext.c b/clang/test/Driver/darwin-asan-mkernel-kext.c
index 7827d2ec3fd11..5622e78bf7483 100644
--- a/clang/test/Driver/darwin-asan-mkernel-kext.c
+++ b/clang/test/Driver/darwin-asan-mkernel-kext.c
@@ -5,11 +5,11 @@
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
 // RUN:   -mkernel -### %s 2>&1 | FileCheck %s
 
-// CHECK: "-fsanitize-address-destructor-kind=none"
+// CHECK: "-fsanitize-address-destructor=none"
 
 // Check it's possible to override the driver's decision.
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=address -fapple-kext \
-// RUN:   -mkernel -### -fsanitize-address-destructor-kind=global %s 2>&1 | \
+// RUN:   -mkernel -### -fsanitize-address-destructor=global %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-OVERRIDE %s
 
-// CHECK-OVERRIDE: "-fsanitize-address-destructor-kind=global"
+// CHECK-OVERRIDE: "-fsanitize-address-destructor=global"

diff  --git a/clang/test/Driver/fsanitize-address-destructor-kind.c b/clang/test/Driver/fsanitize-address-destructor.c
similarity index 59%
rename from clang/test/Driver/fsanitize-address-destructor-kind.c
rename to clang/test/Driver/fsanitize-address-destructor.c
index b1f070bf1ad2f..70cb2fe6e2a65 100644
--- a/clang/test/Driver/fsanitize-address-destructor-kind.c
+++ b/clang/test/Driver/fsanitize-address-destructor.c
@@ -2,19 +2,19 @@
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address %s \
 // RUN:   -### 2>&1 | \
 // RUN:   FileCheck %s
-// CHECK-NOT: -fsanitize-address-destructor-kind
+// CHECK-NOT: -fsanitize-address-destructor
 
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=none %s -### 2>&1 | \
+// RUN:   -fsanitize-address-destructor=none %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-NONE-ARG %s
-// CHECK-NONE-ARG: "-fsanitize-address-destructor-kind=none"
+// CHECK-NONE-ARG: "-fsanitize-address-destructor=none"
 
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=global %s -### 2>&1 | \
+// RUN:   -fsanitize-address-destructor=global %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-GLOBAL-ARG %s
-// CHECK-GLOBAL-ARG: "-fsanitize-address-destructor-kind=global"
+// CHECK-GLOBAL-ARG: "-fsanitize-address-destructor=global"
 
 // RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
-// RUN:   -fsanitize-address-destructor-kind=bad_arg %s -### 2>&1 | \
+// RUN:   -fsanitize-address-destructor=bad_arg %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=CHECK-INVALID-ARG %s
-// CHECK-INVALID-ARG: error: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor-kind='
+// CHECK-INVALID-ARG: error: unsupported argument 'bad_arg' to option 'fsanitize-address-destructor='


        


More information about the cfe-commits mailing list