/// IRBuilderBase - Common base class shared among various IRBuilders.
class IRBuilderBase {
- MDNode *CurDbgLocation;
+ NewDebugLoc CurDbgLocation;
protected:
BasicBlock *BB;
BasicBlock::iterator InsertPt;
public:
IRBuilderBase(LLVMContext &context)
- : CurDbgLocation(0), Context(context) {
+ : Context(context) {
ClearInsertionPoint();
}
BasicBlock *GetInsertBlock() const { return BB; }
BasicBlock::iterator GetInsertPoint() const { return InsertPt; }
+ LLVMContext &getContext() const { return Context; }
/// SetInsertPoint - This specifies that created instructions should be
/// appended to the end of the specified block.
/// SetCurrentDebugLocation - Set location information used by debugging
/// information.
- void SetCurrentDebugLocation(MDNode *L) {
+ void SetCurrentDebugLocation(const NewDebugLoc &L) {
CurDbgLocation = L;
}
/// getCurrentDebugLocation - Get location information used by debugging
/// information.
- MDNode *getCurrentDebugLocation() const { return CurDbgLocation; }
+ const NewDebugLoc &getCurrentDebugLocation() const { return CurDbgLocation; }
/// SetInstDebugLocation - If this builder has a current debug location, set
/// it on the specified instruction.
void SetInstDebugLocation(Instruction *I) const {
- if (CurDbgLocation)
- I->setDbgMetadata(CurDbgLocation);
+ if (!CurDbgLocation.isUnknown())
+ I->setDebugLoc(CurDbgLocation);
}
//===--------------------------------------------------------------------===//
template<typename InstTy>
InstTy *Insert(InstTy *I, const Twine &Name = "") const {
this->InsertHelper(I, Name, BB, InsertPt);
- if (getCurrentDebugLocation() != 0)
+ if (!getCurrentDebugLocation().isUnknown())
this->SetInstDebugLocation(I);
return I;
}
}
void LLVMClearInsertionPosition(LLVMBuilderRef Builder) {
- unwrap(Builder)->ClearInsertionPoint ();
+ unwrap(Builder)->ClearInsertionPoint();
}
void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr) {
/*--.. Metadata builders ...................................................--*/
void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L) {
- unwrap(Builder)->SetCurrentDebugLocation(L? unwrap<MDNode>(L) : NULL);
+ MDNode *Loc = L ? unwrap<MDNode>(L) : NULL;
+ unwrap(Builder)->SetCurrentDebugLocation(NewDebugLoc::getFromDILocation(Loc));
}
LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder) {
- return wrap(unwrap(Builder)->getCurrentDebugLocation());
+ return wrap(unwrap(Builder)->getCurrentDebugLocation()
+ .getAsMDNode(unwrap(Builder)->getContext()));
}
void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst) {