//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Reid Spencer and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
using namespace llvm;
/// Read a variable-bit-rate encoded unsigned integer
-inline unsigned readInteger(const char*&At, const char*End){
+static inline unsigned readInteger(const char*&At, const char*End) {
unsigned Shift = 0;
unsigned Result = 0;
break;
}
- // Determine if this is a bytecode file
+ // Determine if this is a bitcode file
switch (sys::IdentifyFileType(At, 4)) {
case sys::Bitcode_FileType:
- case sys::Bytecode_FileType:
- flags |= ArchiveMember::BytecodeFlag;
- break;
- case sys::CompressedBytecode_FileType:
- flags |= ArchiveMember::CompressedBytecodeFlag;
- flags &= ~ArchiveMember::CompressedFlag;
+ flags |= ArchiveMember::BitcodeFlag;
break;
default:
- flags &= ~(ArchiveMember::BytecodeFlag|
- ArchiveMember::CompressedBytecodeFlag);
+ flags &= ~ArchiveMember::BitcodeFlag;
break;
}
bool
Archive::checkSignature(std::string* error) {
// Check the magic string at file's header
- if (mapfile->size() < 8 || memcmp(base, ARFILE_MAGIC, 8)) {
+ if (mapfile->getBufferSize() < 8 || memcmp(base, ARFILE_MAGIC, 8)) {
if (error)
*error = "invalid signature for an archive file";
return false;
members.clear();
symTab.clear();
const char *At = base;
- const char *End = base + mapfile->size();
+ const char *End = mapfile->getBufferEnd();
if (!checkSignature(error))
return false;
Archive::getAllModules(std::vector<Module*>& Modules, std::string* ErrMessage) {
for (iterator I=begin(), E=end(); I != E; ++I) {
- if (I->isBytecode() || I->isCompressedBytecode()) {
+ if (I->isBitcode()) {
std::string FullMemberName = archPath.toString() +
"(" + I->getPath().toString() + ")";
MemoryBuffer *Buffer =
members.clear();
symTab.clear();
const char *At = base;
- const char *End = base + mapfile->size();
+ const char *End = mapfile->getBufferEnd();
// Make sure we're dealing with an archive
if (!checkSignature(ErrorMsg))
// Module hasn't been loaded yet, we need to load it
const char* modptr = base + fileOffset;
- ArchiveMember* mbr = parseMemberHeader(modptr, base + mapfile->size(),ErrMsg);
+ ArchiveMember* mbr = parseMemberHeader(modptr, mapfile->getBufferEnd(),
+ ErrMsg);
if (!mbr)
return 0;
// below.
// Get a pointer to the first file
- const char* At = ((const char*)base) + firstFileOffset;
- const char* End = ((const char*)base) + mapfile->size();
+ const char* At = base + firstFileOffset;
+ const char* End = mapfile->getBufferEnd();
while ( At < End) {
// Compute the offset to be put in the symbol table
return false;
// If it contains symbols
- if (mbr->isBytecode() || mbr->isCompressedBytecode()) {
+ if (mbr->isBitcode()) {
// Get the symbols
std::vector<std::string> symbols;
std::string FullMemberName = archPath.toString() + "(" +
bool Archive::isBitcodeArchive() {
// 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())
+ if (symTab.empty())
if (!loadSymbolTable(0))
return false;
// Scan the archive, trying to load a bitcode member. We only load one to
// see if this works.
for (iterator I = begin(), E = end(); I != E; ++I) {
- if (!I->isBytecode() && !I->isCompressedBytecode())
+ if (!I->isBitcode())
continue;
std::string FullMemberName =