summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-11-19 03:18:22 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-11-19 03:18:22 +0000
commit39a0347b7998e68cf5c2d4a1b2900be5f40bc5c6 (patch)
tree9adc0c1c97c1bdc89917fd9e425e59e5aa4bdc0f /llvm/lib/Bytecode
parentc2455ca7b75af92db40a5a990e18ee31ded44a2e (diff)
downloadbcm5719-llvm-39a0347b7998e68cf5c2d4a1b2900be5f40bc5c6.tar.gz
bcm5719-llvm-39a0347b7998e68cf5c2d4a1b2900be5f40bc5c6.zip
Make findModulesDefiningSymbols modify its symbols argument so we can \
eliminate symbols defined by the archive efficiently llvm-svn: 17976
Diffstat (limited to 'llvm/lib/Bytecode')
-rw-r--r--llvm/lib/Bytecode/Archive/ArchiveReader.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Bytecode/Archive/ArchiveReader.cpp b/llvm/lib/Bytecode/Archive/ArchiveReader.cpp
index 615df2bf5f2..6f5b9d36edf 100644
--- a/llvm/lib/Bytecode/Archive/ArchiveReader.cpp
+++ b/llvm/lib/Bytecode/Archive/ArchiveReader.cpp
@@ -407,7 +407,7 @@ Archive::findModuleDefiningSymbol(const std::string& symbol) {
// Look up multiple symbols in the symbol table and return a set of
// ModuleProviders that define those symbols.
void
-Archive::findModulesDefiningSymbols(const std::set<std::string>& symbols,
+Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
std::set<ModuleProvider*>& result)
{
assert(mapfile && base && "Can't findModulesDefiningSymbols on new archive");
@@ -462,11 +462,22 @@ Archive::findModulesDefiningSymbols(const std::set<std::string>& symbols,
// At this point we have a valid symbol table (one way or another) so we
// just use it to quickly find the symbols requested.
- for (std::set<std::string>::const_iterator I=symbols.begin(),
- E=symbols.end(); I != E; ++I) {
+ for (std::set<std::string>::iterator I=symbols.begin(),
+ E=symbols.end(); I != E;) {
+ // See if this symbol exists
ModuleProvider* mp = findModuleDefiningSymbol(*I);
if (mp) {
+ // The symbol exists, insert the ModuleProvider into our result,
+ // duplicates wil be ignored
result.insert(mp);
+
+ // Remove the symbol now that its been resolved, being careful to
+ // not invalidate our iterator.
+ std::set<std::string>::iterator save = I;
+ ++I;
+ symbols.erase(save);
+ } else {
+ ++I;
}
}
}
OpenPOWER on IntegriCloud