Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions llvm/include/llvm-c/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,16 @@ void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP);
*/
unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram);

/**
* Replace the subprogram subroutine type.
* \param Subprogram The subprogram object.
* \param SubroutineType The new subroutine type.
*
* @see DISubprogram::replaceType()
*/
void LLVMDISubprogramReplaceType(LLVMMetadataRef Subprogram,
LLVMMetadataRef SubroutineType);

/**
* Get the debug location for the given instruction.
*
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,12 @@ unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram) {
return unwrapDI<DISubprogram>(Subprogram)->getLine();
}

void LLVMDISubprogramReplaceType(LLVMMetadataRef Subprogram,
LLVMMetadataRef SubroutineType) {
unwrapDI<DISubprogram>(Subprogram)
->replaceType(unwrapDI<DISubroutineType>(SubroutineType));
}

LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst) {
return wrap(unwrap<Instruction>(Inst)->getDebugLoc().getAsMDNode());
}
Expand Down
8 changes: 4 additions & 4 deletions llvm/tools/llvm-c-test/debuginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ int llvm_test_dibuilder(void) {
LLVMMetadataRef FooParamLocation =
LLVMDIBuilderCreateDebugLocation(LLVMGetGlobalContext(), 42, 0,
ReplaceableFunctionMetadata, NULL);
LLVMMetadataRef FunctionMetadata =
LLVMDIBuilderCreateFunction(DIB, File, "foo", 3, "foo", 3,
File, 42, FunctionTy, true, true,
42, 0, false);
LLVMMetadataRef FunctionMetadata = LLVMDIBuilderCreateFunction(
DIB, File, "foo", 3, "foo", 3, File, 42, NULL, true, true, 42, 0, false);
LLVMMetadataReplaceAllUsesWith(ReplaceableFunctionMetadata, FunctionMetadata);

LLVMDISubprogramReplaceType(FunctionMetadata, FunctionTy);

LLVMMetadataRef FooParamExpression =
LLVMDIBuilderCreateExpression(DIB, NULL, 0);
LLVMMetadataRef FooParamVar1 =
Expand Down
Loading