[lld] r252924 - ELF2: Simplify -z option handling. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 11:00:37 PST 2015
Author: ruiu
Date: Thu Nov 12 13:00:37 2015
New Revision: 252924
URL: http://llvm.org/viewvc/llvm-project?rev=252924&view=rev
Log:
ELF2: Simplify -z option handling. 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=252924&r1=252923&r2=252924&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Nov 12 13:00:37 2015
@@ -94,6 +94,13 @@ getString(opt::InputArgList &Args, unsig
return Default;
}
+static bool hasZOption(opt::InputArgList &Args, StringRef Key) {
+ for (auto *Arg : Args.filtered(OPT_z))
+ if (Key == Arg->getValue())
+ return true;
+ return false;
+}
+
void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
initSymbols();
@@ -164,6 +171,10 @@ void LinkerDriver::createFiles(opt::Inpu
Config->SoName = getString(Args, OPT_soname);
Config->Sysroot = getString(Args, OPT_sysroot);
+ Config->ZNodelete = hasZOption(Args, "nodelete");
+ Config->ZNow = hasZOption(Args, "now");
+ Config->ZOrigin = hasZOption(Args, "origin");
+
if (auto *Arg = Args.getLastArg(OPT_O)) {
StringRef Val = Arg->getValue();
if (Val.getAsInteger(10, Config->Optimize))
@@ -184,16 +195,6 @@ void LinkerDriver::createFiles(opt::Inpu
for (auto *Arg : Args.filtered(OPT_undefined))
Config->Undefined.push_back(Arg->getValue());
- for (auto *Arg : Args.filtered(OPT_z)) {
- StringRef S = Arg->getValue();
- if (S == "nodelete")
- Config->ZNodelete = true;
- else if (S == "now")
- Config->ZNow = true;
- else if (S == "origin")
- Config->ZOrigin = true;
- }
-
for (auto *Arg : Args) {
switch (Arg->getOption().getID()) {
case OPT_l:
More information about the llvm-commits
mailing list