[clang] 57fa688 - [Driver][ARM][AArch64] Use err_drv_unsupported_option_argument for -march=/-mcpu=/-mtune= diagnostics

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 28 16:01:34 PDT 2022


Author: Fangrui Song
Date: 2022-06-28T16:01:30-07:00
New Revision: 57fa68897bb76e1fe5442784bca4e0629033c384

URL: https://github.com/llvm/llvm-project/commit/57fa68897bb76e1fe5442784bca4e0629033c384
DIFF: https://github.com/llvm/llvm-project/commit/57fa68897bb76e1fe5442784bca4e0629033c384.diff

LOG: [Driver][ARM][AArch64] Use err_drv_unsupported_option_argument for -march=/-mcpu=/-mtune= diagnostics

err_drv_clang_unsupported is for a Clang unsupported option (any value is rejected).
err_drv_unsupported_option_argument is for an unsupported value (other values may be supported).

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Arch/AArch64.cpp
    clang/lib/Driver/ToolChains/Arch/ARM.cpp
    clang/test/Driver/aarch64-target-as-march.s
    clang/test/Driver/arm-cortex-cpus-2.c
    clang/test/Driver/arm-ias-Wa.s
    clang/test/Preprocessor/aarch64-target-features.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index b17743b728d92..cf7e201b4972c 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -265,13 +265,13 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
         D, getAArch64TargetCPU(Args, Triple, A), Args, Features);
 
   if (!success) {
-    auto Diag = D.Diag(diag::err_drv_clang_unsupported);
+    auto Diag = D.Diag(diag::err_drv_unsupported_option_argument);
     // If "-Wa,-march=" is used, 'WaMArch' will contain the argument's value,
     // while 'A' is uninitialized. Only dereference 'A' in the other case.
     if (!WaMArch.empty())
-      Diag << "-march=" + WaMArch.str();
+      Diag << "march=" << WaMArch;
     else
-      Diag << A->getAsString(Args);
+      Diag << A->getOption().getName() << A->getValue();
   }
 
   if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index b79d1f00ea48b..5c49db2f08379 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -121,7 +121,8 @@ static void checkARMArchName(const Driver &D, const Arg *A, const ArgList &Args,
   if (ArchKind == llvm::ARM::ArchKind::INVALID ||
       (Split.second.size() && !DecodeARMFeatures(D, Split.second, CPUName,
                                                  ArchKind, Features, ArgFPUID)))
-    D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
+    D.Diag(clang::diag::err_drv_unsupported_option_argument)
+        << A->getOption().getName() << A->getValue();
 }
 
 // Check -mcpu=. Needs ArchName to handle -mcpu=generic.
