[LLVM-C] Add Accessors For Global Variable Metadata Properties
Summary: Metadata for a global variable is really a (GlobalVariable, Expression) tuple. Allow access to these, then allow retrieving the file, scope, and line for a DIVariable, whether global or local. This should be the last of the accessors required for uniform access to location and file information metadata.
Reviewers: jberdine, whitequark, deadalnix
Reviewed By: jberdine, whitequark
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D60725
llvm-svn: 358532
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 773d547..1244623 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1248,6 +1248,27 @@
nullptr, AlignInBits));
}
+LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE) {
+ return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getVariable());
+}
+
+LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(
+ LLVMMetadataRef GVE) {
+ return wrap(unwrapDI<DIGlobalVariableExpression>(GVE)->getExpression());
+}
+
+LLVMMetadataRef LLVMDIVariableGetFile(LLVMMetadataRef Var) {
+ return wrap(unwrapDI<DIVariable>(Var)->getFile());
+}
+
+LLVMMetadataRef LLVMDIVariableGetScope(LLVMMetadataRef Var) {
+ return wrap(unwrapDI<DIVariable>(Var)->getScope());
+}
+
+unsigned LLVMDIVariableGetLine(LLVMMetadataRef Var) {
+ return unwrapDI<DIVariable>(Var)->getLine();
+}
+
LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef Ctx, LLVMMetadataRef *Data,
size_t Count) {
return wrap(
@@ -1359,6 +1380,10 @@
unwrap<Function>(Func)->setSubprogram(unwrap<DISubprogram>(SP));
}
+unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram) {
+ return unwrapDI<DISubprogram>(Subprogram)->getLine();
+}
+
LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst) {
return wrap(unwrap<Instruction>(Inst)->getDebugLoc().getAsMDNode());
}