diff options
-rw-r--r-- | llvm/include/llvm-c/DebugInfo.h | 16 | ||||
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 11 |
2 files changed, 27 insertions, 0 deletions
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h index 99e977da15e..655b80d2796 100644 --- a/llvm/include/llvm-c/DebugInfo.h +++ b/llvm/include/llvm-c/DebugInfo.h @@ -1193,6 +1193,22 @@ LLVMMetadataRef LLVMGetSubprogram(LLVMValueRef Func); 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() diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index a9d91214a80..ef21b6a555f 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -1355,6 +1355,17 @@ void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP) { unwrap<Function>(Func)->setSubprogram(unwrap<DISubprogram>(SP)); } +LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst) { + return wrap(unwrap<Instruction>(Inst)->getDebugLoc().getAsMDNode()); +} + +void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc) { + if (Loc) + unwrap<Instruction>(Inst)->setDebugLoc(DebugLoc(unwrap<MDNode>(Loc))); + else + unwrap<Instruction>(Inst)->setDebugLoc(DebugLoc()); +} + LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata) { switch(unwrap(Metadata)->getMetadataID()) { #define HANDLE_METADATA_LEAF(CLASS) \ |