[PATCH] D60489: [LLVM-C] Add DIScope Field Accesssors
Robert Widmann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 15:32:03 PDT 2019
CodaFi created this revision.
CodaFi added reviewers: whitequark, jberdine, deadalnix.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Add accessors for the file, directory, source file name (curiously, an `Optional` value?), and file of a DIScope.
This is intended to replace the LLVMValueRef-based accessors used in D52239 <https://reviews.llvm.org/D52239>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60489
Files:
llvm/include/llvm-c/DebugInfo.h
llvm/lib/IR/DebugInfo.cpp
Index: llvm/lib/IR/DebugInfo.cpp
===================================================================
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -899,6 +899,31 @@
return wrap(unwrapDI<DILocation>(Location)->getScope());
}
+const char *LLVMDIScopeGetDirectory(LLVMMetadataRef Scope, unsigned *Len) {
+ auto Dir = unwrapDI<DIScope>(Scope)->getDirectory();
+ *Len = Dir.size();
+ return Dir.data();
+}
+
+const char *LLVMDIScopeGetFilename(LLVMMetadataRef Scope, unsigned *Len) {
+ auto Dir = unwrapDI<DIScope>(Scope)->getFilename();
+ *Len = Dir.size();
+ return Dir.data();
+}
+
+const char *LLVMDIScopeGetSource(LLVMMetadataRef Scope, unsigned *Len) {
+ if (auto Dir = unwrapDI<DIScope>(Scope)->getSource()) {
+ *Len = Dir->size();
+ return Dir->data();
+ }
+ *Len = 0;
+ return "";
+}
+
+LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope) {
+ return wrap(unwrapDI<DIScope>(Scope)->getFile());
+}
+
LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
const char *Name, size_t NameLen,
int64_t Value,
Index: llvm/include/llvm-c/DebugInfo.h
===================================================================
--- llvm/include/llvm-c/DebugInfo.h
+++ llvm/include/llvm-c/DebugInfo.h
@@ -451,6 +451,41 @@
*/
LLVMMetadataRef LLVMDILocationGetScope(LLVMMetadataRef Location);
+/**
+ * Get the directory of the file associated with a given scope.
+ * \param Scope The scope object.
+ * \param Len The length of the returned string.
+ *
+ * @see DIScope::getDirectory()
+ */
+const char *LLVMDIScopeGetDirectory(LLVMMetadataRef Scope, unsigned *Len);
+
+/**
+ * Get the directory of the file associated with a given scope.
+ * \param Scope The scope object.
+ * \param Len The length of the returned string.
+ *
+ * @see DIScope::getFilename()
+ */
+const char *LLVMDIScopeGetFilename(LLVMMetadataRef Scope, unsigned *Len);
+
+/**
+ * Get the directory of the file associated with a given scope.
+ * \param Scope The scope object.
+ * \param Len The length of the returned string.
+ *
+ * @see DIScope::getSource()
+ */
+const char *LLVMDIScopeGetSource(LLVMMetadataRef Scope, unsigned *Len);
+
+/**
+ * Get the metadata of the file associated with a given scope.
+ * \param Scope The scope object.
+ *
+ * @see DIScope::getFile()
+ */
+LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope);
+
/**
* Create a type array.
* \param Builder The DIBuilder.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60489.194412.patch
Type: text/x-patch
Size: 2563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190409/865e50a1/attachment.bin>
More information about the llvm-commits
mailing list