[cfe-commits] r96314 - in /cfe/trunk: include/clang/Frontend/CompilerInstance.h lib/Frontend/CompilerInstance.cpp tools/driver/cc1_main.cpp
Daniel Dunbar
daniel at zuster.org
Mon Feb 15 17:54:47 PST 2010
Author: ddunbar
Date: Mon Feb 15 19:54:47 2010
New Revision: 96314
URL: http://llvm.org/viewvc/llvm-project?rev=96314&view=rev
Log:
CompilerInstance: Move LLVMContext member out of constructor.
Modified:
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/tools/driver/cc1_main.cpp
Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=96314&r1=96313&r2=96314&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Mon Feb 15 19:54:47 2010
@@ -58,8 +58,7 @@
/// and a long form that takes explicit instances of any required objects.
class CompilerInstance {
/// The LLVM context used for this instance.
- llvm::LLVMContext *LLVMContext;
- bool OwnsLLVMContext;
+ llvm::OwningPtr<llvm::LLVMContext> LLVMContext;
/// The options used in this compiler instance.
llvm::OwningPtr<CompilerInvocation> Invocation;
@@ -97,11 +96,10 @@
/// The list of active output files.
std::list< std::pair<std::string, llvm::raw_ostream*> > OutputFiles;
+ void operator=(const CompilerInstance &); // DO NOT IMPLEMENT
+ CompilerInstance(const CompilerInstance&); // DO NOT IMPLEMENT
public:
- /// Create a new compiler instance with the given LLVM context, optionally
- /// taking ownership of it.
- CompilerInstance(llvm::LLVMContext *_LLVMContext = 0,
- bool _OwnsLLVMContext = true);
+ CompilerInstance();
~CompilerInstance();
/// @name High-Level Operations
@@ -150,12 +148,11 @@
return *LLVMContext;
}
+ llvm::LLVMContext *takeLLVMContext() { return LLVMContext.take(); }
+
/// setLLVMContext - Replace the current LLVM context and take ownership of
/// \arg Value.
- void setLLVMContext(llvm::LLVMContext *Value, bool TakeOwnership = true) {
- LLVMContext = Value;
- OwnsLLVMContext = TakeOwnership;
- }
+ void setLLVMContext(llvm::LLVMContext *Value);
/// }
/// @name Compiler Invocation and Options
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=96314&r1=96313&r2=96314&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Feb 15 19:54:47 2010
@@ -35,16 +35,15 @@
#include "llvm/System/Program.h"
using namespace clang;
-CompilerInstance::CompilerInstance(llvm::LLVMContext *_LLVMContext,
- bool _OwnsLLVMContext)
- : LLVMContext(_LLVMContext),
- OwnsLLVMContext(_OwnsLLVMContext),
- Invocation(new CompilerInvocation) {
+CompilerInstance::CompilerInstance()
+ : Invocation(new CompilerInvocation()) {
}
CompilerInstance::~CompilerInstance() {
- if (OwnsLLVMContext)
- delete LLVMContext;
+}
+
+void CompilerInstance::setLLVMContext(llvm::LLVMContext *Value) {
+ LLVMContext.reset(Value);
}
void CompilerInstance::setInvocation(CompilerInvocation *Value) {
Modified: cfe/trunk/tools/driver/cc1_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1_main.cpp?rev=96314&r1=96313&r2=96314&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1_main.cpp Mon Feb 15 19:54:47 2010
@@ -195,7 +195,9 @@
int cc1_main(const char **ArgBegin, const char **ArgEnd,
const char *Argv0, void *MainAddr) {
- CompilerInstance Clang(new llvm::LLVMContext, true);
+ CompilerInstance Clang;
+
+ Clang.setLLVMContext(new llvm::LLVMContext);
// Run clang -cc1 test.
if (ArgBegin != ArgEnd && llvm::StringRef(ArgBegin[0]) == "-cc1test") {
More information about the cfe-commits
mailing list