#include "llvm/Support/IRBuilder.h"
#include "llvm/GlobalVariable.h"
#include "llvm/Function.h"
#include "llvm/LLVMContext.h"
using namespace llvm;
Value *IRBuilderBase::CreateGlobalString(const char *Str, const Twine &Name) {
Constant *StrConstant = ConstantArray::get(Context, Str, true);
Module &M = *BB->getParent()->getParent();
GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
true, GlobalValue::InternalLinkage,
StrConstant, "", 0, false);
GV->setName(Name);
return GV;
}
void IRBuilderBase::SetCurrentDebugLocation(MDNode *L) {
if (DbgMDKind == 0)
DbgMDKind = Context.getMDKindID("dbg");
CurDbgLocation = L;
}
void IRBuilderBase::SetInstDebugLocation(Instruction *I) const {
if (CurDbgLocation)
I->setMetadata(DbgMDKind, CurDbgLocation);
}
const Type *IRBuilderBase::getCurrentFunctionReturnType() const {
assert(BB && BB->getParent() && "No current function!");
return BB->getParent()->getReturnType();
}