[PATCH] D141690: [clang] fix consteval ctor code generation assert

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 13 07:40:04 PST 2023


ilya-biryukov added a subscriber: jyknight.
ilya-biryukov added a comment.

Sorry, didn't see your comment when submitting mine.

I think the offending code is clearly wrong here and adding the `isLayoutIdentical` seems like the right thing to do.

This looks like a small change and I'm happy to LGTM this myself.
However, I also have very little experience with codegen, you might want to find someone more experienced with it to have a more informed look. @jyknight maybe?



================
Comment at: clang/lib/CodeGen/CGCall.cpp:1338
+  llvm::StructType *STy = dyn_cast<llvm::StructType>(Val->getType());
+  if (STy && STy->isLayoutIdentical(cast<llvm::StructType>(Dest.getElementType()))) {
     for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
----------------
Is it guaranteed that `Dest.getElementType()` is never something other than `StructType`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141690/new/

https://reviews.llvm.org/D141690



More information about the cfe-commits mailing list