aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/DebugInfoTest.cpp
diff options
context:
space:
mode:
authordeadalnix <deadalnix@gmail.com>2024-08-13 12:12:29 +0200
committerGitHub <noreply@github.com>2024-08-13 12:12:29 +0200
commit3fa946a8442e1b8d4fdbdc9b9b7e8c12a0f77dcc (patch)
treee6c1be3db406a2392bb46484c083efd8f1cb6e5e /llvm/unittests/IR/DebugInfoTest.cpp
parenta9636b7f60f283926c66e96c036f5b5d9e57c026 (diff)
downloadllvm-3fa946a8442e1b8d4fdbdc9b9b7e8c12a0f77dcc.zip
llvm-3fa946a8442e1b8d4fdbdc9b9b7e8c12a0f77dcc.tar.gz
llvm-3fa946a8442e1b8d4fdbdc9b9b7e8c12a0f77dcc.tar.bz2
[DI] Have createClassType create a class type. (#102624)
I was wondering why my use of createClassType was generating structure reccords, and it turns out the code is wrong (or for some reason i don't understand the intended use of the API). clang itself does not use that part of the API, so this flew under the radar.
Diffstat (limited to 'llvm/unittests/IR/DebugInfoTest.cpp')
-rw-r--r--llvm/unittests/IR/DebugInfoTest.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp
index cac8acb..953df22 100644
--- a/llvm/unittests/IR/DebugInfoTest.cpp
+++ b/llvm/unittests/IR/DebugInfoTest.cpp
@@ -1244,4 +1244,37 @@ TEST(DIBuilder, HashingDISubprogram) {
EXPECT_EQ(HashDefinition, HashDefinitionAfter);
}
+TEST(DIBuilder, CompositeTypes) {
+ LLVMContext Ctx;
+ std::unique_ptr<Module> M = std::make_unique<Module>("MyModule", Ctx);
+ DIBuilder DIB(*M);
+
+ DIFile *F = DIB.createFile("main.c", "/");
+ DICompileUnit *CU =
+ DIB.createCompileUnit(dwarf::DW_LANG_C, F, "Test", false, "", 0);
+
+ DICompositeType *Class =
+ DIB.createClassType(CU, "MyClass", F, 0, 8, 8, 0, {}, nullptr, {}, 0,
+ nullptr, nullptr, "ClassUniqueIdentifier");
+ EXPECT_EQ(Class->getTag(), dwarf::DW_TAG_class_type);
+
+ DICompositeType *Struct = DIB.createStructType(
+ CU, "MyStruct", F, 0, 8, 8, {}, {}, {}, 0, {}, "StructUniqueIdentifier");
+ EXPECT_EQ(Struct->getTag(), dwarf::DW_TAG_structure_type);
+
+ DICompositeType *Union = DIB.createUnionType(CU, "MyUnion", F, 0, 8, 8, {},
+ {}, 0, "UnionUniqueIdentifier");
+ EXPECT_EQ(Union->getTag(), dwarf::DW_TAG_union_type);
+
+ DICompositeType *Array = DIB.createArrayType(8, 8, nullptr, {});
+ EXPECT_EQ(Array->getTag(), dwarf::DW_TAG_array_type);
+
+ DICompositeType *Vector = DIB.createVectorType(8, 8, nullptr, {});
+ EXPECT_EQ(Vector->getTag(), dwarf::DW_TAG_array_type);
+
+ DICompositeType *Enum = DIB.createEnumerationType(
+ CU, "MyEnum", F, 0, 8, 8, {}, nullptr, 0, "EnumUniqueIdentifier");
+ EXPECT_EQ(Enum->getTag(), dwarf::DW_TAG_enumeration_type);
+}
+
} // end namespace