[clang] [llvm] [HLSL] Disallow named struct types as parameters in target extension types (PR #115971)

Justin Bogner via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 25 10:14:15 PST 2024


================
@@ -40,10 +40,43 @@ TEST(TypesTest, TargetExtType) {
   Type *A = TargetExtType::get(Context, "typea");
   Type *Aparam = TargetExtType::get(Context, "typea", {}, {0, 1});
   Type *Aparam2 = TargetExtType::get(Context, "typea", {}, {0, 1});
+
   // Opaque types with same parameters are identical...
   EXPECT_EQ(Aparam, Aparam2);
   // ... but just having the same name is not enough.
   EXPECT_NE(A, Aparam);
+
+  // ensure struct types in targest extension types
+  // only show the struct name, not the struct body
+  Type *Int32Type = Type::getInt32Ty(Context);
+  Type *FloatType = Type::getFloatTy(Context);
+  std::vector<Type *> OriginalElements = {Int32Type, FloatType};
----------------
bogner wrote:

No need for a vector here - this is a fixed size array. Also what's "original" about these elements?
```suggestion
  std::array<Type *, 2> Elements{Int32Type, FloatType};
```

https://github.com/llvm/llvm-project/pull/115971


More information about the cfe-commits mailing list