From eaa06bb9792f14628402da55caa554965f25e49c Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sat, 26 Feb 2005 22:00:32 +0000 Subject: Implement an isBytecodeArchive method to determine if an archive contains bytecode file members or not. Patch Contributed By Adam Treat git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20338 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Archive/ArchiveReader.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'lib/Archive/ArchiveReader.cpp') diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp index 56b42ffdb2..7eab19d11d 100644 --- a/lib/Archive/ArchiveReader.cpp +++ b/lib/Archive/ArchiveReader.cpp @@ -503,3 +503,32 @@ Archive::findModulesDefiningSymbols(std::set& symbols, } } } + +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 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(); +} -- cgit v1.2.3