Author: Fangrui Song Date: 2024-08-15T17:04:41-07:00 New Revision: 9d63a09b452b641e3cc5d88066464b8250bd2bf7
URL: https://github.com/llvm/llvm-project/commit/9d63a09b452b641e3cc5d88066464b8250bd2bf7 DIFF: https://github.com/llvm/llvm-project/commit/9d63a09b452b641e3cc5d88066464b8250bd2bf7.diff LOG: [Driver] Improve error message for -Wa,-x=unknown Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/arm-target-as-mimplicit-it.s clang/test/Driver/relax.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index c26ebd1ba56ba..2b7241964a345 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2621,6 +2621,11 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, continue; // LLVM handles bigobj automatically auto Equal = Value.split('='); + auto checkArg = [&](std::initializer_list<const char *> Set) { + if (!llvm::is_contained(Set, Equal.second)) + D.Diag(diag::err_drv_unsupported_option_argument) + << (Twine("-Wa,") + Equal.first + "=").str() << Equal.second; + }; switch (C.getDefaultToolChain().getArch()) { default: break; @@ -2629,8 +2634,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, if (Equal.first == "-mrelax-relocations" || Equal.first == "--mrelax-relocations") { UseRelaxRelocations = Equal.second == "yes"; - if (llvm::is_contained({"yes", "no"}, Equal.second)) - continue; + checkArg({"yes", "no"}); + continue; } if (Value == "-msse2avx") { CmdArgs.push_back("-msse2avx"); @@ -2651,8 +2656,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, if (Equal.first == "-mimplicit-it") { // Only store the value; the last value set takes effect. ImplicitIt = Equal.second; - if (CheckARMImplicitITArg(Equal.second)) - continue; + checkArg({"always", "never", "arm", "thumb"}); + continue; } if (Value == "-mthumb") // -mthumb has already been processed in ComputeLLVMTriple() diff --git a/clang/test/Driver/arm-target-as-mimplicit-it.s b/clang/test/Driver/arm-target-as-mimplicit-it.s index d30433ab374d5..e40206dfc3a29 100644 --- a/clang/test/Driver/arm-target-as-mimplicit-it.s +++ b/clang/test/Driver/arm-target-as-mimplicit-it.s @@ -30,7 +30,7 @@ /// Test invalid input. // RUN: not %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID -// RUN: not %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=XINVALID +// RUN: not %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID // RUN: not %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID // RUN: not %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID @@ -47,5 +47,4 @@ // NEVER-NOT: "-arm-implicit-it={{.*}}" // ARM: "-mllvm" "-arm-implicit-it=arm" // THUMB: "-mllvm" "-arm-implicit-it=thumb" -// INVALID: error: unsupported argument '-mimplicit-it=foo' to option '-Wa,' -// XINVALID: error: unsupported argument '-mimplicit-it=foo' to option '-Xassembler' +// INVALID: error: unsupported argument 'foo' to option '-Wa,-mimplicit-it=' diff --git a/clang/test/Driver/relax.c b/clang/test/Driver/relax.c index 4771b9e3af111..9315a0045f1f4 100644 --- a/clang/test/Driver/relax.c +++ b/clang/test/Driver/relax.c @@ -4,7 +4,7 @@ // CHECK: "-mrelax-relocations=no" // RUN: not %clang -### --target=x86_64 -c -Wa,-mrelax-relocations=x %s 2>&1 | FileCheck %s --check-prefix=ERR -// ERR: error: unsupported argument '-mrelax-relocations=x' to option '-Wa,' +// ERR: error: unsupported argument 'x' to option '-Wa,-mrelax-relocations=' // RUN: not %clang -### --target=aarch64 -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR2 // ERR2: error: unsupported argument '-mrelax-relocations=no' to option '-Wa,' _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits