summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/lib/Driver/Driver.cpp7
-rw-r--r--lld/lib/Driver/WinLinkDriver.cpp5
2 files changed, 4 insertions, 8 deletions
diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp
index f803d121037..e7ab500a2ab 100644
--- a/lld/lib/Driver/Driver.cpp
+++ b/lld/lib/Driver/Driver.cpp
@@ -77,11 +77,8 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
if (context.getNodes().empty())
return false;
- // File::parse may add items to the node list which may invalidate
- // existing iterators. Avoid using iterator to access elements.
- std::vector<std::unique_ptr<Node>> &nodes = context.getNodes();
- for (size_t i = 0; i < nodes.size(); ++i)
- if (FileNode *node = dyn_cast<FileNode>(nodes[i].get()))
+ for (std::unique_ptr<Node> &ie : context.getNodes())
+ if (FileNode *node = dyn_cast<FileNode>(ie.get()))
context.getTaskGroup().spawn([node] { node->getFile()->parse(); });
std::vector<std::unique_ptr<File>> internalFiles;
diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp
index ead06ad3a0a..6ee7a5a004b 100644
--- a/lld/lib/Driver/WinLinkDriver.cpp
+++ b/lld/lib/Driver/WinLinkDriver.cpp
@@ -805,9 +805,8 @@ parseArgs(int argc, const char **argv, PECOFFLinkingContext &ctx,
// graph.
static bool hasLibrary(PECOFFLinkingContext &ctx, File *file) {
StringRef path = file->path();
- std::vector<std::unique_ptr<Node>> &nodes = ctx.getNodes();
- for (size_t i = 0; i < nodes.size(); ++i)
- if (auto *f = dyn_cast<FileNode>(nodes[i].get()))
+ for (std::unique_ptr<Node> &p : ctx.getNodes())
+ if (auto *f = dyn_cast<FileNode>(p.get()))
if (f->getFile()->path() == path)
return true;
return false;
OpenPOWER on IntegriCloud