diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-01 21:22:36 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-01 21:22:36 +0000 |
commit | a148fdd8312c060c65bacf8fe61a6db5b2add6a5 (patch) | |
tree | 9e5f714db4af7dddfab061cb0016489f6d114c56 /include | |
parent | a0619e843be1fcf8fba618ed93207cf5db42cc26 (diff) | |
download | external_llvm-a148fdd8312c060c65bacf8fe61a6db5b2add6a5.zip external_llvm-a148fdd8312c060c65bacf8fe61a6db5b2add6a5.tar.gz external_llvm-a148fdd8312c060c65bacf8fe61a6db5b2add6a5.tar.bz2 |
Hold the LLVMContext by reference rather than by pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74640 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm-c/lto.h | 2 | ||||
-rw-r--r-- | include/llvm/Assembly/Parser.h | 4 | ||||
-rw-r--r-- | include/llvm/Bitcode/Archive.h | 10 | ||||
-rw-r--r-- | include/llvm/Bitcode/ReaderWriter.h | 4 | ||||
-rw-r--r-- | include/llvm/Debugger/Debugger.h | 2 | ||||
-rw-r--r-- | include/llvm/LLVMContext.h | 2 | ||||
-rw-r--r-- | include/llvm/LinkAllVMCore.h | 3 | ||||
-rw-r--r-- | include/llvm/Linker.h | 4 | ||||
-rw-r--r-- | include/llvm/Module.h | 6 |
9 files changed, 19 insertions, 18 deletions
diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 5d92fc5..d9a2e5c 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -58,6 +58,7 @@ typedef struct LTOModule* lto_module_t; /** opaque reference to a code generator */ typedef struct LTOCodeGenerator* lto_code_gen_t; +typedef struct LTOContext* lto_context_t; #ifdef __cplusplus extern "C" { @@ -76,7 +77,6 @@ lto_get_version(void); extern const char* lto_get_error_message(void); - /** * Checks if a file is a loadable object file. */ diff --git a/include/llvm/Assembly/Parser.h b/include/llvm/Assembly/Parser.h index 2a5bac7..616750a 100644 --- a/include/llvm/Assembly/Parser.h +++ b/include/llvm/Assembly/Parser.h @@ -32,7 +32,7 @@ class LLVMContext; Module *ParseAssemblyFile( const std::string &Filename, ///< The name of the file to parse ParseError &Error, ///< If not null, an object to return errors in. - LLVMContext* Context ///< Context in which to allocate globals info. + const LLVMContext& Context ///< Context in which to allocate globals info. ); /// The function is a secondary interface to the LLVM Assembly Parser. It parses @@ -45,7 +45,7 @@ Module *ParseAssemblyString( const char *AsmString, ///< The string containing assembly Module *M, ///< A module to add the assembly too. ParseError &Error, ///< If not null, an object to return errors in. - LLVMContext* Context + const LLVMContext& Context ); //===------------------------------------------------------------------------=== diff --git a/include/llvm/Bitcode/Archive.h b/include/llvm/Bitcode/Archive.h index c188df8..85b918e 100644 --- a/include/llvm/Bitcode/Archive.h +++ b/include/llvm/Bitcode/Archive.h @@ -280,7 +280,7 @@ class Archive { /// @brief Create an empty Archive. static Archive* CreateEmpty( const sys::Path& Filename,///< Name of the archive to (eventually) create. - LLVMContext* C ///< Context to use for global information + const LLVMContext& C ///< Context to use for global information ); /// Open an existing archive and load its contents in preparation for @@ -291,7 +291,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 + const LLVMContext& C, ///< The context to use for global information std::string* ErrorMessage ///< An optional error string ); @@ -313,7 +313,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 + const LLVMContext& C, ///< The context to use for global info std::string* ErrorMessage=0 ///< An optional error string ); @@ -453,7 +453,7 @@ class Archive { protected: /// @brief Construct an Archive for \p filename and optionally map it /// into memory. - explicit Archive(const sys::Path& filename, LLVMContext* C); + explicit Archive(const sys::Path& filename, const LLVMContext& C); /// @param data The symbol table data to be parsed /// @param len The length of the symbol table data @@ -534,7 +534,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. + const LLVMContext& Context; ///< This holds global data. /// @} /// @name Hidden /// @{ diff --git a/include/llvm/Bitcode/ReaderWriter.h b/include/llvm/Bitcode/ReaderWriter.h index a781187..3cde47b 100644 --- a/include/llvm/Bitcode/ReaderWriter.h +++ b/include/llvm/Bitcode/ReaderWriter.h @@ -32,13 +32,13 @@ namespace llvm { /// error, this returns null, *does not* take ownership of Buffer, and fills /// in *ErrMsg with an error description if ErrMsg is non-null. ModuleProvider *getBitcodeModuleProvider(MemoryBuffer *Buffer, - LLVMContext* Context, + const LLVMContext& Context, std::string *ErrMsg = 0); /// ParseBitcodeFile - Read the specified bitcode file, returning the module. /// If an error occurs, this returns null and fills in *ErrMsg if it is /// non-null. This method *never* takes ownership of Buffer. - Module *ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext* Context, + Module *ParseBitcodeFile(MemoryBuffer *Buffer, const LLVMContext& Context, std::string *ErrMsg = 0); /// WriteBitcodeToFile - Write the specified module to the specified output diff --git a/include/llvm/Debugger/Debugger.h b/include/llvm/Debugger/Debugger.h index ed04ed5..d003539 100644 --- a/include/llvm/Debugger/Debugger.h +++ b/include/llvm/Debugger/Debugger.h @@ -96,7 +96,7 @@ namespace llvm { /// the PATH for the specified program, loading it when found. If the /// specified program cannot be found, an exception is thrown to indicate /// the error. - void loadProgram(const std::string &Path, LLVMContext* Context); + void loadProgram(const std::string &Path, const LLVMContext& Context); /// unloadProgram - If a program is running, kill it, then unload all traces /// of the current program. If no program is loaded, this method silently diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 1d95502..f0c2200 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -198,7 +198,7 @@ public: }; /// FOR BACKWARDS COMPATIBILITY - Returns a global context. -LLVMContext* getGlobalContext(); +extern const LLVMContext& getGlobalContext(); } diff --git a/include/llvm/LinkAllVMCore.h b/include/llvm/LinkAllVMCore.h index 3c4b9c4..e5a5197 100644 --- a/include/llvm/LinkAllVMCore.h +++ b/include/llvm/LinkAllVMCore.h @@ -16,6 +16,7 @@ #ifndef LLVM_LINKALLVMCORE_H #define LLVM_LINKALLVMCORE_H +#include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" @@ -44,7 +45,7 @@ namespace { // to know that getenv() never returns -1, this will do the job. if (std::getenv("bar") != (char*) -1) return; - llvm::Module* M = new llvm::Module("", 0); + llvm::Module* M = new llvm::Module("", llvm::getGlobalContext()); (void)new llvm::UnreachableInst(); (void) llvm::createVerifierPass(); (void) new llvm::Mangler(*M,""); diff --git a/include/llvm/Linker.h b/include/llvm/Linker.h index 8389dc7..2ab0ed4 100644 --- a/include/llvm/Linker.h +++ b/include/llvm/Linker.h @@ -67,7 +67,7 @@ class Linker { Linker( const std::string& progname, ///< name of tool running linker const std::string& modulename, ///< name of linker's end-result module - LLVMContext* C, ///< Context for global info + const LLVMContext& C, ///< Context for global info unsigned Flags = 0 ///< ControlFlags (one or more |'d together) ); @@ -285,7 +285,7 @@ class Linker { /// @name Data /// @{ private: - LLVMContext* Context; ///< The context for global information + const LLVMContext& Context; ///< The context for global information Module* Composite; ///< The composite module linked together std::vector<sys::Path> LibPaths; ///< The library search paths unsigned Flags; ///< Flags to control optional behavior. diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 8370ffb..8efa8e0 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -110,7 +110,7 @@ public: /// @name Member Variables /// @{ private: - LLVMContext* Context; ///< The LLVMContext from which types and + const LLVMContext& Context; ///< The LLVMContext from which types and ///< constants are allocated. GlobalListType GlobalList; ///< The Global Variables in the module FunctionListType FunctionList; ///< The Functions in the module @@ -131,7 +131,7 @@ private: public: /// The Module constructor. Note that there is no default constructor. You /// must provide a name for the module upon construction. - explicit Module(const std::string &ModuleID, LLVMContext* C); + explicit Module(const std::string &ModuleID, const LLVMContext& C); /// The module destructor. This will dropAllReferences. ~Module(); @@ -162,7 +162,7 @@ public: /// Get the global data context. /// @returns LLVMContext - a container for LLVM's global information - LLVMContext* getContext() const { return Context; } + const LLVMContext& getContext() const { return Context; } /// Get any module-scope inline assembly blocks. /// @returns a string containing the module-scope inline assembly blocks. |