================
@@ -2163,6 +2163,50 @@ static void BuildFlattenedTypeList(QualType BaseTy,
   }
 }
 
+bool SemaHLSL::IsTypedResourceElementCompatible(clang::QualType QT) {
+  if (QT.isNull())
+    return false;
+
+  // check if the outer type was an array type
+  if (QT->isArrayType())
+    return false;
+
+  llvm::SmallVector<QualType, 4> QTTypes;
+  BuildFlattenedTypeList(QT, QTTypes);
+
+  assert(QTTypes.size() > 0 &&
----------------
llvm-beanz wrote:

That's an incomplete type, not an empty struct. What about something like:

```hlsl
struct EmptyStruct {};
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(EmptyStruct),
 "");

struct EmptyDerived : EmptyStruct {};
_Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(EmptyDerived),
 "");

struct EmptyBase : EmptyStruct {
  int4 V;
};
_Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(EmptyBase), 
"");
```

We frequently find bugs in DXC with cases of empty structs, empty base classes, 
etc.

https://github.com/llvm/llvm-project/pull/114864
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to