llvm.org GIT mirror llvm / 67f575b
[LLVM-C] Add DIFile Field Accesssors Summary: Add accessors for the file, directory, source file name (curiously, an `Optional` value?), of a DIFile. This is intended to replace the LLVMValueRef-based accessors used in D52239 Reviewers: whitequark, jberdine, deadalnix Reviewed By: whitequark, jberdine Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60489 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358577 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 4 months ago
2 changed file(s) with 59 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
458458 */
459459 LLVMMetadataRef LLVMDILocationGetInlinedAt(LLVMMetadataRef Location);
460460
461 /**
462 * Get the metadata of the file associated with a given scope.
463 * \param Scope The scope object.
464 *
465 * @see DIScope::getFile()
466 */
467 LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope);
468
469 /**
470 * Get the directory of a given file.
471 * \param File The file object.
472 * \param Len The length of the returned string.
473 *
474 * @see DIFile::getDirectory()
475 */
476 const char *LLVMDIFileGetDirectory(LLVMMetadataRef File, unsigned *Len);
477
478 /**
479 * Get the name of a given file.
480 * \param File The file object.
481 * \param Len The length of the returned string.
482 *
483 * @see DIFile::getFilename()
484 */
485 const char *LLVMDIFileGetFilename(LLVMMetadataRef File, unsigned *Len);
486
487 /**
488 * Get the source of a given file.
489 * \param File The file object.
490 * \param Len The length of the returned string.
491 *
492 * @see DIFile::getSource()
493 */
494 const char *LLVMDIFileGetSource(LLVMMetadataRef File, unsigned *Len);
461495
462496 /**
463497 * Create a type array.
902902 return wrap(unwrapDI(Location)->getInlinedAt());
903903 }
904904
905 LLVMMetadataRef LLVMDIScopeGetFile(LLVMMetadataRef Scope) {
906 return wrap(unwrapDI(Scope)->getFile());
907 }
908
909 const char *LLVMDIFileGetDirectory(LLVMMetadataRef File, unsigned *Len) {
910 auto Dir = unwrapDI(File)->getDirectory();
911 *Len = Dir.size();
912 return Dir.data();
913 }
914
915 const char *LLVMDIFileGetFilename(LLVMMetadataRef File, unsigned *Len) {
916 auto Name = unwrapDI(File)->getFilename();
917 *Len = Name.size();
918 return Name.data();
919 }
920
921 const char *LLVMDIFileGetSource(LLVMMetadataRef File, unsigned *Len) {
922 if (auto Src = unwrapDI(File)->getSource()) {
923 *Len = Src->size();
924 return Src->data();
925 }
926 *Len = 0;
927 return "";
928 }
929
905930 LLVMMetadataRef LLVMDIBuilderCreateEnumerator(LLVMDIBuilderRef Builder,
906931 const char *Name, size_t NameLen,
907932 int64_t Value,