sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.
================
Comment at: clang/lib/AST/ASTContext.cpp:2463
- unsigned PreferredAlign = static_cast<unsigned>(
- toBits(getASTRecordLayout(RT->getDecl()).PreferredAlignment));
- assert(PreferredAlign >= ABIAlign &&
- "PreferredAlign should be at least as large as ABIAlign.");
- return PreferredAlign;
+ if (!RT->getDecl()->isInvalidDecl()) {
+ unsigned PreferredAlign = static_cast<unsigned>(
----------------
hokein wrote:
> another proper fix might be change the `getPreferredTypeAlign` signature to
> support error handling (e.g. return a bool), but that would require a large
> invasive change for its callers, not sure it is worth.
>
> I think the current implementation is OK, as the result doesn't really matter
> for an invalid RecordDecl, and we do similar thing int `getTypeInfoImpl`
> (returning a fake `Align`/`Width` for invalid decl).
I think this is fine though it could be clearer/more explicit about how the
special case is handled.
```
if (RT->getDecl()->isInvalidDecl())
return ABIAlign;
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85834/new/
https://reviews.llvm.org/D85834
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits