X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FBitcode%2FArchive.h;h=e19e4c09ce3295800a21b398feeee61b04feadac;hb=f9be95f867745b6754b2402b9b72f9eaeabd637f;hp=39ad5eb63a6c70d58df4dfbf3be0d0cb7e84a181;hpb=181b6c9cb5def44658d15848e34c5c45d973f065;p=oota-llvm.git diff --git a/include/llvm/Bitcode/Archive.h b/include/llvm/Bitcode/Archive.h index 39ad5eb63a6..e19e4c09ce3 100644 --- a/include/llvm/Bitcode/Archive.h +++ b/include/llvm/Bitcode/Archive.h @@ -2,8 +2,8 @@ // // 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. // //===----------------------------------------------------------------------===// // @@ -17,20 +17,21 @@ #ifndef LLVM_BITCODE_ARCHIVE_H #define LLVM_BITCODE_ARCHIVE_H -#include "llvm/ADT/ilist" +#include "llvm/ADT/ilist.h" +#include "llvm/ADT/ilist_node.h" #include "llvm/System/Path.h" -#include "llvm/System/MappedFile.h" #include #include -#include namespace llvm { + class MemoryBuffer; // Forward declare classes class ModuleProvider; // From VMCore class Module; // From VMCore class Archive; // Declared below class ArchiveMemberHeader; // Internal implementation class +class LLVMContext; // Global data /// This class is the main class manipulated by users of the Archive class. It /// holds information about one member of the Archive. It is also the element @@ -39,7 +40,7 @@ class ArchiveMemberHeader; // Internal implementation class /// construct ArchiveMember instances. You should obtain them from the methods /// of the Archive class instead. /// @brief This class represents a single archive member. -class ArchiveMember { +class ArchiveMember : public ilist_node { /// @name Types /// @{ public: @@ -164,23 +165,10 @@ class ArchiveMember { /// @brief Replace contents of archive member with a new file. bool replaceWith(const sys::Path &aFile, std::string* ErrMsg); - /// @} - /// @name ilist methods - do not use - /// @{ - public: - const ArchiveMember *getNext() const { return next; } - const ArchiveMember *getPrev() const { return prev; } - ArchiveMember *getNext() { return next; } - ArchiveMember *getPrev() { return prev; } - void setPrev(ArchiveMember* p) { prev = p; } - void setNext(ArchiveMember* n) { next = n; } - /// @} /// @name Data /// @{ private: - ArchiveMember* next; ///< Pointer to next archive member - ArchiveMember* prev; ///< Pointer to previous archive member Archive* parent; ///< Pointer to parent archive sys::PathWithStatus path; ///< Path of file containing the member sys::FileStatus info; ///< Status info (size,mode,date) @@ -198,7 +186,7 @@ class ArchiveMember { 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; @@ -216,7 +204,7 @@ class ArchiveMember { /// applications and the linkers. Consequently, the implementation of the class /// is optimized for reading. class Archive { - + /// @name Types /// @{ public: @@ -254,7 +242,7 @@ class 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(); } @@ -290,7 +278,8 @@ class Archive { /// @returns An Archive* that represents the new archive file. /// @brief Create an empty Archive. static Archive* CreateEmpty( - const sys::Path& Filename ///< Name of the archive to (eventually) create. + const sys::Path& Filename,///< Name of the archive to (eventually) create. + LLVMContext& C ///< Context to use for global information ); /// Open an existing archive and load its contents in preparation for @@ -301,6 +290,7 @@ class Archive { /// @brief Open and load an archive file static Archive* OpenAndLoad( const sys::Path& filePath, ///< The file path to open and load + LLVMContext& C, ///< The context to use for global information std::string* ErrorMessage ///< An optional error string ); @@ -322,6 +312,7 @@ class Archive { /// @brief Open an existing archive and load its symbols. static Archive* OpenAndLoadSymbols( const sys::Path& Filename, ///< Name of the archive file to open + LLVMContext& C, ///< The context to use for global info std::string* ErrorMessage=0 ///< An optional error string ); @@ -461,7 +452,7 @@ class Archive { 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, LLVMContext& C); /// @param data The symbol table data to be parsed /// @param len The length of the symbol table data @@ -497,7 +488,7 @@ class Archive { void writeSymbolTable(std::ofstream& ARFile); /// Writes one ArchiveMember to an ofstream. If an error occurs, returns - /// false, otherwise true. If an error occurs and error is non-null then + /// false, otherwise true. If an error occurs and error is non-null then /// it will be set to an error message. /// @returns false Writing member succeeded /// @returns true Writing member failed, \p error set to error message @@ -534,7 +525,7 @@ class Archive { 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 @@ -542,6 +533,7 @@ class Archive { unsigned firstFileOffset; ///< Offset to first normal file. ModuleMap modules; ///< The modules loaded via symbol lookup. ArchiveMember* foreignST; ///< This holds the foreign symbol table. + LLVMContext& Context; ///< This holds global data. /// @} /// @name Hidden /// @{