[lld] r212616 - [all]: Use range-based ArgList adapter instead of filtered_begin/filtered_end
Tim Northover
tnorthover at apple.com
Wed Jul 9 06:03:55 PDT 2014
Author: tnorthover
Date: Wed Jul 9 08:03:54 2014
New Revision: 212616
URL: http://llvm.org/viewvc/llvm-project?rev=212616&view=rev
Log:
[all]: Use range-based ArgList adapter instead of filtered_begin/filtered_end
Some of those loops were pretty monstrous.
Modified:
lld/trunk/lib/Driver/DarwinLdDriver.cpp
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/lib/Driver/WinLinkDriver.cpp
Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=212616&r1=212615&r2=212616&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Wed Jul 9 08:03:54 2014
@@ -104,10 +104,9 @@ bool DarwinLdDriver::parse(int argc, con
return false;
}
- for (auto it = parsedArgs->filtered_begin(OPT_UNKNOWN),
- ie = parsedArgs->filtered_end(); it != ie; ++it) {
+ for (auto unknownArg : parsedArgs->filtered(OPT_UNKNOWN)) {
diagnostics << "warning: ignoring unknown argument: "
- << (*it)->getAsString(*parsedArgs) << "\n";
+ << unknownArg->getAsString(*parsedArgs) << "\n";
}
// Figure out output kind ( -dylib, -r, -bundle, -preload, or -static )
@@ -256,10 +255,8 @@ bool DarwinLdDriver::parse(int argc, con
}
// Handle -mllvm
- for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_mllvm),
- ie = parsedArgs->filtered_end();
- it != ie; ++it) {
- ctx.appendLLVMOption((*it)->getValue());
+ for (auto &llvmArg : parsedArgs->filtered(OPT_mllvm)) {
+ ctx.appendLLVMOption(llvmArg->getValue());
}
// Handle -print_atoms a
@@ -269,11 +266,9 @@ bool DarwinLdDriver::parse(int argc, con
std::unique_ptr<InputGraph> inputGraph(new InputGraph());
// Handle input files
- for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_INPUT),
- ie = parsedArgs->filtered_end();
- it != ie; ++it) {
+ for (auto &inputFile : parsedArgs->filtered(OPT_INPUT)) {
inputGraph->addInputElement(std::unique_ptr<InputElement>(
- new MachOFileNode(ctx, (*it)->getValue(), globalWholeArchive)));
+ new MachOFileNode(ctx, inputFile->getValue(), globalWholeArchive)));
}
if (!inputGraph->size()) {
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=212616&r1=212615&r2=212616&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Wed Jul 9 08:03:54 2014
@@ -288,21 +288,17 @@ bool GnuLdDriver::parse(int argc, const
bool _outputOptionSet = false;
// Ignore unknown arguments.
- for (auto it = parsedArgs->filtered_begin(OPT_UNKNOWN),
- ie = parsedArgs->filtered_end();
- it != ie; ++it)
- diagnostics << "warning: ignoring unknown argument: " << (*it)->getValue()
- << "\n";
+ for (auto unknownArg : parsedArgs->filtered(OPT_UNKNOWN))
+ diagnostics << "warning: ignoring unknown argument: "
+ << unknownArg->getValue() << "\n";
// Set sys root path.
if (llvm::opt::Arg *sysRootPath = parsedArgs->getLastArg(OPT_sysroot))
ctx->setSysroot(sysRootPath->getValue());
// Add all search paths.
- for (auto it = parsedArgs->filtered_begin(OPT_L),
- ie = parsedArgs->filtered_end();
- it != ie; ++it)
- ctx->addSearchPath((*it)->getValue());
+ for (auto libDir : parsedArgs->filtered(OPT_L))
+ ctx->addSearchPath(libDir->getValue());
if (!parsedArgs->hasArg(OPT_nostdlib))
addPlatformSearchDirs(*ctx, triple, baseTriple);
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=212616&r1=212615&r2=212616&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Wed Jul 9 08:03:54 2014
@@ -696,9 +696,8 @@ parseArgs(int argc, const char **argv, P
// 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 it = parsedArgs->filtered_begin(OPT_UNKNOWN),
- ie = parsedArgs->filtered_end(); it != ie; ++it) {
- StringRef arg = (*it)->getSpelling();
+ for (auto unknownArg : parsedArgs->filtered(OPT_UNKNOWN)) {
+ StringRef arg = unknownArg->getSpelling();
if (isReadingDirectiveSection && arg.startswith("-?"))
continue;
diag << "warning: ignoring unknown argument: " << arg << "\n";
@@ -830,19 +829,15 @@ bool WinLinkDriver::parse(int argc, cons
// Handle /nodefaultlib:<lib>. The same option without argument is handled in
// the following for loop.
- for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_nodefaultlib),
- ie = parsedArgs->filtered_end();
- it != ie; ++it) {
- ctx.addNoDefaultLib((*it)->getValue());
+ for (auto nodeDefaultLib : parsedArgs->filtered(OPT_nodefaultlib)) {
+ ctx.addNoDefaultLib(nodeDefaultLib->getValue());
}
// Handle /defaultlib. Argument of the option is added to the input file list
// unless it's blacklisted by /nodefaultlib.
std::vector<StringRef> defaultLibs;
- for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_defaultlib),
- ie = parsedArgs->filtered_end();
- it != ie; ++it) {
- defaultLibs.push_back((*it)->getValue());
+ for (auto defaultLib : parsedArgs->filtered(OPT_defaultlib)) {
+ defaultLibs.push_back(defaultLib->getValue());
}
std::vector<StringRef> inputFiles;
More information about the llvm-commits
mailing list