@@ -137,7 +138,8 @@ static void checkARMCPUName(const Driver &D, const Arg *A, const ArgList &Args,
   if (ArchKind == llvm::ARM::ArchKind::INVALID ||
       (Split.second.size() &&
        !DecodeARMFeatures(D, Split.second, CPU, ArchKind, Features, ArgFPUID)))
-    D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
+    D.Diag(clang::diag::err_drv_unsupported_option_argument)
+        << A->getOption().getName() << A->getValue();
 }
 
 bool arm::useAAPCSForMachO(const llvm::Triple &T) {

diff  --git a/clang/test/Driver/aarch64-target-as-march.s b/clang/test/Driver/aarch64-target-as-march.s
index 03c3e395230df..7475414e12e61 100644
--- a/clang/test/Driver/aarch64-target-as-march.s
+++ b/clang/test/Driver/aarch64-target-as-march.s
@@ -51,5 +51,5 @@
 // RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=foobar %s 2>&1 | \
 // RUN: FileCheck --check-prefix=INVALID-ARCH-2 %s
 
-// INVALID-ARCH-1: error: the clang compiler does not support '-march=all'
-// INVALID-ARCH-2: error: the clang compiler does not support '-march=foobar'
+// INVALID-ARCH-1: error: unsupported argument 'all' to option '-march='
+// INVALID-ARCH-2: error: unsupported argument 'foobar' to option '-march='

diff  --git a/clang/test/Driver/arm-cortex-cpus-2.c b/clang/test/Driver/arm-cortex-cpus-2.c
index beb3dbc3749b7..7d2c38b7cc0e3 100644
--- a/clang/test/Driver/arm-cortex-cpus-2.c
+++ b/clang/test/Driver/arm-cortex-cpus-2.c
@@ -143,20 +143,20 @@
 
 // ================== Check that a bogus architecture gives an error
 // RUN: %clang -target arm -march=armbogusv6 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS %s
-// CHECK-BOGUS: error: {{.*}} does not support '-march=armbogusv6' 
+// CHECK-BOGUS: error: unsupported argument 'armbogusv6' to option '-march='
 // RUN: %clang -target arm---eabihf -march=armbogusv7 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-HF %s
-// CHECK-BOGUS-HF: error: {{.*}} does not support '-march=armbogusv7' 
+// CHECK-BOGUS-HF: error: unsupported argument 'armbogusv7' to option '-march='
 // RUN: %clang -target arm -march=armv6bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS2 %s
-// CHECK-BOGUS2: error: {{.*}} does not support '-march=armv6bogus'
+// CHECK-BOGUS2: error: unsupported argument 'armv6bogus' to option '-march='
 // RUN: %clang -target arm -march=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS3 %s
-// CHECK-BOGUS3: error: {{.*}} does not support '-march=bogus'
+// CHECK-BOGUS3: error: unsupported argument 'bogus' to option '-march='
 
 // ================== Check that a bogus CPU gives an error
 // RUN: %clang -target arm -mcpu=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-CPU %s
 // RUN: %clang -target armv8-apple-darwin -arch arm64 -mcpu=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-CPU %s
-// CHECK-BOGUS-CPU: error: {{.*}} does not support '-mcpu=bogus'
+// CHECK-BOGUS-CPU: error: unsupported argument 'bogus' to option '-mcpu='
 // RUN: %clang -target armv8-apple-darwin -arch arm64 -mtune=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-TUNE %s
-// CHECK-BOGUS-TUNE: error: {{.*}} does not support '-mtune=bogus'
+// CHECK-BOGUS-TUNE: error: unsupported argument 'bogus' to option '-mtune='
 
 // ================== Check default Architecture on each ARM11 CPU
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1136j-s -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV6 %s

diff  --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index fd2f157c88b21..b548a4dbb3926 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -14,7 +14,7 @@
 
 // RUN: %clang -target arm -Wa,-mcpu=bogus -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-BOGUS-CPU %s
-// CHECK-BOGUS-CPU: error: {{.*}} does not support '-Wa,-mcpu=bogus'
+// CHECK-BOGUS-CPU: error: unsupported argument '-mcpu=bogus' to option '-Wa,'
 
 // RUN: %clang -target arm -mcpu=cortex-a8 -Wa,-mcpu=cortex-a15 -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-DUP-CPU %s
@@ -38,7 +38,7 @@
 
 // RUN: %clang -target arm -Wa,-march=armbogusv6 -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-BOGUS-ARCH %s
-// CHECK-BOGUS-ARCH: error: {{.*}} does not support '-Wa,-march=armbogusv6'
+// CHECK-BOGUS-ARCH: error: unsupported argument '-march=armbogusv6' to option '-Wa,'
 
 // RUN: %clang -target arm -march=armv7 -Wa,-march=armv6 -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-DUP-ARCH %s

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c b/clang/test/Preprocessor/aarch64-target-features.c
index f82e89f4fc78d..6e495a0ae96e7 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -140,7 +140,7 @@
 
 // RUN: %clang -target aarch64 -march=arm64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s
 // RUN: %clang -target aarch64 -march=aarch64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-ARCH-NOT-ACCEPT %s
-// CHECK-ARCH-NOT-ACCEPT: error: the clang compiler does not support
+// CHECK-ARCH-NOT-ACCEPT: error: unsupported argument {{.*}} to option '-march='
 
 // RUN: %clang -target aarch64 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-GENERIC %s
 // RUN: %clang -target aarch64 -march=armv8-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-GENERIC %s


        


More information about the cfe-commits mailing list