1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[LLVM-C] Add Bindings to Access an Instruction's DebugLoc

Summary: Provide direct accessors to supplement LLVMSetInstDebugLocation.  In addition, properly accept and return the NULL location.  The old accessors provided no way to do this, so the current debug location cannot currently be cleared.

Reviewers: whitequark, deadalnix

Reviewed By: whitequark

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60481

llvm-svn: 358038
This commit is contained in:
Robert Widmann 2019-04-09 22:27:51 +00:00
parent 8d86101cf9
commit b1c5e0c327
2 changed files with 27 additions and 0 deletions

View File

@ -1192,6 +1192,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.
*

View File

@ -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) \