@@ -40,10 +40,43 @@ TEST(TypesTest, TargetExtType) {
4040 Type *A = TargetExtType::get (Context, " typea" );
4141 Type *Aparam = TargetExtType::get (Context, " typea" , {}, {0 , 1 });
4242 Type *Aparam2 = TargetExtType::get (Context, " typea" , {}, {0 , 1 });
43+
4344 // Opaque types with same parameters are identical...
4445 EXPECT_EQ (Aparam, Aparam2);
4546 // ... but just having the same name is not enough.
4647 EXPECT_NE (A, Aparam);
48+
49+ // ensure struct types in targest extension types
50+ // only show the struct name, not the struct body
51+ Type *Int32Type = Type::getInt32Ty (Context);
52+ Type *FloatType = Type::getFloatTy (Context);
53+ std::vector<Type *> OriginalElements = {Int32Type, FloatType};
54+ StructType *Struct = llvm::StructType::create (Context, " MyStruct" );
55+ Struct->setBody (OriginalElements);
56+
57+ // the other struct is different only in that it's an anonymous struct,
58+ // without a name
59+ StructType *OtherStruct =
60+ StructType::get (Context, Struct->elements (), /* isPacked=*/ false );
61+
62+ Type *TargetExtensionType =
63+ TargetExtType::get (Context, " structTET" , {Struct}, {0 , 1 });
64+ Type *OtherTargetExtensionType =
65+ TargetExtType::get (Context, " structTET" , {OtherStruct}, {0 , 1 });
66+
67+ SmallVector<char , 50 > TETV;
68+ SmallVector<char , 50 > OtherTETV;
69+
70+ llvm::raw_svector_ostream TETStream (TETV);
71+ TargetExtensionType->print (TETStream);
72+
73+ llvm::raw_svector_ostream OtherTETStream (OtherTETV);
74+ OtherTargetExtensionType->print (OtherTETStream);
75+
76+ EXPECT_STREQ (TETStream.str ().str ().data (),
77+ " target(\" structTET\" , %MyStruct, 0, 1)" );
78+ EXPECT_STREQ (OtherTETStream.str ().str ().data (),
79+ " target(\" structTET\" , { i32, float }, 0, 1)" );
4780}
4881
4982TEST (TypedPointerType, PrintTest) {
0 commit comments