[clang] 068b8af - [ARM][AArch64] Change -mharden-sls= to use err_drv_unsupported_option_argument

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 22:03:53 PDT 2022


Author: Fangrui Song
Date: 2022-05-27T22:03:48-07:00
New Revision: 068b8af7961caafadeffd1a99a103ef1d7a36e21

URL: https://github.com/llvm/llvm-project/commit/068b8af7961caafadeffd1a99a103ef1d7a36e21
DIFF: https://github.com/llvm/llvm-project/commit/068b8af7961caafadeffd1a99a103ef1d7a36e21.diff

LOG: [ARM][AArch64] Change -mharden-sls= to use err_drv_unsupported_option_argument

Update the diagnostic in D81404: the convention is to use
err_drv_unsupported_option_argument instead of adding a new diagnostic for every
option.

Reviewed By: nickdesaulniers

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

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticDriverKinds.td
    clang/lib/Driver/ToolChains/Arch/AArch64.cpp
    clang/lib/Driver/ToolChains/Arch/ARM.cpp
    clang/test/Driver/sls-hardening-options.c

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 3cc9565e6e8b2..ef08198273a16 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -428,8 +428,6 @@ def err_invalid_branch_protection: Error <
   "invalid branch protection option '%0' in '%1'">;
 def warn_unsupported_branch_protection: Warning <
   "invalid branch protection option '%0' in '%1'">, InGroup<BranchProtection>;
-def err_invalid_sls_hardening : Error<
-  "invalid sls hardening option '%0' in '%1'">;
 def err_sls_hardening_arm_not_supported : Error<
   "-mharden-sls is only supported on armv7-a or later">;
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index d82198ec678bf..b17743b728d92 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -324,8 +324,8 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
           DisableComdat = true;
           continue;
         }
-        D.Diag(diag::err_invalid_sls_hardening)
-            << Scope << A->getAsString(Args);
+        D.Diag(diag::err_drv_unsupported_option_argument)
+            << A->getOption().getName() << Scope;
         break;
       }
     }

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 68e8dc2e5f052..dc6b35e39cfdd 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -868,8 +868,8 @@ void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
           DisableComdat = true;
           continue;
         }
-        D.Diag(diag::err_invalid_sls_hardening)
-            << Scope << A->getAsString(Args);
+        D.Diag(diag::err_drv_unsupported_option_argument)
+            << A->getOption().getName() << Scope;
         break;
       }
     }

diff  --git a/clang/test/Driver/sls-hardening-options.c b/clang/test/Driver/sls-hardening-options.c
index cb35d8b5f99d0..4deb74e66f1de 100644
--- a/clang/test/Driver/sls-hardening-options.c
+++ b/clang/test/Driver/sls-hardening-options.c
@@ -99,7 +99,7 @@
 // NOCOMDAT-OFF-NOT: "harden-sls-nocomdat"
 // NOCOMDAT: "+harden-sls-nocomdat"
 
-// BAD-SLS-SPEC: invalid sls hardening option '{{[^']+}}' in '-mharden-sls=
+// BAD-SLS-SPEC: unsupported argument '{{[^']+}}' to option '-mharden-sls='
 
 // RUN: %clang -target armv6a--none-eabi -c %s -### -mharden-sls=all 2>&1 | \
 // RUN: FileCheck %s --check-prefix=SLS-NOT-SUPPORTED


        


More information about the cfe-commits mailing list