Index: llvm/trunk/include/llvm-c/DebugInfo.h =================================================================== --- llvm/trunk/include/llvm-c/DebugInfo.h +++ llvm/trunk/include/llvm-c/DebugInfo.h @@ -1193,6 +1193,22 @@ void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP); /** + * Get the debug location for the given instruction. + * + * @see llvm::Instruction::getDebugLoc() + */ +LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst); + +/** + * Set the debug location for the given instruction. + * + * To clear the location metadata of the given instruction, pass NULL to \p Loc. + * + * @see llvm::Instruction::setDebugLoc() + */ +void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc); + +/** * Obtain the enumerated type of a Metadata instance. * * @see llvm::Metadata::getMetadataID() Index: llvm/trunk/lib/IR/DebugInfo.cpp =================================================================== --- llvm/trunk/lib/IR/DebugInfo.cpp +++ llvm/trunk/lib/IR/DebugInfo.cpp @@ -1355,6 +1355,17 @@ unwrap(Func)->setSubprogram(unwrap(SP)); } +LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst) { + return wrap(unwrap(Inst)->getDebugLoc().getAsMDNode()); +} + +void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc) { + if (Loc) + unwrap(Inst)->setDebugLoc(DebugLoc(unwrap(Loc))); + else + unwrap(Inst)->setDebugLoc(DebugLoc()); +} + LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata) { switch(unwrap(Metadata)->getMetadataID()) { #define HANDLE_METADATA_LEAF(CLASS) \