Skip to content

Commit 9d63a09

Browse files
committed
[Driver] Improve error message for -Wa,-x=unknown
1 parent ec29660 commit 9d63a09

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,6 +2621,11 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26212621
continue; // LLVM handles bigobj automatically
26222622

26232623
auto Equal = Value.split('=');
2624+
auto checkArg = [&](std::initializer_list<const char *> Set) {
2625+
if (!llvm::is_contained(Set, Equal.second))
2626+
D.Diag(diag::err_drv_unsupported_option_argument)
2627+
<< (Twine("-Wa,") + Equal.first + "=").str() << Equal.second;
2628+
};
26242629
switch (C.getDefaultToolChain().getArch()) {
26252630
default:
26262631
break;
@@ -2629,8 +2634,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26292634
if (Equal.first == "-mrelax-relocations" ||
26302635
Equal.first == "--mrelax-relocations") {
26312636
UseRelaxRelocations = Equal.second == "yes";
2632-
if (llvm::is_contained({"yes", "no"}, Equal.second))
2633-
continue;
2637+
checkArg({"yes", "no"});
2638+
continue;
26342639
}
26352640
if (Value == "-msse2avx") {
26362641
CmdArgs.push_back("-msse2avx");
@@ -2651,8 +2656,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
26512656
if (Equal.first == "-mimplicit-it") {
26522657
// Only store the value; the last value set takes effect.
26532658
ImplicitIt = Equal.second;
2654-
if (CheckARMImplicitITArg(Equal.second))
2655-
continue;
2659+
checkArg({"always", "never", "arm", "thumb"});
2660+
continue;
26562661
}
26572662
if (Value == "-mthumb")
26582663
// -mthumb has already been processed in ComputeLLVMTriple()

clang/test/Driver/arm-target-as-mimplicit-it.s

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
/// Test invalid input.
3232
// RUN: not %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
33-
// RUN: not %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=XINVALID
33+
// RUN: not %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
3434
// RUN: not %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always -Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
3535
// RUN: not %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
3636

@@ -47,5 +47,4 @@
4747
// NEVER-NOT: "-arm-implicit-it={{.*}}"
4848
// ARM: "-mllvm" "-arm-implicit-it=arm"
4949
// THUMB: "-mllvm" "-arm-implicit-it=thumb"
50-
// INVALID: error: unsupported argument '-mimplicit-it=foo' to option '-Wa,'
51-
// XINVALID: error: unsupported argument '-mimplicit-it=foo' to option '-Xassembler'
50+
// INVALID: error: unsupported argument 'foo' to option '-Wa,-mimplicit-it='

clang/test/Driver/relax.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// CHECK: "-mrelax-relocations=no"
55

66
// RUN: not %clang -### --target=x86_64 -c -Wa,-mrelax-relocations=x %s 2>&1 | FileCheck %s --check-prefix=ERR
7-
// ERR: error: unsupported argument '-mrelax-relocations=x' to option '-Wa,'
7+
// ERR: error: unsupported argument 'x' to option '-Wa,-mrelax-relocations='
88

99
// RUN: not %clang -### --target=aarch64 -c -Wa,-mrelax-relocations=no %s 2>&1 | FileCheck %s --check-prefix=ERR2
1010
// ERR2: error: unsupported argument '-mrelax-relocations=no' to option '-Wa,'

0 commit comments

Comments
 (0)