From 85a5e69cedff8f053cdc71b4912b23313fd09eb6 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 29 Apr 2017 22:56:38 +0000 Subject: [PATCH] Simplify by using getString instead of getLastArg. NFC. llvm-svn: 301758 --- lld/ELF/Driver.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 8b390a164ff8..fce6321a7426 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -447,16 +447,14 @@ static UnresolvedPolicy getUnresolvedSymbolPolicy(opt::InputArgList &Args) { } static Target2Policy getTarget2(opt::InputArgList &Args) { - if (auto *Arg = Args.getLastArg(OPT_target2)) { - StringRef S = Arg->getValue(); - if (S == "rel") - return Target2Policy::Rel; - if (S == "abs") - return Target2Policy::Abs; - if (S == "got-rel") - return Target2Policy::GotRel; - error("unknown --target2 option: " + S); - } + StringRef S = getString(Args, OPT_target2, "got-rel"); + if (S == "rel") + return Target2Policy::Rel; + if (S == "abs") + return Target2Policy::Abs; + if (S == "got-rel") + return Target2Policy::GotRel; + error("unknown --target2 option: " + S); return Target2Policy::GotRel; } @@ -561,11 +559,7 @@ getBuildId(opt::InputArgList &Args) { if (Args.hasArg(OPT_build_id)) return {BuildIdKind::Fast, {}}; - auto *Arg = Args.getLastArg(OPT_build_id_eq); - if (!Arg) - return {BuildIdKind::None, {}}; - - StringRef S = Arg->getValue(); + StringRef S = getString(Args, OPT_build_id_eq, "none"); if (S == "md5") return {BuildIdKind::Md5, {}}; if (S == "sha1" || S == "tree")