diff --git a/lib/Bytecode/Reader/ReaderWrappers.cpp b/lib/Bytecode/Reader/ReaderWrappers.cpp index 09bc55b3361..b70c3ef4a33 100644 --- a/lib/Bytecode/Reader/ReaderWrappers.cpp +++ b/lib/Bytecode/Reader/ReaderWrappers.cpp @@ -336,6 +336,7 @@ bool llvm::GetBytecodeDependentLibraries(const std::string &fname, try { std::auto_ptr AMP( getBytecodeModuleProvider(fname)); Module* M = AMP->releaseModule(); + deplibs = M->getLibraries(); delete M; return true; @@ -345,4 +346,42 @@ bool llvm::GetBytecodeDependentLibraries(const std::string &fname, } } +// Get just the externally visible defined symbols from the bytecode +bool llvm::GetBytecodeSymbols(const sys::Path& fName, + std::vector& symbols) { + try { + std::auto_ptr AMP( getBytecodeModuleProvider(fName.get())); + + // Get the module from the provider + Module* M = AMP->releaseModule(); + + // Loop over global variables + for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI) { + if (GI->hasInitializer()) { + std::string name ( GI->getName() ); + if (!name.empty()) { + symbols.push_back(name); + } + } + } + + //Loop over functions + for (Module::iterator FI = M->begin(), FE=M->end(); FI != FE; ++FI) { + if (!FI->isExternal()) { + std::string name ( FI->getName() ); + if (!name.empty()) { + symbols.push_back(name); + } + } + } + + // Done with the module + delete M; + return true; + + } catch (...) { + return false; + } +} + // vim: sw=2 ai