rjmccall added inline comments.

================
Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:176
   CharUnits Alignment;
-  if (T->isIncompleteType()) {
+  if (T->getBaseElementTypeUnsafe()->isIncompleteType()) {
     Alignment = CharUnits::One(); // Shouldn't be used, but pessimistic is 
best.
----------------
efriedma wrote:
> rsmith wrote:
> > I don't know if it matters in practice, but this is still wrong. An 
> > incomplete type can have a known alignment, for a case like `struct 
> > alignas(32) S;`. Perhaps we should remove this test entirely and call 
> > `getTypeAlignIfKnown` instead of `getTypeAlign[InChars]` below.
> I can't think of any way to observe the alignment computed by 
> getNaturalTypeAlignment for an incomplete class. We usually only use the 
> alignment computed by getNaturalTypeAlignment() to set the alignment of 
> memory operations, and you can't do any memory operations with an incomplete 
> class.
> 
> But the result might be easier to read, in any case.
If there's a `getTypeAlignIfKnown()`, it would be better to use it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79052



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D79052: [... Eli Friedman via Phabricator via cfe-commits
    • [PATCH] D790... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D790... Eli Friedman via Phabricator via cfe-commits
    • [PATCH] D790... John McCall via Phabricator via cfe-commits

Reply via email to