mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Implement an isBytecodeArchive method to determine if an archive contains
bytecode file members or not. Patch Contributed By Adam Treat llvm-svn: 20338
This commit is contained in:
parent
cf3cda8125
commit
24b41ba78d
@ -414,6 +414,15 @@ class Archive {
|
||||
std::set<std::string>& symbols, ///< Symbols to be sought
|
||||
std::set<ModuleProvider*>& modules ///< The modules matching \p symbols
|
||||
);
|
||||
|
||||
/// This method determines whether the archive is a properly formed llvm
|
||||
/// bytecode archive. It first makes sure the symbol table has been loaded
|
||||
/// and has a non-zero size. If it does, then it is an archive. If not,
|
||||
/// then it tries to load all the bytecode modules of the archive. Finally,
|
||||
/// it returns whether it was successfull.
|
||||
/// @returns true if the archive is a proper llvm bytecode archive
|
||||
/// @brief Determine whether the archive is a proper llvm bytecode archive.
|
||||
bool isBytecodeArchive();
|
||||
|
||||
/// @}
|
||||
/// @name Mutators
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user