[LLVM-C] Add DIBuilder Bindings For Variable Creation
Summary: Wrap LLVMDIBuilderCreateAutoVariable, LLVMDIBuilderCreateParameterVariable, LLVMDIBuilderCreateExpression, and move and correct LLVMDIBuilderInsertDeclareBefore and LLVMDIBuilderInsertDeclareAtEnd from the Go bindings to the C bindings.
Reviewers: harlanhaskins, whitequark, deadalnix
Reviewed By: harlanhaskins, whitequark
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D45928
llvm-svn: 330555
diff --git a/llvm/tools/llvm-c-test/debuginfo.c b/llvm/tools/llvm-c-test/debuginfo.c
index 2d594d0..b1cc851 100644
--- a/llvm/tools/llvm-c-test/debuginfo.c
+++ b/llvm/tools/llvm-c-test/debuginfo.c
@@ -48,6 +48,7 @@
LLVMTypeRef FooParamTys[] = { LLVMInt64Type(), LLVMInt64Type() };
LLVMTypeRef FooFuncTy = LLVMFunctionType(LLVMInt64Type(), FooParamTys, 2, 0);
LLVMValueRef FooFunction = LLVMAddFunction(M, "foo", FooFuncTy);
+ LLVMBasicBlockRef FooEntryBlock = LLVMAppendBasicBlock(FooFunction, "entry");
LLVMMetadataRef ParamTypes[] = {Int64Ty, Int64Ty};
LLVMMetadataRef FunctionTy =
@@ -56,6 +57,23 @@
LLVMDIBuilderCreateFunction(DIB, File, "foo", 3, "foo", 3,
File, 42, FunctionTy, true, true,
42, 0, false);
+ LLVMMetadataRef FooParamLocation =
+ LLVMDIBuilderCreateDebugLocation(LLVMGetGlobalContext(), 42, 0,
+ FunctionMetadata, NULL);
+ LLVMMetadataRef FooParamExpression =
+ LLVMDIBuilderCreateExpression(DIB, NULL, 0);
+ LLVMMetadataRef FooParamVar1 =
+ LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "a", 1, 1, File,
+ 42, Int64Ty, true, 0);
+ LLVMDIBuilderInsertDeclareAtEnd(DIB, LLVMConstInt(LLVMInt64Type(), 0, false),
+ FooParamVar1, FooParamExpression,
+ FooParamLocation, FooEntryBlock);
+ LLVMMetadataRef FooParamVar2 =
+ LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "b", 1, 2, File,
+ 42, Int64Ty, true, 0);
+ LLVMDIBuilderInsertDeclareAtEnd(DIB, LLVMConstInt(LLVMInt64Type(), 0, false),
+ FooParamVar2, FooParamExpression,
+ FooParamLocation, FooEntryBlock);
LLVMSetSubprogram(FooFunction, FunctionMetadata);
LLVMMetadataRef FooLexicalBlock =