Add a global context, for easing backwards compatibility.
authorOwen Anderson <resistor@mac.com>
Tue, 30 Jun 2009 23:39:59 +0000 (23:39 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 30 Jun 2009 23:39:59 +0000 (23:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74574 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/LLVMContext.h
lib/VMCore/LLVMContext.cpp

index 01c64a81e0490f602038e87cf240eda6eae24bb2..1d95502bcd6a5a3de85219e04fad91c8471a0604 100644 (file)
@@ -197,6 +197,9 @@ public:
   VectorType* getVectorTypeTruncatedElement(const VectorType* VTy);
 };
 
+/// FOR BACKWARDS COMPATIBILITY - Returns a global context.
+LLVMContext* getGlobalContext();
+
 }
 
 #endif
index e0fe6ab7929bc1d39249043a7d999f0b0e09530f..09c7fcc8cf1fe7d68c961becae698a8ed06604c7 100644 (file)
 #include "llvm/LLVMContext.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "LLVMContextImpl.h"
 
 using namespace llvm;
 
+static ManagedStatic<LLVMContext> GlobalContext;
+
+LLVMContext* getGlobalContext() {
+  return &*GlobalContext;
+}
+
 LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { }
 LLVMContext::~LLVMContext() { delete pImpl; }