//
// 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.
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_BITECODE_ARCHIVE_H
-#define LLVM_BITECODE_ARCHIVE_H
+#ifndef LLVM_BITCODE_ARCHIVE_H
+#define LLVM_BITCODE_ARCHIVE_H
-#include "llvm/ADT/ilist"
+#include "llvm/ADT/ilist.h"
#include "llvm/System/Path.h"
-#include "llvm/System/MappedFile.h"
#include <map>
#include <set>
#include <fstream>
namespace llvm {
+ class MemoryBuffer;
// Forward declare classes
class ModuleProvider; // From VMCore
SVR4SymbolTableFlag = 2, ///< Member is a SVR4 symbol table
BSD4SymbolTableFlag = 4, ///< Member is a BSD4 symbol table
LLVMSymbolTableFlag = 8, ///< Member is an LLVM symbol table
- BytecodeFlag = 16, ///< Member is uncompressed bytecode
- CompressedBytecodeFlag = 32, ///< Member is compressed bytecode
+ BitcodeFlag = 16, ///< Member is bitcode
HasPathFlag = 64, ///< Member has a full or partial path
HasLongFilenameFlag = 128, ///< Member uses the long filename syntax
StringTableFlag = 256 ///< Member is an ar(1) format string table
/// @brief Get the data content of the archive member
const void* getData() const { return data; }
- /// This method determines if the member is a regular compressed file. Note
- /// that compressed bytecode files will yield "false" for this method.
- /// @see isCompressedBytecode()
+ /// This method determines if the member is a regular compressed file.
/// @returns true iff the archive member is a compressed regular file.
/// @brief Determine if the member is a compressed regular file.
bool isCompressed() const { return flags&CompressedFlag; }
/// @brief Determine if this member is the ar(1) string table.
bool isStringTable() const { return flags&StringTableFlag; }
- /// @returns true iff the archive member is an uncompressed bytecode file.
- /// @brief Determine if this member is a bytecode file.
- bool isBytecode() const { return flags&BytecodeFlag; }
-
- /// @returns true iff the archive member is a compressed bytecode file.
- /// @brief Determine if the member is a compressed bytecode file.
- bool isCompressedBytecode() const { return flags&CompressedBytecodeFlag;}
+ /// @returns true iff the archive member is a bitcode file.
+ /// @brief Determine if this member is a bitcode file.
+ bool isBitcode() const { return flags&BitcodeFlag; }
/// @returns true iff the file name contains a path (directory) component.
/// @brief Determine if the member has a path
private:
/// Used internally by the Archive class to construct an ArchiveMember.
/// The contents of the ArchiveMember are filled out by the Archive class.
- ArchiveMember(Archive *PAR);
+ explicit ArchiveMember(Archive *PAR);
// So Archive can construct an ArchiveMember
friend class llvm::Archive;
inline reverse_iterator rend () { return members.rend(); }
inline const_reverse_iterator rend () const { return members.rend(); }
- inline unsigned size() const { return members.size(); }
+ inline size_t size() const { return members.size(); }
inline bool empty() const { return members.empty(); }
inline const ArchiveMember& front() const { return members.front(); }
inline ArchiveMember& front() { return members.front(); }
/// @brief Get the offset to the first "real" file member in the archive.
unsigned getFirstFileOffset() { return firstFileOffset; }
- /// This method will scan the archive for bytecode modules, interpret them
+ /// This method will scan the archive for bitcode modules, interpret them
/// and return a vector of the instantiated modules in \p Modules. If an
/// error occurs, this method will return true. If \p ErrMessage is not null
/// and an error occurs, \p *ErrMessage will be set to a string explaining
/// the error that occurred.
/// @returns true if an error occurred
- /// @brief Instantiate all the bytecode modules located in the archive
+ /// @brief Instantiate all the bitcode modules located in the archive
bool getAllModules(std::vector<Module*>& Modules, std::string* ErrMessage);
/// This accessor looks up the \p symbol in the archive's symbol table and
);
/// This method determines whether the archive is a properly formed llvm
- /// bytecode archive. It first makes sure the symbol table has been loaded
+ /// bitcode 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,
+ /// then it tries to load all the bitcode 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();
+ /// @returns true if the archive is a proper llvm bitcode archive
+ /// @brief Determine whether the archive is a proper llvm bitcode archive.
+ bool isBitcodeArchive();
/// @}
/// @name Mutators
/// This method is the only way to get the archive written to disk. It
/// creates or overwrites the file specified when \p this was created
/// or opened. The arguments provide options for writing the archive. If
- /// \p CreateSymbolTable is true, the archive is scanned for bytecode files
+ /// \p CreateSymbolTable is true, the archive is scanned for bitcode files
/// and a symbol table of the externally visible function and global
/// variable names is created. If \p TruncateNames is true, the names of the
/// archive members will have their path component stripped and the file
protected:
/// @brief Construct an Archive for \p filename and optionally map it
/// into memory.
- Archive(const sys::Path& filename);
+ explicit Archive(const sys::Path& filename);
+ /// @param data The symbol table data to be parsed
+ /// @param len The length of the symbol table data
/// @param error Set to address of a std::string to get error messages
/// @returns false on error
/// @brief Parse the symbol table at \p data.
std::string* error ///< Optional error message catcher
);
- /// @param error Set to address of a std::string to get error messages
+ /// @param ErrMessage Set to address of a std::string to get error messages
/// @returns false on error
/// @brief Check that the archive signature is correct
bool checkSignature(std::string* ErrMessage);
- /// @param error Set to address of a std::string to get error messages
+ /// @param ErrMessage Set to address of a std::string to get error messages
/// @returns false on error
/// @brief Load the entire archive.
bool loadArchive(std::string* ErrMessage);
- /// @param error Set to address of a std::string to get error messages
+ /// @param ErrMessage Set to address of a std::string to get error messages
/// @returns false on error
/// @brief Load just the symbol table.
bool loadSymbolTable(std::string* ErrMessage);
/// @brief Frees all the members and unmaps the archive file.
void cleanUpMemory();
- /// This type is used to keep track of bytecode modules loaded from the
+ /// This type is used to keep track of bitcode modules loaded from the
/// symbol table. It maps the file offset to a pair that consists of the
/// associated ArchiveMember and the ModuleProvider.
/// @brief Module mapping type
protected:
sys::Path archPath; ///< Path to the archive file we read/write
MembersList members; ///< The ilist of ArchiveMember
- sys::MappedFile* mapfile; ///< Raw Archive contents mapped into memory
+ MemoryBuffer *mapfile; ///< Raw Archive contents mapped into memory
const char* base; ///< Base of the memory mapped file data
SymTabType symTab; ///< The symbol table
std::string strtab; ///< The string table for long file names