[PATCH] D154630: [LLVM-C] Use unwrapDI in LLVMDITypeGetName
Scott Linder via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 7 09:51:41 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb98abab2c83: [LLVM-C] Use unwrapDI in LLVMDITypeGetName (authored by tamird, committed by scott.linder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154630/new/
https://reviews.llvm.org/D154630
Files:
llvm/lib/IR/DebugInfo.cpp
llvm/test/Bindings/llvm-c/di-type-get-name.ll
llvm/tools/llvm-c-test/debuginfo.c
llvm/tools/llvm-c-test/llvm-c-test.h
llvm/tools/llvm-c-test/main.c
Index: llvm/tools/llvm-c-test/main.c
===================================================================
--- llvm/tools/llvm-c-test/main.c
+++ llvm/tools/llvm-c-test/main.c
@@ -49,6 +49,8 @@
" Read lines of name, rpn from stdin - print generated module\n\n");
fprintf(stderr, " * --get-di-tag\n");
fprintf(stderr, " Run test for getting MDNode dwarf tag\n");
+ fprintf(stderr, " * --di-type-get-name\n");
+ fprintf(stderr, " Run test for getting MDNode type name\n");
fprintf(stderr, " * --replace-md-operand\n");
fprintf(stderr, " Run test for replacing MDNode operands\n");
fprintf(stderr, " * --is-a-value-as-metadata\n");
@@ -96,6 +98,8 @@
return llvm_set_metadata();
} else if (argc == 2 && !strcmp(argv[1], "--get-di-tag")) {
return llvm_get_di_tag();
+ } else if (argc == 2 && !strcmp(argv[1], "--di-type-get-name")) {
+ return llvm_di_type_get_name();
} else if (argc == 2 && !strcmp(argv[1], "--replace-md-operand")) {
return llvm_replace_md_operand();
} else if (argc == 2 && !strcmp(argv[1], "--is-a-value-as-metadata")) {
Index: llvm/tools/llvm-c-test/llvm-c-test.h
===================================================================
--- llvm/tools/llvm-c-test/llvm-c-test.h
+++ llvm/tools/llvm-c-test/llvm-c-test.h
@@ -38,6 +38,7 @@
// debuginfo.c
int llvm_test_dibuilder(void);
int llvm_get_di_tag(void);
+int llvm_di_type_get_name(void);
// metadata.c
int llvm_add_named_metadata_operand(void);
Index: llvm/tools/llvm-c-test/debuginfo.c
===================================================================
--- llvm/tools/llvm-c-test/debuginfo.c
+++ llvm/tools/llvm-c-test/debuginfo.c
@@ -231,3 +231,28 @@
return 0;
}
+
+int llvm_di_type_get_name(void) {
+ LLVMModuleRef M = LLVMModuleCreateWithName("Mod");
+
+ LLVMDIBuilderRef Builder = LLVMCreateDIBuilder(M);
+ const char Filename[] = "metadata.c";
+ const char Directory[] = ".";
+ LLVMMetadataRef File = LLVMDIBuilderCreateFile(
+ Builder, Filename, strlen(Filename), Directory, strlen(Directory));
+ const char Name[] = "TestClass";
+ LLVMMetadataRef Struct = LLVMDIBuilderCreateStructType(
+ Builder, File, Name, strlen(Name), File, 42, 64, 0,
+ LLVMDIFlagObjcClassComplete, NULL, NULL, 0, 0, NULL, NULL, 0);
+
+ size_t Len;
+ const char *TypeName = LLVMDITypeGetName(Struct, &Len);
+ assert(Len == strlen(Name));
+ assert(strncmp(TypeName, Name, Len) == 0);
+ (void)TypeName;
+
+ LLVMDisposeDIBuilder(Builder);
+ LLVMDisposeModule(M);
+
+ return 0;
+}
Index: llvm/test/Bindings/llvm-c/di-type-get-name.ll
===================================================================
--- /dev/null
+++ llvm/test/Bindings/llvm-c/di-type-get-name.ll
@@ -0,0 +1,2 @@
+; RUN: llvm-c-test --di-type-get-name < /dev/null
+; This used to trigger an assertion
Index: llvm/lib/IR/DebugInfo.cpp
===================================================================
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -1487,7 +1487,7 @@
}
const char *LLVMDITypeGetName(LLVMMetadataRef DType, size_t *Length) {
- StringRef Str = unwrap<DIType>(DType)->getName();
+ StringRef Str = unwrapDI<DIType>(DType)->getName();
*Length = Str.size();
return Str.data();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154630.538179.patch
Type: text/x-patch
Size: 3242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230707/53e9f613/attachment.bin>
More information about the llvm-commits
mailing list