[lld] r301758 - Simplify by using getString instead of getLastArg. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 29 15:56:38 PDT 2017


Author: ruiu
Date: Sat Apr 29 17:56:38 2017
New Revision: 301758

URL: http://llvm.org/viewvc/llvm-project?rev=301758&view=rev
Log:
Simplify by using getString instead of getLastArg. NFC.

Modified:
    lld/trunk/ELF/Driver.cpp

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=301758&r1=301757&r2=301758&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sat Apr 29 17:56:38 2017
@@ -447,16 +447,14 @@ static UnresolvedPolicy getUnresolvedSym
 }
 
 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")




More information about the llvm-commits mailing list