[llvm-commits] CVS: llvm/lib/Bytecode/Archive/ArchiveReader.cpp

Reid Spencer reid at x10sys.com
Thu Nov 18 19:18:33 PST 2004



Changes in directory llvm/lib/Bytecode/Archive:

ArchiveReader.cpp updated: 1.27 -> 1.28
---
Log message:

Make findModulesDefiningSymbols modify its symbols argument so we can \
eliminate symbols defined by the archive efficiently

---
Diffs of the changes:  (+14 -3)

Index: llvm/lib/Bytecode/Archive/ArchiveReader.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.27 llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.28
--- llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.27	Wed Nov 17 12:25:21 2004
+++ llvm/lib/Bytecode/Archive/ArchiveReader.cpp	Thu Nov 18 21:18:22 2004
@@ -407,7 +407,7 @@
 // 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 @@
   // 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;
     }
   }
 }






More information about the llvm-commits mailing list