Skip to content

Commit

Permalink
Nuke getGlobalContext() from LLVM (but the C API)
Browse files Browse the repository at this point in the history
The only use for getGlobalContext() is in the C API.
Let's just move the static global here and nuke the C++ API.

Differential Revision: http://reviews.llvm.org/D19094

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266380
  • Loading branch information
joker-eph committed Apr 14, 2016
1 parent 03b42e4 commit dc4c095
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
4 changes: 0 additions & 4 deletions llvm/include/llvm/IR/LLVMContext.h
Expand Up @@ -235,10 +235,6 @@ class LLVMContext {
friend class Module;
};

/// getGlobalContext - Returns a global context. This is for LLVM clients that
/// only care about operating on a single thread.
extern LLVMContext &getGlobalContext();

// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef)

Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/IR/Core.cpp
Expand Up @@ -73,13 +73,13 @@ void LLVMDisposeMessage(char *Message) {

/*===-- Operations on contexts --------------------------------------------===*/

static ManagedStatic<LLVMContext> GlobalContext;

LLVMContextRef LLVMContextCreate() {
return wrap(new LLVMContext());
}

LLVMContextRef LLVMGetGlobalContext() {
return wrap(&getGlobalContext());
}
LLVMContextRef LLVMGetGlobalContext() { return wrap(&*GlobalContext); }

void LLVMContextSetDiagnosticHandler(LLVMContextRef C,
LLVMDiagnosticHandler Handler,
Expand Down Expand Up @@ -155,7 +155,7 @@ LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI) {
/*===-- Operations on modules ---------------------------------------------===*/

LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID) {
return wrap(new Module(ModuleID, getGlobalContext()));
return wrap(new Module(ModuleID, *GlobalContext));
}

LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
Expand Down
6 changes: 0 additions & 6 deletions llvm/lib/IR/LLVMContext.cpp
Expand Up @@ -25,12 +25,6 @@
#include <cctype>
using namespace llvm;

static ManagedStatic<LLVMContext> GlobalContext;

LLVMContext& llvm::getGlobalContext() {
return *GlobalContext;
}

LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) {
// Create the fixed metadata kinds. This is done in the same order as the
// MD_* enum values so that they correspond.
Expand Down

0 comments on commit dc4c095

Please sign in to comment.