projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More changes from Chris' review: simplify getIndices and avoid
[oota-llvm.git]
/
lib
/
Archive
/
ArchiveReader.cpp
diff --git
a/lib/Archive/ArchiveReader.cpp
b/lib/Archive/ArchiveReader.cpp
index 93eaac18f6bd4d4d0072c4f7179d1bc3b07df5bd..1ded9e5c4cc0692d9d1b6c56e0bf869b1fedd2be 100644
(file)
--- a/
lib/Archive/ArchiveReader.cpp
+++ b/
lib/Archive/ArchiveReader.cpp
@@
-2,8
+2,8
@@
//
// The LLVM Compiler Infrastructure
//
//
// The LLVM Compiler Infrastructure
//
-// This file
was developed by Reid Spencer and is distributed under th
e
-//
University of Illinois Open Source
License. See LICENSE.TXT for details.
+// This file
is distributed under the University of Illinois Open Sourc
e
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
//
@@
-19,7
+19,7
@@
using namespace llvm;
/// Read a variable-bit-rate encoded unsigned integer
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;
unsigned Shift = 0;
unsigned Result = 0;
@@
-204,19
+204,13
@@
Archive::parseMemberHeader(const char*& At, const char* End, std::string* error)
break;
}
break;
}
- // Determine if this is a b
yte
code file
+ // Determine if this is a b
it
code file
switch (sys::IdentifyFileType(At, 4)) {
case sys::Bitcode_FileType:
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:
break;
default:
- flags &= ~(ArchiveMember::BytecodeFlag|
- ArchiveMember::CompressedBytecodeFlag);
+ flags &= ~ArchiveMember::BitcodeFlag;
break;
}
break;
}
@@
-244,7
+238,7
@@
Archive::parseMemberHeader(const char*& At, const char* End, std::string* error)
bool
Archive::checkSignature(std::string* error) {
// Check the magic string at file's header
bool
Archive::checkSignature(std::string* error) {
// Check the magic string at file's header
- if (mapfile->
s
ize() < 8 || memcmp(base, ARFILE_MAGIC, 8)) {
+ if (mapfile->
getBufferS
ize() < 8 || memcmp(base, ARFILE_MAGIC, 8)) {
if (error)
*error = "invalid signature for an archive file";
return false;
if (error)
*error = "invalid signature for an archive file";
return false;
@@
-262,7
+256,7
@@
Archive::loadArchive(std::string* error) {
members.clear();
symTab.clear();
const char *At = base;
members.clear();
symTab.clear();
const char *At = base;
- const char *End =
base + mapfile->size
();
+ const char *End =
mapfile->getBufferEnd
();
if (!checkSignature(error))
return false;
if (!checkSignature(error))
return false;
@@
-349,7
+343,7
@@
bool
Archive::getAllModules(std::vector<Module*>& Modules, std::string* ErrMessage) {
for (iterator I=begin(), E=end(); I != E; ++I) {
Archive::getAllModules(std::vector<Module*>& Modules, std::string* ErrMessage) {
for (iterator I=begin(), E=end(); I != E; ++I) {
- if (I->isB
ytecode() || I->isCompressedByte
code()) {
+ if (I->isB
it
code()) {
std::string FullMemberName = archPath.toString() +
"(" + I->getPath().toString() + ")";
MemoryBuffer *Buffer =
std::string FullMemberName = archPath.toString() +
"(" + I->getPath().toString() + ")";
MemoryBuffer *Buffer =
@@
-375,7
+369,7
@@
Archive::loadSymbolTable(std::string* ErrorMsg) {
members.clear();
symTab.clear();
const char *At = base;
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))
// Make sure we're dealing with an archive
if (!checkSignature(ErrorMsg))
@@
-483,7
+477,8
@@
Archive::findModuleDefiningSymbol(const std::string& symbol,
// Module hasn't been loaded yet, we need to load it
const char* modptr = base + fileOffset;
// 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;
if (!mbr)
return 0;
@@
-522,8
+517,8
@@
Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
// below.
// Get a pointer to the first file
// 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
while ( At < End) {
// Compute the offset to be put in the symbol table
@@
-535,7
+530,7
@@
Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
return false;
// If it contains symbols
return false;
// If it contains symbols
- if (mbr->isB
ytecode() || mbr->isCompressedByte
code()) {
+ if (mbr->isB
it
code()) {
// Get the symbols
std::vector<std::string> symbols;
std::string FullMemberName = archPath.toString() + "(" +
// Get the symbols
std::vector<std::string> symbols;
std::string FullMemberName = archPath.toString() + "(" +
@@
-594,7
+589,7
@@
Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
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.
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;
if (!loadSymbolTable(0))
return false;
@@
-612,7
+607,7
@@
bool Archive::isBitcodeArchive() {
// 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) {
// 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->isB
ytecode() && !I->isCompressedByte
code())
+ if (!I->isB
it
code())
continue;
std::string FullMemberName =
continue;
std::string FullMemberName =