forked from OSchip/llvm-project
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
This commit is contained in:
parent
0aeb1199ea
commit
d7c4454fb2
|
@ -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;
|
||||
|
|
|
@ -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 [
|
||||
|
|
Loading…
Reference in New Issue