llvm.org GIT mirror llvm / 22f6b59
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358532 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 4 months ago
2 changed file(s) with 75 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
10371037 size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File,
10381038 unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
10391039 LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits);
1040
1041 /**
1042 * Retrieves the \c DIVariable associated with this global variable expression.
1043 * \param GVE The global variable expression.
1044 *
1045 * @see llvm::DIGlobalVariableExpression::getVariable()
1046 */
1047 LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE);
1048
1049 /**
1050 * Retrieves the \c DIExpression associated with this global variable expression.
1051 * \param GVE The global variable expression.
1052 *
1053 * @see llvm::DIGlobalVariableExpression::getExpression()
1054 */
1055 LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(
1056 LLVMMetadataRef GVE);
1057
1058 /**
1059 * Get the metadata of the file associated with a given variable.
1060 * \param Var The variable object.
1061 *
1062 * @see DIVariable::getFile()
1063 */
1064 LLVMMetadataRef LLVMDIVariableGetFile(LLVMMetadataRef Var);
1065
1066 /**
1067 * Get the metadata of the scope associated with a given variable.
1068 * \param Var The variable object.
1069 *
1070 * @see DIVariable::getScope()
1071 */
1072 LLVMMetadataRef LLVMDIVariableGetScope(LLVMMetadataRef Var);
1073
1074 /**
1075 * Get the source line where this \c DIVariable is declared.
1076 * \param Var The DIVariable.
1077 *
1078 * @see DIVariable::getLine()
1079 */
1080 unsigned LLVMDIVariableGetLine(LLVMMetadataRef Var);
1081
10401082 /**
10411083 * Create a new temporary \c MDNode. Suitable for use in constructing cyclic
10421084 * \c MDNode structures. A temporary \c MDNode is not uniqued, may be RAUW'd,
12011243 void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP);
12021244
12031245 /**
1246 * Get the line associated with a given subprogram.
1247 * \param Subprogram The subprogram object.
1248 *
1249 * @see DISubprogram::getLine()
1250 */
1251 unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram);
1252
1253 /**
12041254 * Get the debug location for the given instruction.
12051255 *
12061256 * @see llvm::Instruction::getDebugLoc()
12471247 nullptr, AlignInBits));
12481248 }
12491249
1250 LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable(LLVMMetadataRef GVE) {
1251 return wrap(unwrapDI(GVE)->getVariable());
1252 }
1253
1254 LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression(
1255 LLVMMetadataRef GVE) {
1256 return wrap(unwrapDI(GVE)->getExpression());
1257 }
1258
1259 LLVMMetadataRef LLVMDIVariableGetFile(LLVMMetadataRef Var) {
1260 return wrap(unwrapDI(Var)->getFile());
1261 }
1262
1263 LLVMMetadataRef LLVMDIVariableGetScope(LLVMMetadataRef Var) {
1264 return wrap(unwrapDI(Var)->getScope());
1265 }
1266
1267 unsigned LLVMDIVariableGetLine(LLVMMetadataRef Var) {
1268 return unwrapDI(Var)->getLine();
1269 }
1270
12501271 LLVMMetadataRef LLVMTemporaryMDNode(LLVMContextRef Ctx, LLVMMetadataRef *Data,
12511272 size_t Count) {
12521273 return wrap(
13581379 unwrap(Func)->setSubprogram(unwrap(SP));
13591380 }
13601381
1382 unsigned LLVMDISubprogramGetLine(LLVMMetadataRef Subprogram) {
1383 return unwrapDI(Subprogram)->getLine();
1384 }
1385
13611386 LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst) {
13621387 return wrap(unwrap(Inst)->getDebugLoc().getAsMDNode());
13631388 }