[llvm-commits] CVS: llvm/lib/Bytecode/Archive/ArchiveReader.cpp 
    Reid Spencer 
    reid at x10sys.com
       
    Sat Feb 26 14:00:43 PST 2005
    
    
  
Changes in directory llvm/lib/Bytecode/Archive:
ArchiveReader.cpp updated: 1.38 -> 1.39
---
Log message:
Implement an isBytecodeArchive method to determine if an archive contains
bytecode file members or not.
Patch Contributed By Adam Treat
---
Diffs of the changes:  (+29 -0)
 ArchiveReader.cpp |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+)
Index: llvm/lib/Bytecode/Archive/ArchiveReader.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.38 llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.39
--- llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.38	Tue Dec 28 19:20:24 2004
+++ llvm/lib/Bytecode/Archive/ArchiveReader.cpp	Sat Feb 26 16:00:32 2005
@@ -503,3 +503,32 @@
     }
   }
 }
+
+bool
+Archive::isBytecodeArchive()
+{
+  //Make sure the symTab has been loaded...
+  //in most cases this should have been done
+  //when the archive was constructed, but still, 
+  //this is just in case.
+  if ( !symTab.size() )
+    loadSymbolTable();
+
+  //Now that we know it's been loaded, return true
+  //if it has a size  
+  if ( symTab.size() ) return true;
+
+  //We still can't be sure it isn't a bytecode archive
+  loadArchive();
+
+  std::vector<Module *> Modules;
+  std::string ErrorMessage;
+
+  //If getAllModules gives an error then this isn't a proper
+  //bytecode archive
+  if ( getAllModules( Modules, &ErrorMessage ) ) return false;
+
+  //Finally, if we find any bytecode modules then this is a proper
+  //bytecode archive
+  return Modules.size();
+}
    
    
More information about the llvm-commits
mailing list