summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2005-02-26 22:00:32 +0000
committerReid Spencer <rspencer@reidspencer.com>2005-02-26 22:00:32 +0000
commit709e10ed92a0ca028cfa794c2a5093272df03708 (patch)
tree00b8cba3739607f66fef725d7483cb0ad14e4eff /llvm/lib/Bytecode
parentf05d2b31786d76a9776775f40c8b7833290bf7cd (diff)
downloadbcm5719-llvm-709e10ed92a0ca028cfa794c2a5093272df03708.tar.gz
bcm5719-llvm-709e10ed92a0ca028cfa794c2a5093272df03708.zip
Implement an isBytecodeArchive method to determine if an archive contains
bytecode file members or not. Patch Contributed By Adam Treat llvm-svn: 20338
Diffstat (limited to 'llvm/lib/Bytecode')
-rw-r--r--llvm/lib/Bytecode/Archive/ArchiveReader.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/Bytecode/Archive/ArchiveReader.cpp b/llvm/lib/Bytecode/Archive/ArchiveReader.cpp
index 56b42ffdb2e..7eab19d11db 100644
--- a/llvm/lib/Bytecode/Archive/ArchiveReader.cpp
+++ b/llvm/lib/Bytecode/Archive/ArchiveReader.cpp
@@ -503,3 +503,32 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& 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<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();
+}
OpenPOWER on IntegriCloud