[lld] r240347 - Update for LLVM API change to return by InputArgList directly (rather than by pointer) from ParseArgs
David Blaikie
dblaikie at gmail.com
Mon Jun 22 15:06:52 PDT 2015
Author: dblaikie
Date: Mon Jun 22 17:06:52 2015
New Revision: 240347
URL: http://llvm.org/viewvc/llvm-project?rev=240347&view=rev
Log:
Update for LLVM API change to return by InputArgList directly (rather than by pointer) from ParseArgs
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Driver.h
lld/trunk/COFF/DriverUtils.cpp
lld/trunk/lib/Driver/CoreDriver.cpp
lld/trunk/lib/Driver/DarwinLdDriver.cpp
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/lib/Driver/UniversalDriver.cpp
lld/trunk/lib/Driver/WinLinkDriver.cpp
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=240347&r1=240346&r2=240347&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon Jun 22 17:06:52 2015
@@ -90,9 +90,9 @@ LinkerDriver::parseDirectives(StringRef
auto ArgsOrErr = Parser.parse(S);
if (auto EC = ArgsOrErr.getError())
return EC;
- std::unique_ptr<llvm::opt::InputArgList> Args = std::move(ArgsOrErr.get());
+ llvm::opt::InputArgList Args = std::move(ArgsOrErr.get());
- for (auto *Arg : *Args) {
+ for (auto *Arg : Args) {
switch (Arg->getOption().getID()) {
case OPT_alternatename:
if (auto EC = parseAlternateName(Arg->getValue()))
@@ -234,46 +234,46 @@ bool LinkerDriver::link(llvm::ArrayRef<c
llvm::errs() << EC.message() << "\n";
return false;
}
- std::unique_ptr<llvm::opt::InputArgList> Args = std::move(ArgsOrErr.get());
+ llvm::opt::InputArgList Args = std::move(ArgsOrErr.get());
// Handle /help
- if (Args->hasArg(OPT_help)) {
+ if (Args.hasArg(OPT_help)) {
printHelp(ArgsArr[0]);
return true;
}
- if (Args->filtered_begin(OPT_INPUT) == Args->filtered_end()) {
+ if (Args.filtered_begin(OPT_INPUT) == Args.filtered_end()) {
llvm::errs() << "no input files.\n";
return false;
}
// Construct search path list.
SearchPaths.push_back("");
- for (auto *Arg : Args->filtered(OPT_libpath))
+ for (auto *Arg : Args.filtered(OPT_libpath))
SearchPaths.push_back(Arg->getValue());
addLibSearchPaths();
// Handle /out
- if (auto *Arg = Args->getLastArg(OPT_out))
+ if (auto *Arg = Args.getLastArg(OPT_out))
Config->OutputFile = Arg->getValue();
// Handle /verbose
- if (Args->hasArg(OPT_verbose))
+ if (Args.hasArg(OPT_verbose))
Config->Verbose = true;
// Handle /dll
- if (Args->hasArg(OPT_dll)) {
+ if (Args.hasArg(OPT_dll)) {
Config->DLL = true;
Config->ManifestID = 2;
}
// Handle /entry
- if (auto *Arg = Args->getLastArg(OPT_entry))
+ if (auto *Arg = Args.getLastArg(OPT_entry))
Config->EntryName = Arg->getValue();
// Handle /fixed
- if (Args->hasArg(OPT_fixed)) {
- if (Args->hasArg(OPT_dynamicbase)) {
+ if (Args.hasArg(OPT_fixed)) {
+ if (Args.hasArg(OPT_dynamicbase)) {
llvm::errs() << "/fixed must not be specified with /dynamicbase\n";
return false;
}
@@ -282,7 +282,7 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /machine
- auto MTOrErr = getMachineType(Args.get());
+ auto MTOrErr = getMachineType(&Args);
if (auto EC = MTOrErr.getError()) {
llvm::errs() << EC.message() << "\n";
return false;
@@ -290,15 +290,15 @@ bool LinkerDriver::link(llvm::ArrayRef<c
Config->MachineType = MTOrErr.get();
// Handle /nodefaultlib:<filename>
- for (auto *Arg : Args->filtered(OPT_nodefaultlib))
+ for (auto *Arg : Args.filtered(OPT_nodefaultlib))
Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()));
// Handle /nodefaultlib
- if (Args->hasArg(OPT_nodefaultlib_all))
+ if (Args.hasArg(OPT_nodefaultlib_all))
Config->NoDefaultLibAll = true;
// Handle /base
- if (auto *Arg = Args->getLastArg(OPT_base)) {
+ if (auto *Arg = Args.getLastArg(OPT_base)) {
if (auto EC = parseNumbers(Arg->getValue(), &Config->ImageBase)) {
llvm::errs() << "/base: " << EC.message() << "\n";
return false;
@@ -306,7 +306,7 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /stack
- if (auto *Arg = Args->getLastArg(OPT_stack)) {
+ if (auto *Arg = Args.getLastArg(OPT_stack)) {
if (auto EC = parseNumbers(Arg->getValue(), &Config->StackReserve,
&Config->StackCommit)) {
llvm::errs() << "/stack: " << EC.message() << "\n";
@@ -315,7 +315,7 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /heap
- if (auto *Arg = Args->getLastArg(OPT_heap)) {
+ if (auto *Arg = Args.getLastArg(OPT_heap)) {
if (auto EC = parseNumbers(Arg->getValue(), &Config->HeapReserve,
&Config->HeapCommit)) {
llvm::errs() << "/heap: " << EC.message() << "\n";
@@ -324,7 +324,7 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /version
- if (auto *Arg = Args->getLastArg(OPT_version)) {
+ if (auto *Arg = Args.getLastArg(OPT_version)) {
if (auto EC = parseVersion(Arg->getValue(), &Config->MajorImageVersion,
&Config->MinorImageVersion)) {
llvm::errs() << "/version: " << EC.message() << "\n";
@@ -333,7 +333,7 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /subsystem
- if (auto *Arg = Args->getLastArg(OPT_subsystem)) {
+ if (auto *Arg = Args.getLastArg(OPT_subsystem)) {
if (auto EC = parseSubsystem(Arg->getValue(), &Config->Subsystem,
&Config->MajorOSVersion,
&Config->MinorOSVersion)) {
@@ -343,20 +343,20 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /alternatename
- for (auto *Arg : Args->filtered(OPT_alternatename))
+ for (auto *Arg : Args.filtered(OPT_alternatename))
if (parseAlternateName(Arg->getValue()))
return false;
// Handle /include
- for (auto *Arg : Args->filtered(OPT_incl))
+ for (auto *Arg : Args.filtered(OPT_incl))
Config->Includes.insert(Arg->getValue());
// Handle /implib
- if (auto *Arg = Args->getLastArg(OPT_implib))
+ if (auto *Arg = Args.getLastArg(OPT_implib))
Config->Implib = Arg->getValue();
// Handle /opt
- for (auto *Arg : Args->filtered(OPT_opt)) {
+ for (auto *Arg : Args.filtered(OPT_opt)) {
std::string S = StringRef(Arg->getValue()).lower();
if (S == "noref") {
Config->DoGC = false;
@@ -371,7 +371,7 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /export
- for (auto *Arg : Args->filtered(OPT_export)) {
+ for (auto *Arg : Args.filtered(OPT_export)) {
ErrorOr<Export> E = parseExport(Arg->getValue());
if (E.getError())
return false;
@@ -379,18 +379,18 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /delayload
- for (auto *Arg : Args->filtered(OPT_delayload)) {
+ for (auto *Arg : Args.filtered(OPT_delayload)) {
Config->DelayLoads.insert(Arg->getValue());
Config->Includes.insert("__delayLoadHelper2");
}
// Handle /failifmismatch
- for (auto *Arg : Args->filtered(OPT_failifmismatch))
+ for (auto *Arg : Args.filtered(OPT_failifmismatch))
if (checkFailIfMismatch(Arg->getValue()))
return false;
// Handle /def
- if (auto *Arg = Args->getLastArg(OPT_deffile)) {
+ if (auto *Arg = Args.getLastArg(OPT_deffile)) {
ErrorOr<MemoryBufferRef> MBOrErr = openFile(Arg->getValue());
if (auto EC = MBOrErr.getError()) {
llvm::errs() << "/def: " << EC.message() << "\n";
@@ -402,7 +402,7 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /manifest
- if (auto *Arg = Args->getLastArg(OPT_manifest_colon)) {
+ if (auto *Arg = Args.getLastArg(OPT_manifest_colon)) {
if (auto EC = parseManifest(Arg->getValue())) {
llvm::errs() << "/manifest: " << EC.message() << "\n";
return false;
@@ -410,7 +410,7 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /manifestuac
- if (auto *Arg = Args->getLastArg(OPT_manifestuac)) {
+ if (auto *Arg = Args.getLastArg(OPT_manifestuac)) {
if (auto EC = parseManifestUAC(Arg->getValue())) {
llvm::errs() << "/manifestuac: " << EC.message() << "\n";
return false;
@@ -418,29 +418,35 @@ bool LinkerDriver::link(llvm::ArrayRef<c
}
// Handle /manifestdependency
- if (auto *Arg = Args->getLastArg(OPT_manifestdependency))
+ if (auto *Arg = Args.getLastArg(OPT_manifestdependency))
Config->ManifestDependency = Arg->getValue();
// Handle /manifestfile
- if (auto *Arg = Args->getLastArg(OPT_manifestfile))
+ if (auto *Arg = Args.getLastArg(OPT_manifestfile))
Config->ManifestFile = Arg->getValue();
// Handle miscellaneous boolean flags.
- if (Args->hasArg(OPT_allowbind_no)) Config->AllowBind = false;
- if (Args->hasArg(OPT_allowisolation_no)) Config->AllowIsolation = false;
- if (Args->hasArg(OPT_dynamicbase_no)) Config->DynamicBase = false;
- if (Args->hasArg(OPT_highentropyva_no)) Config->HighEntropyVA = false;
- if (Args->hasArg(OPT_nxcompat_no)) Config->NxCompat = false;
- if (Args->hasArg(OPT_tsaware_no)) Config->TerminalServerAware = false;
+ if (Args.hasArg(OPT_allowbind_no))
+ Config->AllowBind = false;
+ if (Args.hasArg(OPT_allowisolation_no))
+ Config->AllowIsolation = false;
+ if (Args.hasArg(OPT_dynamicbase_no))
+ Config->DynamicBase = false;
+ if (Args.hasArg(OPT_highentropyva_no))
+ Config->HighEntropyVA = false;
+ if (Args.hasArg(OPT_nxcompat_no))
+ Config->NxCompat = false;
+ if (Args.hasArg(OPT_tsaware_no))
+ Config->TerminalServerAware = false;
// Create a list of input files. Files can be given as arguments
// for /defaultlib option.
std::vector<StringRef> InputPaths;
std::vector<MemoryBufferRef> Inputs;
- for (auto *Arg : Args->filtered(OPT_INPUT))
+ for (auto *Arg : Args.filtered(OPT_INPUT))
if (Optional<StringRef> Path = findFile(Arg->getValue()))
InputPaths.push_back(*Path);
- for (auto *Arg : Args->filtered(OPT_defaultlib))
+ for (auto *Arg : Args.filtered(OPT_defaultlib))
if (Optional<StringRef> Path = findLib(Arg->getValue()))
InputPaths.push_back(*Path);
for (StringRef Path : InputPaths) {
Modified: lld/trunk/COFF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.h?rev=240347&r1=240346&r2=240347&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.h (original)
+++ lld/trunk/COFF/Driver.h Mon Jun 22 17:06:52 2015
@@ -41,17 +41,15 @@ class ArgParser {
public:
ArgParser() : Alloc(AllocAux) {}
// Parses command line options.
- ErrorOr<std::unique_ptr<llvm::opt::InputArgList>>
- parse(llvm::ArrayRef<const char *> Args);
+ ErrorOr<llvm::opt::InputArgList> parse(llvm::ArrayRef<const char *> Args);
// Tokenizes a given string and then parses as command line options.
- ErrorOr<std::unique_ptr<llvm::opt::InputArgList>> parse(StringRef S) {
+ ErrorOr<llvm::opt::InputArgList> parse(StringRef S) {
return parse(tokenize(S));
}
private:
- ErrorOr<std::unique_ptr<llvm::opt::InputArgList>>
- parse(std::vector<const char *> Argv);
+ ErrorOr<llvm::opt::InputArgList> parse(std::vector<const char *> Argv);
std::vector<const char *> tokenize(StringRef S);
Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=240347&r1=240346&r2=240347&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Mon Jun 22 17:06:52 2015
@@ -541,7 +541,7 @@ public:
};
// Parses a given list of options.
-ErrorOr<std::unique_ptr<llvm::opt::InputArgList>>
+ErrorOr<llvm::opt::InputArgList>
ArgParser::parse(std::vector<const char *> Argv) {
// First, replace respnose files (@<file>-style options).
auto ArgvOrErr = replaceResponseFiles(Argv);
@@ -556,21 +556,21 @@ ArgParser::parse(std::vector<const char
COFFOptTable Table;
unsigned MissingIndex;
unsigned MissingCount;
- std::unique_ptr<llvm::opt::InputArgList> Args(
- Table.ParseArgs(Argv, MissingIndex, MissingCount));
+ llvm::opt::InputArgList Args =
+ Table.ParseArgs(Argv, MissingIndex, MissingCount);
if (MissingCount) {
llvm::errs() << "missing arg value for \""
- << Args->getArgString(MissingIndex)
- << "\", expected " << MissingCount
+ << Args.getArgString(MissingIndex) << "\", expected "
+ << MissingCount
<< (MissingCount == 1 ? " argument.\n" : " arguments.\n");
return make_error_code(LLDError::InvalidOption);
}
- for (auto *Arg : Args->filtered(OPT_UNKNOWN))
+ for (auto *Arg : Args.filtered(OPT_UNKNOWN))
llvm::errs() << "ignoring unknown argument: " << Arg->getSpelling() << "\n";
return std::move(Args);
}
-ErrorOr<std::unique_ptr<llvm::opt::InputArgList>>
+ErrorOr<llvm::opt::InputArgList>
ArgParser::parse(llvm::ArrayRef<const char *> Args) {
Args = Args.slice(1);
std::vector<const char *> V(Args.begin(), Args.end());
Modified: lld/trunk/lib/Driver/CoreDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CoreDriver.cpp?rev=240347&r1=240346&r2=240347&view=diff
==============================================================================
--- lld/trunk/lib/Driver/CoreDriver.cpp (original)
+++ lld/trunk/lib/Driver/CoreDriver.cpp Mon Jun 22 17:06:52 2015
@@ -90,14 +90,14 @@ bool CoreDriver::link(llvm::ArrayRef<con
bool CoreDriver::parse(llvm::ArrayRef<const char *> args,
CoreLinkingContext &ctx, raw_ostream &diagnostics) {
// Parse command line options using CoreOptions.td
- std::unique_ptr<llvm::opt::InputArgList> parsedArgs;
CoreOptTable table;
unsigned missingIndex;
unsigned missingCount;
- parsedArgs.reset(table.ParseArgs(args.slice(1), missingIndex, missingCount));
+ llvm::opt::InputArgList parsedArgs =
+ table.ParseArgs(args.slice(1), missingIndex, missingCount);
if (missingCount) {
diagnostics << "error: missing arg value for '"
- << parsedArgs->getArgString(missingIndex) << "' expected "
+ << parsedArgs.getArgString(missingIndex) << "' expected "
<< missingCount << " argument(s).\n";
return false;
}
@@ -111,7 +111,7 @@ bool CoreDriver::parse(llvm::ArrayRef<co
ctx.setSearchArchivesToOverrideTentativeDefinitions(false);
// Process all the arguments and create input files.
- for (auto inputArg : *parsedArgs) {
+ for (auto inputArg : parsedArgs) {
switch (inputArg->getOption().getID()) {
case OPT_mllvm:
ctx.appendLLVMOption(inputArg->getValue());
Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=240347&r1=240346&r2=240347&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Mon Jun 22 17:06:52 2015
@@ -280,28 +280,27 @@ bool DarwinLdDriver::linkMachO(llvm::Arr
bool DarwinLdDriver::parse(llvm::ArrayRef<const char *> args,
MachOLinkingContext &ctx, raw_ostream &diagnostics) {
// Parse command line options using DarwinLdOptions.td
- std::unique_ptr<llvm::opt::InputArgList> parsedArgs;
DarwinLdOptTable table;
unsigned missingIndex;
unsigned missingCount;
- bool globalWholeArchive = false;
- parsedArgs.reset(table.ParseArgs(args.slice(1), missingIndex, missingCount));
+ llvm::opt::InputArgList parsedArgs =
+ table.ParseArgs(args.slice(1), missingIndex, missingCount);
if (missingCount) {
diagnostics << "error: missing arg value for '"
- << parsedArgs->getArgString(missingIndex) << "' expected "
+ << parsedArgs.getArgString(missingIndex) << "' expected "
<< missingCount << " argument(s).\n";
return false;
}
- for (auto unknownArg : parsedArgs->filtered(OPT_UNKNOWN)) {
- diagnostics << "warning: ignoring unknown argument: "
- << unknownArg->getAsString(*parsedArgs) << "\n";
+ for (auto unknownArg : parsedArgs.filtered(OPT_UNKNOWN)) {
+ diagnostics << "warning: ignoring unknown argument: "
+ << unknownArg->getAsString(parsedArgs) << "\n";
}
// Figure out output kind ( -dylib, -r, -bundle, -preload, or -static )
llvm::MachO::HeaderFileType fileType = llvm::MachO::MH_EXECUTE;
- if ( llvm::opt::Arg *kind = parsedArgs->getLastArg(OPT_dylib, OPT_relocatable,
- OPT_bundle, OPT_static, OPT_preload)) {
+ if (llvm::opt::Arg *kind = parsedArgs.getLastArg(
+ OPT_dylib, OPT_relocatable, OPT_bundle, OPT_static, OPT_preload)) {
switch (kind->getOption().getID()) {
case OPT_dylib:
fileType = llvm::MachO::MH_DYLIB;
@@ -323,7 +322,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
// Handle -arch xxx
MachOLinkingContext::Arch arch = MachOLinkingContext::arch_unknown;
- if (llvm::opt::Arg *archStr = parsedArgs->getLastArg(OPT_arch)) {
+ if (llvm::opt::Arg *archStr = parsedArgs.getLastArg(OPT_arch)) {
arch = MachOLinkingContext::archFromName(archStr->getValue());
if (arch == MachOLinkingContext::arch_unknown) {
diagnostics << "error: unknown arch named '" << archStr->getValue()
@@ -333,16 +332,16 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// If no -arch specified, scan input files to find first non-fat .o file.
if (arch == MachOLinkingContext::arch_unknown) {
- for (auto &inFile: parsedArgs->filtered(OPT_INPUT)) {
+ for (auto &inFile : parsedArgs.filtered(OPT_INPUT)) {
// This is expensive because it opens and maps the file. But that is
// ok because no -arch is rare.
if (MachOLinkingContext::isThinObjectFile(inFile->getValue(), arch))
break;
}
- if (arch == MachOLinkingContext::arch_unknown
- && !parsedArgs->getLastArg(OPT_test_file_usage)) {
+ if (arch == MachOLinkingContext::arch_unknown &&
+ !parsedArgs.getLastArg(OPT_test_file_usage)) {
// If no -arch and no options at all, print usage message.
- if (parsedArgs->size() == 0)
+ if (parsedArgs.size() == 0)
table.PrintHelp(llvm::outs(), args[0], "LLVM Linker", false);
else
diagnostics << "error: -arch not specified and could not be inferred\n";
@@ -354,8 +353,8 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
MachOLinkingContext::OS os = MachOLinkingContext::OS::macOSX;
uint32_t minOSVersion = 0;
if (llvm::opt::Arg *minOS =
- parsedArgs->getLastArg(OPT_macosx_version_min, OPT_ios_version_min,
- OPT_ios_simulator_version_min)) {
+ parsedArgs.getLastArg(OPT_macosx_version_min, OPT_ios_version_min,
+ OPT_ios_simulator_version_min)) {
switch (minOS->getOption().getID()) {
case OPT_macosx_version_min:
os = MachOLinkingContext::OS::macOSX;
@@ -391,17 +390,17 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
ctx.configure(fileType, arch, os, minOSVersion);
// Handle -e xxx
- if (llvm::opt::Arg *entry = parsedArgs->getLastArg(OPT_entry))
+ if (llvm::opt::Arg *entry = parsedArgs.getLastArg(OPT_entry))
ctx.setEntrySymbolName(entry->getValue());
// Handle -o xxx
- if (llvm::opt::Arg *outpath = parsedArgs->getLastArg(OPT_output))
+ if (llvm::opt::Arg *outpath = parsedArgs.getLastArg(OPT_output))
ctx.setOutputPath(outpath->getValue());
else
ctx.setOutputPath("a.out");
// Handle -image_base XXX and -seg1addr XXXX
- if (llvm::opt::Arg *imageBase = parsedArgs->getLastArg(OPT_image_base)) {
+ if (llvm::opt::Arg *imageBase = parsedArgs.getLastArg(OPT_image_base)) {
uint64_t baseAddress;
if (parseNumberBase16(imageBase->getValue(), baseAddress)) {
diagnostics << "error: image_base expects a hex number\n";
@@ -419,26 +418,26 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle -dead_strip
- if (parsedArgs->getLastArg(OPT_dead_strip))
+ if (parsedArgs.getLastArg(OPT_dead_strip))
ctx.setDeadStripping(true);
+ bool globalWholeArchive = false;
// Handle -all_load
- if (parsedArgs->getLastArg(OPT_all_load))
+ if (parsedArgs.getLastArg(OPT_all_load))
globalWholeArchive = true;
// Handle -install_name
- if (llvm::opt::Arg *installName = parsedArgs->getLastArg(OPT_install_name))
+ if (llvm::opt::Arg *installName = parsedArgs.getLastArg(OPT_install_name))
ctx.setInstallName(installName->getValue());
else
ctx.setInstallName(ctx.outputPath());
// Handle -mark_dead_strippable_dylib
- if (parsedArgs->getLastArg(OPT_mark_dead_strippable_dylib))
+ if (parsedArgs.getLastArg(OPT_mark_dead_strippable_dylib))
ctx.setDeadStrippableDylib(true);
// Handle -compatibility_version and -current_version
- if (llvm::opt::Arg *vers =
- parsedArgs->getLastArg(OPT_compatibility_version)) {
+ if (llvm::opt::Arg *vers = parsedArgs.getLastArg(OPT_compatibility_version)) {
if (ctx.outputMachOType() != llvm::MachO::MH_DYLIB) {
diagnostics
<< "error: -compatibility_version can only be used with -dylib\n";
@@ -452,7 +451,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
ctx.setCompatibilityVersion(parsedVers);
}
- if (llvm::opt::Arg *vers = parsedArgs->getLastArg(OPT_current_version)) {
+ if (llvm::opt::Arg *vers = parsedArgs.getLastArg(OPT_current_version)) {
if (ctx.outputMachOType() != llvm::MachO::MH_DYLIB) {
diagnostics << "-current_version can only be used with -dylib\n";
return false;
@@ -466,11 +465,11 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle -bundle_loader
- if (llvm::opt::Arg *loader = parsedArgs->getLastArg(OPT_bundle_loader))
+ if (llvm::opt::Arg *loader = parsedArgs.getLastArg(OPT_bundle_loader))
ctx.setBundleLoader(loader->getValue());
// Handle -sectalign segname sectname align
- for (auto &alignArg : parsedArgs->filtered(OPT_sectalign)) {
+ for (auto &alignArg : parsedArgs.filtered(OPT_sectalign)) {
const char* segName = alignArg->getValue(0);
const char* sectName = alignArg->getValue(1);
const char* alignStr = alignArg->getValue(2);
@@ -494,31 +493,31 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle -mllvm
- for (auto &llvmArg : parsedArgs->filtered(OPT_mllvm)) {
+ for (auto &llvmArg : parsedArgs.filtered(OPT_mllvm)) {
ctx.appendLLVMOption(llvmArg->getValue());
}
// Handle -print_atoms
- if (parsedArgs->getLastArg(OPT_print_atoms))
+ if (parsedArgs.getLastArg(OPT_print_atoms))
ctx.setPrintAtoms();
// Handle -t (trace) option.
- if (parsedArgs->getLastArg(OPT_t))
+ if (parsedArgs.getLastArg(OPT_t))
ctx.setLogInputFiles(true);
// Handle -demangle option.
- if (parsedArgs->getLastArg(OPT_demangle))
+ if (parsedArgs.getLastArg(OPT_demangle))
ctx.setDemangleSymbols(true);
// Handle -keep_private_externs
- if (parsedArgs->getLastArg(OPT_keep_private_externs)) {
+ if (parsedArgs.getLastArg(OPT_keep_private_externs)) {
ctx.setKeepPrivateExterns(true);
if (ctx.outputMachOType() != llvm::MachO::MH_OBJECT)
diagnostics << "warning: -keep_private_externs only used in -r mode\n";
}
// Handle -dependency_info <path> used by Xcode.
- if (llvm::opt::Arg *depInfo = parsedArgs->getLastArg(OPT_dependency_info)) {
+ if (llvm::opt::Arg *depInfo = parsedArgs.getLastArg(OPT_dependency_info)) {
if (std::error_code ec = ctx.createDependencyFile(depInfo->getValue())) {
diagnostics << "warning: " << ec.message()
<< ", processing '-dependency_info "
@@ -531,14 +530,14 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
// exist. We'll also be expected to print out information about how we located
// libraries and so on that the user specified, but not to actually do any
// linking.
- if (parsedArgs->getLastArg(OPT_test_file_usage)) {
+ if (parsedArgs.getLastArg(OPT_test_file_usage)) {
ctx.setTestingFileUsage();
// With paths existing by fiat, linking is not going to end well.
ctx.setDoNothing(true);
// Only bother looking for an existence override if we're going to use it.
- for (auto existingPath : parsedArgs->filtered(OPT_path_exists)) {
+ for (auto existingPath : parsedArgs.filtered(OPT_path_exists)) {
ctx.addExistingPathForDebug(existingPath->getValue());
}
}
@@ -561,7 +560,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
// 3. If the last -syslibroot is "/", all of them are ignored entirely.
// 4. If { syslibroots } x path == {}, the original path is kept.
std::vector<StringRef> sysLibRoots;
- for (auto syslibRoot : parsedArgs->filtered(OPT_syslibroot)) {
+ for (auto syslibRoot : parsedArgs.filtered(OPT_syslibroot)) {
sysLibRoots.push_back(syslibRoot->getValue());
}
if (!sysLibRoots.empty()) {
@@ -572,17 +571,17 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
// Paths specified with -L come first, and are not considered system paths for
// the case where there is precisely 1 -syslibroot.
- for (auto libPath : parsedArgs->filtered(OPT_L)) {
+ for (auto libPath : parsedArgs.filtered(OPT_L)) {
ctx.addModifiedSearchDir(libPath->getValue());
}
// Process -F directories (where to look for frameworks).
- for (auto fwPath : parsedArgs->filtered(OPT_F)) {
+ for (auto fwPath : parsedArgs.filtered(OPT_F)) {
ctx.addFrameworkSearchDir(fwPath->getValue());
}
// -Z suppresses the standard search paths.
- if (!parsedArgs->hasArg(OPT_Z)) {
+ if (!parsedArgs.hasArg(OPT_Z)) {
ctx.addModifiedSearchDir("/usr/lib", true);
ctx.addModifiedSearchDir("/usr/local/lib", true);
ctx.addFrameworkSearchDir("/Library/Frameworks", true);
@@ -591,7 +590,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
// Now that we've constructed the final set of search paths, print out those
// search paths in verbose mode.
- if (parsedArgs->getLastArg(OPT_v)) {
+ if (parsedArgs.getLastArg(OPT_v)) {
diagnostics << "Library search paths:\n";
for (auto path : ctx.searchDirs()) {
diagnostics << " " << path << '\n';
@@ -603,7 +602,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle -exported_symbols_list <file>
- for (auto expFile : parsedArgs->filtered(OPT_exported_symbols_list)) {
+ for (auto expFile : parsedArgs.filtered(OPT_exported_symbols_list)) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::blackList) {
diagnostics << "error: -exported_symbols_list cannot be combined "
<< "with -unexported_symbol[s_list]\n";
@@ -621,7 +620,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle -exported_symbol <symbol>
- for (auto symbol : parsedArgs->filtered(OPT_exported_symbol)) {
+ for (auto symbol : parsedArgs.filtered(OPT_exported_symbol)) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::blackList) {
diagnostics << "error: -exported_symbol cannot be combined "
<< "with -unexported_symbol[s_list]\n";
@@ -632,7 +631,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle -unexported_symbols_list <file>
- for (auto expFile : parsedArgs->filtered(OPT_unexported_symbols_list)) {
+ for (auto expFile : parsedArgs.filtered(OPT_unexported_symbols_list)) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) {
diagnostics << "error: -unexported_symbols_list cannot be combined "
<< "with -exported_symbol[s_list]\n";
@@ -650,7 +649,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle -unexported_symbol <symbol>
- for (auto symbol : parsedArgs->filtered(OPT_unexported_symbol)) {
+ for (auto symbol : parsedArgs.filtered(OPT_unexported_symbol)) {
if (ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) {
diagnostics << "error: -unexported_symbol cannot be combined "
<< "with -exported_symbol[s_list]\n";
@@ -661,8 +660,8 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle obosolete -multi_module and -single_module
- if (llvm::opt::Arg *mod = parsedArgs->getLastArg(OPT_multi_module,
- OPT_single_module)) {
+ if (llvm::opt::Arg *mod =
+ parsedArgs.getLastArg(OPT_multi_module, OPT_single_module)) {
if (mod->getOption().getID() == OPT_multi_module) {
diagnostics << "warning: -multi_module is obsolete and being ignored\n";
}
@@ -675,7 +674,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle -pie or -no_pie
- if (llvm::opt::Arg *pie = parsedArgs->getLastArg(OPT_pie, OPT_no_pie)) {
+ if (llvm::opt::Arg *pie = parsedArgs.getLastArg(OPT_pie, OPT_no_pie)) {
switch (ctx.outputMachOType()) {
case llvm::MachO::MH_EXECUTE:
switch (ctx.os()) {
@@ -721,7 +720,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle stack_size
- if (llvm::opt::Arg *stackSize = parsedArgs->getLastArg(OPT_stack_size)) {
+ if (llvm::opt::Arg *stackSize = parsedArgs.getLastArg(OPT_stack_size)) {
uint64_t stackSizeVal;
if (parseNumberBase16(stackSize->getValue(), stackSizeVal)) {
diagnostics << "error: stack_size expects a hex number\n";
@@ -737,11 +736,11 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle debug info handling options: -S
- if (parsedArgs->hasArg(OPT_S))
+ if (parsedArgs.hasArg(OPT_S))
ctx.setDebugInfoMode(MachOLinkingContext::DebugInfoMode::noDebugMap);
// Handle -order_file <file>
- for (auto orderFile : parsedArgs->filtered(OPT_order_file)) {
+ for (auto orderFile : parsedArgs.filtered(OPT_order_file)) {
if (std::error_code ec = parseOrderFile(orderFile->getValue(), ctx,
diagnostics)) {
diagnostics << "error: " << ec.message()
@@ -753,7 +752,7 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
}
// Handle -rpath <path>
- if (parsedArgs->hasArg(OPT_rpath)) {
+ if (parsedArgs.hasArg(OPT_rpath)) {
switch (ctx.outputMachOType()) {
case llvm::MachO::MH_EXECUTE:
case llvm::MachO::MH_DYLIB:
@@ -775,13 +774,13 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
return false;
}
- for (auto rPath : parsedArgs->filtered(OPT_rpath)) {
+ for (auto rPath : parsedArgs.filtered(OPT_rpath)) {
ctx.addRpath(rPath->getValue());
}
}
// Handle input files
- for (auto &arg : *parsedArgs) {
+ for (auto &arg : parsedArgs) {
bool upward;
ErrorOr<StringRef> resolvedPath = StringRef();
switch (arg->getOption().getID()) {
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=240347&r1=240346&r2=240347&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Mon Jun 22 17:06:52 2015
@@ -343,35 +343,35 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
std::unique_ptr<ELFLinkingContext> &context,
raw_ostream &diag) {
// Parse command line options using GnuLdOptions.td
- std::unique_ptr<llvm::opt::InputArgList> parsedArgs;
GnuLdOptTable table;
unsigned missingIndex;
unsigned missingCount;
- parsedArgs.reset(table.ParseArgs(args.slice(1), missingIndex, missingCount));
+ llvm::opt::InputArgList parsedArgs =
+ table.ParseArgs(args.slice(1), missingIndex, missingCount);
if (missingCount) {
diag << "error: missing arg value for '"
- << parsedArgs->getArgString(missingIndex) << "' expected "
+ << parsedArgs.getArgString(missingIndex) << "' expected "
<< missingCount << " argument(s).\n";
return false;
}
// Handle --help
- if (parsedArgs->hasArg(OPT_help)) {
+ if (parsedArgs.hasArg(OPT_help)) {
table.PrintHelp(llvm::outs(), args[0], "LLVM Linker", false);
return true;
}
// Use -target or use default target triple to instantiate LinkingContext
llvm::Triple baseTriple;
- if (auto *arg = parsedArgs->getLastArg(OPT_target)) {
+ if (auto *arg = parsedArgs.getLastArg(OPT_target)) {
baseTriple = llvm::Triple(arg->getValue());
} else {
baseTriple = getDefaultTarget(args[0]);
}
llvm::Triple triple(baseTriple);
- if (!applyEmulation(triple, *parsedArgs, diag))
+ if (!applyEmulation(triple, parsedArgs, diag))
return false;
std::unique_ptr<ELFLinkingContext> ctx(createELFLinkingContext(triple));
@@ -382,39 +382,39 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
}
// Copy mllvm
- for (auto *arg : parsedArgs->filtered(OPT_mllvm))
+ for (auto *arg : parsedArgs.filtered(OPT_mllvm))
ctx->appendLLVMOption(arg->getValue());
// Ignore unknown arguments.
- for (auto unknownArg : parsedArgs->filtered(OPT_UNKNOWN))
+ for (auto unknownArg : parsedArgs.filtered(OPT_UNKNOWN))
diag << "warning: ignoring unknown argument: "
<< unknownArg->getValue() << "\n";
// Set sys root path.
- if (auto *arg = parsedArgs->getLastArg(OPT_sysroot))
+ if (auto *arg = parsedArgs.getLastArg(OPT_sysroot))
ctx->setSysroot(arg->getValue());
// Handle --demangle option(For compatibility)
- if (parsedArgs->hasArg(OPT_demangle))
+ if (parsedArgs.hasArg(OPT_demangle))
ctx->setDemangleSymbols(true);
// Handle --no-demangle option.
- if (parsedArgs->hasArg(OPT_no_demangle))
+ if (parsedArgs.hasArg(OPT_no_demangle))
ctx->setDemangleSymbols(false);
// Figure out output kind (-r, -static, -shared)
- if (parsedArgs->hasArg(OPT_relocatable)) {
+ if (parsedArgs.hasArg(OPT_relocatable)) {
ctx->setOutputELFType(llvm::ELF::ET_REL);
ctx->setPrintRemainingUndefines(false);
ctx->setAllowRemainingUndefines(true);
}
- if (parsedArgs->hasArg(OPT_static)) {
+ if (parsedArgs.hasArg(OPT_static)) {
ctx->setOutputELFType(llvm::ELF::ET_EXEC);
ctx->setIsStaticExecutable(true);
}
- if (parsedArgs->hasArg(OPT_shared)) {
+ if (parsedArgs.hasArg(OPT_shared)) {
ctx->setOutputELFType(llvm::ELF::ET_DYN);
ctx->setAllowShlibUndefines(true);
ctx->setUseShlibUndefines(false);
@@ -423,13 +423,13 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
}
// Handle --stats.
- if (parsedArgs->hasArg(OPT_stats)) {
+ if (parsedArgs.hasArg(OPT_stats)) {
ctx->setCollectStats(true);
}
// Figure out if the output type is nmagic/omagic
- if (auto *arg = parsedArgs->getLastArg(
- OPT_nmagic, OPT_omagic, OPT_no_omagic)) {
+ if (auto *arg =
+ parsedArgs.getLastArg(OPT_nmagic, OPT_omagic, OPT_no_omagic)) {
switch (arg->getOption().getID()) {
case OPT_nmagic:
ctx->setOutputMagic(ELFLinkingContext::OutputMagic::NMAGIC);
@@ -446,25 +446,25 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
}
}
- if (parsedArgs->hasArg(OPT_discard_loc))
+ if (parsedArgs.hasArg(OPT_discard_loc))
ctx->setDiscardLocals(true);
- if (parsedArgs->hasArg(OPT_discard_temp_loc))
+ if (parsedArgs.hasArg(OPT_discard_temp_loc))
ctx->setDiscardTempLocals(true);
- if (parsedArgs->hasArg(OPT_strip_all))
+ if (parsedArgs.hasArg(OPT_strip_all))
ctx->setStripSymbols(true);
- if (auto *arg = parsedArgs->getLastArg(OPT_soname))
+ if (auto *arg = parsedArgs.getLastArg(OPT_soname))
ctx->setSharedObjectName(arg->getValue());
- if (parsedArgs->hasArg(OPT_rosegment))
+ if (parsedArgs.hasArg(OPT_rosegment))
ctx->setCreateSeparateROSegment();
- if (parsedArgs->hasArg(OPT_no_align_segments))
+ if (parsedArgs.hasArg(OPT_no_align_segments))
ctx->setAlignSegments(false);
- if (auto *arg = parsedArgs->getLastArg(OPT_image_base)) {
+ if (auto *arg = parsedArgs.getLastArg(OPT_image_base)) {
uint64_t baseAddress = 0;
StringRef inputValue = arg->getValue();
if (inputValue.getAsInteger(0, baseAddress) || !baseAddress) {
@@ -474,50 +474,49 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
ctx->setBaseAddress(baseAddress);
}
- if (parsedArgs->hasArg(OPT_merge_strings))
+ if (parsedArgs.hasArg(OPT_merge_strings))
ctx->setMergeCommonStrings(true);
- if (parsedArgs->hasArg(OPT_t))
+ if (parsedArgs.hasArg(OPT_t))
ctx->setLogInputFiles(true);
- if (parsedArgs->hasArg(OPT_use_shlib_undefs))
+ if (parsedArgs.hasArg(OPT_use_shlib_undefs))
ctx->setUseShlibUndefines(true);
- if (auto val = getBool(*parsedArgs, OPT_allow_shlib_undefs,
+ if (auto val = getBool(parsedArgs, OPT_allow_shlib_undefs,
OPT_no_allow_shlib_undefs))
ctx->setAllowShlibUndefines(*val);
- if (auto *arg = parsedArgs->getLastArg(OPT_e))
+ if (auto *arg = parsedArgs.getLastArg(OPT_e))
ctx->setEntrySymbolName(arg->getValue());
- if (auto *arg = parsedArgs->getLastArg(OPT_output))
+ if (auto *arg = parsedArgs.getLastArg(OPT_output))
ctx->setOutputPath(arg->getValue());
- if (parsedArgs->hasArg(OPT_noinhibit_exec))
+ if (parsedArgs.hasArg(OPT_noinhibit_exec))
ctx->setAllowRemainingUndefines(true);
- if (auto val = getBool(*parsedArgs, OPT_export_dynamic,
- OPT_no_export_dynamic))
+ if (auto val = getBool(parsedArgs, OPT_export_dynamic, OPT_no_export_dynamic))
ctx->setExportDynamic(*val);
- if (parsedArgs->hasArg(OPT_allow_multiple_definition))
+ if (parsedArgs.hasArg(OPT_allow_multiple_definition))
ctx->setAllowDuplicates(true);
- if (auto *arg = parsedArgs->getLastArg(OPT_dynamic_linker))
+ if (auto *arg = parsedArgs.getLastArg(OPT_dynamic_linker))
ctx->setInterpreter(arg->getValue());
- if (auto *arg = parsedArgs->getLastArg(OPT_init))
+ if (auto *arg = parsedArgs.getLastArg(OPT_init))
ctx->setInitFunction(arg->getValue());
- if (auto *arg = parsedArgs->getLastArg(OPT_fini))
+ if (auto *arg = parsedArgs.getLastArg(OPT_fini))
ctx->setFiniFunction(arg->getValue());
- if (auto *arg = parsedArgs->getLastArg(OPT_output_filetype))
+ if (auto *arg = parsedArgs.getLastArg(OPT_output_filetype))
ctx->setOutputFileType(arg->getValue());
// Process ELF/ARM specific options
- bool hasArmTarget1Rel = parsedArgs->hasArg(OPT_target1_rel);
- bool hasArmTarget1Abs = parsedArgs->hasArg(OPT_target1_abs);
+ bool hasArmTarget1Rel = parsedArgs.hasArg(OPT_target1_rel);
+ bool hasArmTarget1Abs = parsedArgs.hasArg(OPT_target1_abs);
if (triple.getArch() == llvm::Triple::arm) {
if (hasArmTarget1Rel && hasArmTarget1Abs) {
diag << "error: options --target1-rel and --target1-abs"
@@ -527,7 +526,7 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
ctx->setArmTarget1Rel(hasArmTarget1Rel && !hasArmTarget1Abs);
}
} else {
- for (const auto *arg : parsedArgs->filtered(OPT_grp_arm_targetopts)) {
+ for (const auto *arg : parsedArgs.filtered(OPT_grp_arm_targetopts)) {
diag << "warning: ignoring unsupported ARM/ELF specific argument: "
<< arg->getSpelling() << "\n";
}
@@ -538,25 +537,25 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
triple.getArch() == llvm::Triple::mipsel ||
triple.getArch() == llvm::Triple::mips64 ||
triple.getArch() == llvm::Triple::mips64el)
- ctx->setMipsPcRelEhRel(parsedArgs->hasArg(OPT_pcrel_eh_reloc));
+ ctx->setMipsPcRelEhRel(parsedArgs.hasArg(OPT_pcrel_eh_reloc));
else {
- for (const auto *arg : parsedArgs->filtered(OPT_grp_mips_targetopts)) {
+ for (const auto *arg : parsedArgs.filtered(OPT_grp_mips_targetopts)) {
diag << "warning: ignoring unsupported MIPS specific argument: "
<< arg->getSpelling() << "\n";
}
}
- for (auto *arg : parsedArgs->filtered(OPT_L))
+ for (auto *arg : parsedArgs.filtered(OPT_L))
ctx->addSearchPath(arg->getValue());
// Add the default search directory specific to the target.
- if (!parsedArgs->hasArg(OPT_nostdlib))
+ if (!parsedArgs.hasArg(OPT_nostdlib))
addPlatformSearchDirs(*ctx, triple, baseTriple);
- for (auto *arg : parsedArgs->filtered(OPT_u))
+ for (auto *arg : parsedArgs.filtered(OPT_u))
ctx->addInitialUndefinedSymbol(arg->getValue());
- for (auto *arg : parsedArgs->filtered(OPT_defsym)) {
+ for (auto *arg : parsedArgs.filtered(OPT_defsym)) {
StringRef sym, target;
uint64_t addr;
if (parseDefsymAsAbsolute(arg->getValue(), sym, addr)) {
@@ -569,7 +568,7 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
}
}
- for (auto *arg : parsedArgs->filtered(OPT_z)) {
+ for (auto *arg : parsedArgs.filtered(OPT_z)) {
StringRef opt = arg->getValue();
if (opt == "muldefs")
ctx->setAllowDuplicates(true);
@@ -599,14 +598,14 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
}
}
- for (auto *arg : parsedArgs->filtered(OPT_rpath)) {
+ for (auto *arg : parsedArgs.filtered(OPT_rpath)) {
SmallVector<StringRef, 2> rpaths;
StringRef(arg->getValue()).split(rpaths, ":");
for (auto path : rpaths)
ctx->addRpath(path);
}
- for (auto *arg : parsedArgs->filtered(OPT_rpath_link)) {
+ for (auto *arg : parsedArgs.filtered(OPT_rpath_link)) {
SmallVector<StringRef, 2> rpaths;
StringRef(arg->getValue()).split(rpaths, ":");
for (auto path : rpaths)
@@ -614,11 +613,11 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
}
// Enable new dynamic tags.
- if (parsedArgs->hasArg(OPT_enable_newdtags))
+ if (parsedArgs.hasArg(OPT_enable_newdtags))
ctx->setEnableNewDtags(true);
// Support --wrap option.
- for (auto *arg : parsedArgs->filtered(OPT_wrap))
+ for (auto *arg : parsedArgs.filtered(OPT_wrap))
ctx->addWrapForSymbol(arg->getValue());
// Register possible input file parsers.
@@ -634,7 +633,7 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
bool wholeArchive = false;
// Process files
- for (auto arg : *parsedArgs) {
+ for (auto arg : parsedArgs) {
switch (arg->getOption().getID()) {
case OPT_no_whole_archive:
wholeArchive = false;
@@ -695,7 +694,7 @@ bool GnuLdDriver::parse(llvm::ArrayRef<c
diag << "Cannot open " << path << ": " << ec.message() << "\n";
return false;
}
- bool nostdlib = parsedArgs->hasArg(OPT_nostdlib);
+ bool nostdlib = parsedArgs.hasArg(OPT_nostdlib);
std::error_code ec =
evalLinkerScript(*ctx, std::move(mb.get()), diag, nostdlib);
if (ec) {
Modified: lld/trunk/lib/Driver/UniversalDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/UniversalDriver.cpp?rev=240347&r1=240346&r2=240347&view=diff
==============================================================================
--- lld/trunk/lib/Driver/UniversalDriver.cpp (original)
+++ lld/trunk/lib/Driver/UniversalDriver.cpp Mon Jun 22 17:06:52 2015
@@ -136,12 +136,12 @@ static void removeArg(llvm::opt::Arg *ar
}
static Flavor getFlavor(llvm::MutableArrayRef<const char *> &args,
- std::unique_ptr<llvm::opt::InputArgList> &parsedArgs) {
- if (llvm::opt::Arg *argCore = parsedArgs->getLastArg(OPT_core)) {
+ const llvm::opt::InputArgList &parsedArgs) {
+ if (llvm::opt::Arg *argCore = parsedArgs.getLastArg(OPT_core)) {
removeArg(argCore, args);
return Flavor::core;
}
- if (llvm::opt::Arg *argFlavor = parsedArgs->getLastArg(OPT_flavor)) {
+ if (llvm::opt::Arg *argFlavor = parsedArgs.getLastArg(OPT_flavor)) {
removeArg(argFlavor, args);
return strToFlavor(argFlavor->getValue());
}
@@ -166,7 +166,6 @@ namespace lld {
bool UniversalDriver::link(llvm::MutableArrayRef<const char *> args,
raw_ostream &diagnostics) {
// Parse command line options using GnuLdOptions.td
- std::unique_ptr<llvm::opt::InputArgList> parsedArgs;
UniversalDriverOptTable table;
unsigned missingIndex;
unsigned missingCount;
@@ -174,23 +173,24 @@ bool UniversalDriver::link(llvm::Mutable
// Program name
StringRef programName = llvm::sys::path::stem(args[0]);
- parsedArgs.reset(table.ParseArgs(args.slice(1), missingIndex, missingCount));
+ llvm::opt::InputArgList parsedArgs =
+ table.ParseArgs(args.slice(1), missingIndex, missingCount);
if (missingCount) {
diagnostics << "error: missing arg value for '"
- << parsedArgs->getArgString(missingIndex) << "' expected "
+ << parsedArgs.getArgString(missingIndex) << "' expected "
<< missingCount << " argument(s).\n";
return false;
}
// Handle -help
- if (parsedArgs->getLastArg(OPT_help)) {
+ if (parsedArgs.getLastArg(OPT_help)) {
table.PrintHelp(llvm::outs(), programName.data(), "LLVM Linker", false);
return true;
}
// Handle -version
- if (parsedArgs->getLastArg(OPT_version)) {
+ if (parsedArgs.getLastArg(OPT_version)) {
diagnostics << "LLVM Linker Version: " << getLLDVersion()
<< getLLDRepositoryVersion() << "\n";
return true;
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=240347&r1=240346&r2=240347&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Mon Jun 22 17:06:52 2015
@@ -738,31 +738,31 @@ static bool expandResponseFiles(llvm::Ar
// Parses the given command line options and returns the result. Returns NULL if
// there's an error in the options.
-static std::unique_ptr<llvm::opt::InputArgList>
+static llvm::Optional<llvm::opt::InputArgList>
parseArgs(llvm::ArrayRef<const char *> args, PECOFFLinkingContext &ctx,
raw_ostream &diag, bool isReadingDirectiveSection) {
// Expand arguments starting with "@".
bool expanded = false;
if (!expandResponseFiles(args, ctx, diag, expanded))
- return nullptr;
+ return llvm::None;
// Parse command line options using WinLinkOptions.td
- std::unique_ptr<llvm::opt::InputArgList> parsedArgs;
WinLinkOptTable table;
unsigned missingIndex;
unsigned missingCount;
- parsedArgs.reset(table.ParseArgs(args.slice(1), missingIndex, missingCount));
+ llvm::opt::InputArgList parsedArgs =
+ table.ParseArgs(args.slice(1), missingIndex, missingCount);
if (missingCount) {
diag << "error: missing arg value for '"
- << parsedArgs->getArgString(missingIndex) << "' expected "
+ << parsedArgs.getArgString(missingIndex) << "' expected "
<< missingCount << " argument(s).\n";
- return nullptr;
+ return llvm::None;
}
// Show warning for unknown arguments. In .drectve section, unknown options
// starting with "-?" are silently ignored. This is a COFF's feature to embed a
// new linker option to an object file while keeping backward compatibility.
- for (auto unknownArg : parsedArgs->filtered(OPT_UNKNOWN)) {
+ for (auto unknownArg : parsedArgs.filtered(OPT_UNKNOWN)) {
StringRef arg = unknownArg->getSpelling();
if (isReadingDirectiveSection && arg.startswith("-?"))
continue;
@@ -770,20 +770,20 @@ parseArgs(llvm::ArrayRef<const char *> a
}
// Copy mllvm
- for (auto arg : parsedArgs->filtered(OPT_mllvm))
+ for (auto arg : parsedArgs.filtered(OPT_mllvm))
ctx.appendLLVMOption(arg->getValue());
// If we have expaneded response files and /verbose is given, print out the
// final command line.
if (!isReadingDirectiveSection && expanded &&
- parsedArgs->getLastArg(OPT_verbose)) {
+ parsedArgs.getLastArg(OPT_verbose)) {
diag << "Command line:";
for (const char *arg : args)
diag << " " << arg;
diag << "\n\n";
}
- return parsedArgs;
+ return std::move(parsedArgs);
}
// Returns true if the given file node has already been added to the input
@@ -874,7 +874,7 @@ bool WinLinkDriver::parse(llvm::ArrayRef
std::map<StringRef, StringRef> failIfMismatchMap;
// Parse the options.
- std::unique_ptr<llvm::opt::InputArgList> parsedArgs =
+ llvm::Optional<llvm::opt::InputArgList> parsedArgs =
parseArgs(args, ctx, diag, isReadingDirectiveSection);
if (!parsedArgs)
return false;
More information about the llvm-commits
mailing list