Simplify. NFC.

llvm-svn: 284692
This commit is contained in:
Rui Ueyama 2016-10-20 04:36:36 +00:00
parent db94496629
commit 0aeb1199ea
1 changed files with 14 additions and 10 deletions

View File

@ -580,6 +580,18 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
readVersionScript(*Buffer);
}
// Returns a value of "-format" option.
static bool getBinaryOption(opt::Arg *Arg) {
StringRef S = Arg->getValue();
if (S == "binary")
return true;
if (S == "elf" || S == "default")
return false;
error("unknown " + Arg->getSpelling() + " format: " + S +
" (supported formats: elf, default, binary)");
return false;
}
void LinkerDriver::createFiles(opt::InputArgList &Args) {
for (auto *Arg : Args) {
switch (Arg->getOption().getID()) {
@ -596,17 +608,9 @@ void LinkerDriver::createFiles(opt::InputArgList &Args) {
case OPT_as_needed:
Config->AsNeeded = true;
break;
case OPT_format: {
StringRef Val = Arg->getValue();
if (Val == "elf" || Val == "default")
Config->Binary = false;
else if (Val == "binary")
Config->Binary = true;
else
error("unknown " + Arg->getSpelling() + " format: " + Arg->getValue() +
" (supported formats: elf, default, binary)");
case OPT_format:
Config->Binary = getBinaryOption(Arg);
break;
}
case OPT_no_as_needed:
Config->AsNeeded = false;
break;