summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-10-20 04:47:45 +0000
committerRui Ueyama <ruiu@google.com>2016-10-20 04:47:45 +0000
commitd7c4454fb20a07704d3110621b31e4286be930b8 (patch)
treee06a6167c7b9e0bc15b7249e1efde6ad04ae8c9d
parent0aeb1199ea7153bb53ae27e2b67979b2182dd74f (diff)
downloadbcm5719-llvm-d7c4454fb20a07704d3110621b31e4286be930b8.tar.gz
bcm5719-llvm-d7c4454fb20a07704d3110621b31e4286be930b8.zip
Fix error message for unknown -format argument.
-format=<foo>, -format <foo> and -b <foo> are all the same. Previous code was intended to produce an error message with the same spelling as given from the command line, but it actually always printed out this string: "unknown -format= value:". This is probably more confusing than "unknown -format value:". So I changed the message. llvm-svn: 284693
-rw-r--r--lld/ELF/Driver.cpp7
-rw-r--r--lld/test/ELF/format-binary.test4
2 files changed, 7 insertions, 4 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 15d30494b76..54a267fd6af 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -581,13 +581,12 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
}
// Returns a value of "-format" option.
-static bool getBinaryOption(opt::Arg *Arg) {
- StringRef S = Arg->getValue();
+static bool getBinaryOption(StringRef S) {
if (S == "binary")
return true;
if (S == "elf" || S == "default")
return false;
- error("unknown " + Arg->getSpelling() + " format: " + S +
+ error("unknown -format value: " + S +
" (supported formats: elf, default, binary)");
return false;
}
@@ -609,7 +608,7 @@ void LinkerDriver::createFiles(opt::InputArgList &Args) {
Config->AsNeeded = true;
break;
case OPT_format:
- Config->Binary = getBinaryOption(Arg);
+ Config->Binary = getBinaryOption(Arg->getValue());
break;
case OPT_no_as_needed:
Config->AsNeeded = false;
diff --git a/lld/test/ELF/format-binary.test b/lld/test/ELF/format-binary.test
index 132f77c9d99..586f5f963df 100644
--- a/lld/test/ELF/format-binary.test
+++ b/lld/test/ELF/format-binary.test
@@ -7,6 +7,10 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld %t.o -b binary %t.binary -b default %t.o -shared -o %t.out
+# RUN: not ld.lld -b foo > %t.log 2>&1
+# RUN: FileCheck -check-prefix=ERR %s < %t.log
+# ERR: error: unknown -format value: foo (supported formats: elf, default, binary)
+
# CHECK: Name: .data
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
OpenPOWER on IntegriCloud