diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-02-16 09:30:23 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-02-16 09:30:23 +0000 |
commit | f25ddd991a5601d0101602c4c263a58c7af4b8a2 (patch) | |
tree | 4cfca640904d1896e25032757a61f8959c066919 /lib/Archive/ArchiveReader.cpp | |
parent | 3fd58f91dd318518f7daa4ba64c0aaf31799d89b (diff) | |
download | FreeBSD-src-f25ddd991a5601d0101602c4c263a58c7af4b8a2.zip FreeBSD-src-f25ddd991a5601d0101602c4c263a58c7af4b8a2.tar.gz |
Update LLVM to r96341.
Diffstat (limited to 'lib/Archive/ArchiveReader.cpp')
-rw-r--r-- | lib/Archive/ArchiveReader.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp index 74895d8..3ef15d2 100644 --- a/lib/Archive/ArchiveReader.cpp +++ b/lib/Archive/ArchiveReader.cpp @@ -120,7 +120,8 @@ Archive::parseMemberHeader(const char*& At, const char* End, std::string* error) if (Hdr->name[1] == '1' && Hdr->name[2] == '/') { if (isdigit(Hdr->name[3])) { unsigned len = atoi(&Hdr->name[3]); - pathname.assign(At, len); + const char *nulp = (const char *)memchr(At, '\0', len); + pathname.assign(At, nulp != 0 ? nulp - At : len); At += len; MemberSize -= len; flags |= ArchiveMember::HasLongFilenameFlag; @@ -452,9 +453,9 @@ Archive* Archive::OpenAndLoadSymbols(const sys::Path& file, return result.release(); } -// Look up one symbol in the symbol table and return a ModuleProvider for the -// module that defines that symbol. -ModuleProvider* +// Look up one symbol in the symbol table and return the module that defines +// that symbol. +Module* Archive::findModuleDefiningSymbol(const std::string& symbol, std::string* ErrMsg) { SymTabType::iterator SI = symTab.find(symbol); @@ -483,27 +484,27 @@ Archive::findModuleDefiningSymbol(const std::string& symbol, if (!mbr) return 0; - // Now, load the bitcode module to get the ModuleProvider + // Now, load the bitcode module to get the Module. std::string FullMemberName = archPath.str() + "(" + mbr->getPath().str() + ")"; MemoryBuffer *Buffer =MemoryBuffer::getNewMemBuffer(mbr->getSize(), FullMemberName.c_str()); memcpy((char*)Buffer->getBufferStart(), mbr->getData(), mbr->getSize()); - ModuleProvider *mp = getBitcodeModuleProvider(Buffer, Context, ErrMsg); - if (!mp) + Module *m = getLazyBitcodeModule(Buffer, Context, ErrMsg); + if (!m) return 0; - modules.insert(std::make_pair(fileOffset, std::make_pair(mp, mbr))); + modules.insert(std::make_pair(fileOffset, std::make_pair(m, mbr))); - return mp; + return m; } // Look up multiple symbols in the symbol table and return a set of -// ModuleProviders that define those symbols. +// Modules that define those symbols. bool Archive::findModulesDefiningSymbols(std::set<std::string>& symbols, - std::set<ModuleProvider*>& result, + std::set<Module*>& result, std::string* error) { if (!mapfile || !base) { if (error) @@ -536,19 +537,19 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols, std::vector<std::string> symbols; std::string FullMemberName = archPath.str() + "(" + mbr->getPath().str() + ")"; - ModuleProvider* MP = + Module* M = GetBitcodeSymbols((const unsigned char*)At, mbr->getSize(), FullMemberName, Context, symbols, error); - if (MP) { + if (M) { // Insert the module's symbols into the symbol table for (std::vector<std::string>::iterator I = symbols.begin(), E=symbols.end(); I != E; ++I ) { symTab.insert(std::make_pair(*I, offset)); } - // Insert the ModuleProvider and the ArchiveMember into the table of + // Insert the Module and the ArchiveMember into the table of // modules. - modules.insert(std::make_pair(offset, std::make_pair(MP, mbr))); + modules.insert(std::make_pair(offset, std::make_pair(M, mbr))); } else { if (error) *error = "Can't parse bitcode member: " + @@ -571,11 +572,11 @@ Archive::findModulesDefiningSymbols(std::set<std::string>& symbols, for (std::set<std::string>::iterator I=symbols.begin(), E=symbols.end(); I != E;) { // See if this symbol exists - ModuleProvider* mp = findModuleDefiningSymbol(*I,error); - if (mp) { - // The symbol exists, insert the ModuleProvider into our result, - // duplicates wil be ignored - result.insert(mp); + Module* m = findModuleDefiningSymbol(*I,error); + if (m) { + // The symbol exists, insert the Module into our result, duplicates will + // be ignored. + result.insert(m); // Remove the symbol now that its been resolved, being careful to // post-increment the iterator. |