[lld] r296226 - Factor out code to parse -hash-style.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 24 18:07:28 PST 2017
Author: ruiu
Date: Fri Feb 24 20:07:27 2017
New Revision: 296226
URL: http://llvm.org/viewvc/llvm-project?rev=296226&view=rev
Log:
Factor out code to parse -hash-style.
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=296226&r1=296225&r2=296226&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Fri Feb 24 20:07:27 2017
@@ -109,7 +109,7 @@ struct Configuration {
bool FatalWarnings;
bool GcSections;
bool GdbIndex;
- bool GnuHash = false;
+ bool GnuHash;
bool ICF;
bool Mips64EL = false;
bool MipsN32Abi = false;
@@ -127,7 +127,7 @@ struct Configuration {
bool SingleRoRx;
bool Shared;
bool Static = false;
- bool SysvHash = true;
+ bool SysvHash;
bool Target1Rel;
bool Threads;
bool Trace;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=296226&r1=296225&r2=296226&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Feb 24 20:07:27 2017
@@ -502,6 +502,17 @@ static SortSectionPolicy getSortKind(opt
return SortSectionPolicy::Default;
}
+static std::pair<bool, bool> getHashStyle(opt::InputArgList &Args) {
+ StringRef S = getString(Args, OPT_hash_style, "sysv");
+ if (S == "sysv")
+ return {true, false};
+ if (S == "gnu")
+ return {false, true};
+ if (S != "both")
+ error("unknown -hash-style: " + S);
+ return {true, true};
+}
+
static std::vector<StringRef> getLines(MemoryBufferRef MB) {
SmallVector<StringRef, 0> Arr;
MB.getBuffer().split(Arr, '\n');
@@ -612,16 +623,7 @@ void LinkerDriver::readConfigs(opt::Inpu
if (!Config->Relocatable)
Config->Strip = getStripOption(Args);
- if (auto *Arg = Args.getLastArg(OPT_hash_style)) {
- StringRef S = Arg->getValue();
- if (S == "gnu") {
- Config->GnuHash = true;
- Config->SysvHash = false;
- } else if (S == "both") {
- Config->GnuHash = true;
- } else if (S != "sysv")
- error("unknown hash style: " + S);
- }
+ std::tie(Config->SysvHash, Config->GnuHash) = getHashStyle(Args);
// Parse --build-id or --build-id=<style>.
if (Args.hasArg(OPT_build_id))
More information about the llvm-commits
mailing list