//===-- LLVMContext.cpp - Implement LLVMContext -----------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements LLVMContext, as a wrapper around the opaque // struct LLVMContextImpl. // //===----------------------------------------------------------------------===// #include "llvm/LLVMContext.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instruction.h" #include "llvm/Metadata.h" #include "llvm/Support/ManagedStatic.h" #include "LLVMContextImpl.h" #include using namespace llvm; static ManagedStatic GlobalContext; LLVMContext& llvm::getGlobalContext() { return *GlobalContext; } LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { } LLVMContext::~LLVMContext() { delete pImpl; } GetElementPtrConstantExpr::GetElementPtrConstantExpr (Constant *C, const std::vector &IdxList, const Type *DestTy) : ConstantExpr(DestTy, Instruction::GetElementPtr, OperandTraits::op_end(this) - (IdxList.size()+1), IdxList.size()+1) { OperandList[0] = C; for (unsigned i = 0, E = IdxList.size(); i != E; ++i) OperandList[i+1] = IdxList[i]; }