================
@@ -378,8 +378,12 @@ PointerType::getABIAlignment(const ::mlir::DataLayout 
&dataLayout,
 llvm::TypeSize
 RecordType::getTypeSizeInBits(const mlir::DataLayout &dataLayout,
                               mlir::DataLayoutEntryListRef params) const {
-  if (isUnion())
-    return dataLayout.getTypeSize(getLargestMember(dataLayout));
+  if (isUnion()) {
+    mlir::Type largest = getLargestMember(dataLayout);
+    if (!largest)
+      return llvm::TypeSize::getFixed(0);
----------------
erichkeane wrote:

Agreed, it definitely SHOULD be with sizeof.  But that is a compile-time 
expression generated by the frontend, so size being 0 here looks odd...

I have a patch that does a bit of rewrite on union sizes (we're getting it 
not-so-subtly wrong) that I'm preparing, but i saw this while writing it and am 
not sure if this is right. 

https://github.com/llvm/llvm-project/pull/191516
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to