diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-02-18 02:25:12 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-02-18 02:25:12 +0000 |
commit | 906c73ffbc78542ad333becb6e013dd9efc299b6 (patch) | |
tree | ba454de9c55cb9e52010de9a138225f7fa4debe3 /include/clang/CodeGen/CodeGenAction.h | |
parent | ef9a1d0e13662162aa8cdae8732c33b5d751d80c (diff) |
Move CompilerInstance::LLVMContext and LLVMContext ownership to CodeGenAction
This removes the final dependency edge from any lib outside of CodeGen
to core. As a result we can, and do, trim the dependency on core
from libclang, PrintFunctionNames, the unit tests and c-index-test.
While at it, review and trim other unneeded dependencies.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/CodeGen/CodeGenAction.h')
-rw-r--r-- | include/clang/CodeGen/CodeGenAction.h | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/include/clang/CodeGen/CodeGenAction.h b/include/clang/CodeGen/CodeGenAction.h index b55effc6be..052c6603f5 100644 --- a/include/clang/CodeGen/CodeGenAction.h +++ b/include/clang/CodeGen/CodeGenAction.h @@ -14,6 +14,7 @@ #include "llvm/ADT/OwningPtr.h" namespace llvm { + class LLVMContext; class Module; } @@ -24,9 +25,14 @@ class CodeGenAction : public ASTFrontendAction { private: unsigned Act; llvm::OwningPtr<llvm::Module> TheModule; + llvm::LLVMContext *VMContext; + bool OwnsVMContext; protected: - CodeGenAction(unsigned _Act); + /// Create a new code generation action. If the optional \arg _VMContext + /// parameter is supplied, the action uses it without taking ownership, + /// otherwise it creates a fresh LLVM context and takes ownership. + CodeGenAction(unsigned _Act, llvm::LLVMContext *_VMContext = 0); virtual bool hasIRSupport() const; @@ -44,37 +50,40 @@ public: /// been run. The result may be null on failure. llvm::Module *takeModule(); + /// Take the LLVM context used by this action. + llvm::LLVMContext *takeLLVMContext(); + BackendConsumer *BEConsumer; }; class EmitAssemblyAction : public CodeGenAction { public: - EmitAssemblyAction(); + EmitAssemblyAction(llvm::LLVMContext *_VMContext = 0); }; class EmitBCAction : public CodeGenAction { public: - EmitBCAction(); + EmitBCAction(llvm::LLVMContext *_VMContext = 0); }; class EmitLLVMAction : public CodeGenAction { public: - EmitLLVMAction(); + EmitLLVMAction(llvm::LLVMContext *_VMContext = 0); }; class EmitLLVMOnlyAction : public CodeGenAction { public: - EmitLLVMOnlyAction(); + EmitLLVMOnlyAction(llvm::LLVMContext *_VMContext = 0); }; class EmitCodeGenOnlyAction : public CodeGenAction { public: - EmitCodeGenOnlyAction(); + EmitCodeGenOnlyAction(llvm::LLVMContext *_VMContext = 0); }; class EmitObjAction : public CodeGenAction { public: - EmitObjAction(); + EmitObjAction(llvm::LLVMContext *_VMContext = 0); }; } |