diff options
Diffstat (limited to 'contrib/llvm/lib/Archive/ArchiveReader.cpp')
-rw-r--r-- | contrib/llvm/lib/Archive/ArchiveReader.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/contrib/llvm/lib/Archive/ArchiveReader.cpp b/contrib/llvm/lib/Archive/ArchiveReader.cpp index eef6fe0..68873e2 100644 --- a/contrib/llvm/lib/Archive/ArchiveReader.cpp +++ b/contrib/llvm/lib/Archive/ArchiveReader.cpp @@ -12,9 +12,11 @@ //===----------------------------------------------------------------------===// #include "ArchiveInternals.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Module.h" +#include <cstdio> #include <cstdlib> #include <memory> using namespace llvm; @@ -504,7 +506,7 @@ Archive::findModuleDefiningSymbol(const std::string& symbol, // Modules that define those symbols. bool Archive::findModulesDefiningSymbols(std::set<std::string>& symbols, - std::set<Module*>& result, + SmallVectorImpl<Module*>& result, std::string* error) { if (!mapfile || !base) { if (error) @@ -569,21 +571,26 @@ Archive::findModulesDefiningSymbols(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. + SmallPtrSet<Module*, 16> Added; for (std::set<std::string>::iterator I=symbols.begin(), - E=symbols.end(); I != E;) { + Next = I, + E=symbols.end(); I != E; I = Next) { + // Increment Next before we invalidate it. + ++Next; + // See if this symbol exists Module* m = findModuleDefiningSymbol(*I,error); - if (m) { - // The symbol exists, insert the Module into our result, duplicates will - // be ignored. - result.insert(m); - - // Remove the symbol now that its been resolved, being careful to - // post-increment the iterator. - symbols.erase(I++); - } else { - ++I; - } + if (!m) + continue; + bool NewMember = Added.insert(m); + if (!NewMember) + continue; + + // The symbol exists, insert the Module into our result. + result.push_back(m); + + // Remove the symbol now that its been resolved. + symbols.erase(I); } return true; } |