@@ -50,31 +50,30 @@ TEST(TypesTest, TargetExtType) {
5050 // only show the struct name, not the struct body
5151 Type *Int32Type = Type::getInt32Ty (Context);
5252 Type *FloatType = Type::getFloatTy (Context);
53- std::vector<Type *> OriginalElements = {Int32Type, FloatType};
54- StructType *Struct = llvm::StructType::create (Context, " MyStruct" );
55- Struct->setBody (OriginalElements);
53+ std::array<Type *, 2 > Elements = {Int32Type, FloatType};
5654
57- // the other struct is different only in that it's an anonymous struct,
58- // without a name
55+ StructType *Struct = llvm::StructType::create (Context, Elements, " MyStruct" ,
56+ /* isPacked=*/ false );
57+ SmallVector<char , 50 > TETV;
58+ llvm::raw_svector_ostream TETStream (TETV);
59+ Type *TargetExtensionType =
60+ TargetExtType::get (Context, " structTET" , {Struct}, {0 , 1 });
61+ TargetExtensionType->print (TETStream);
62+
63+ EXPECT_STREQ (TETStream.str ().str ().data (),
64+ " target(\" structTET\" , %MyStruct, 0, 1)" );
65+
66+ // ensure that literal structs in the target extension type print the struct
67+ // body
5968 StructType *OtherStruct =
6069 StructType::get (Context, Struct->elements (), /* isPacked=*/ false );
6170
62- Type *TargetExtensionType =
63- TargetExtType::get (Context, " structTET" , {Struct}, {0 , 1 });
6471 Type *OtherTargetExtensionType =
6572 TargetExtType::get (Context, " structTET" , {OtherStruct}, {0 , 1 });
66-
67- SmallVector<char , 50 > TETV;
6873 SmallVector<char , 50 > OtherTETV;
69-
70- llvm::raw_svector_ostream TETStream (TETV);
71- TargetExtensionType->print (TETStream);
72-
7374 llvm::raw_svector_ostream OtherTETStream (OtherTETV);
7475 OtherTargetExtensionType->print (OtherTETStream);
7576
76- EXPECT_STREQ (TETStream.str ().str ().data (),
77- " target(\" structTET\" , %MyStruct, 0, 1)" );
7877 EXPECT_STREQ (OtherTETStream.str ().str ().data (),
7978 " target(\" structTET\" , { i32, float }, 0, 1)" );
8079}
0 commit comments