[clang] [Clang] Fix assertion failure in getASTRecordLayout for invalid declarations (PR #208153)
Aditi Medhane via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 11 01:48:46 PDT 2026
AditiRM wrote:
Reworked the fix based on the review feedback and moved away from creating a dummy layout for invalid declarations.
While debugging the failure and tracing the stack, the call path leading to the assertion was identified:
`CheckConstructorCall() → CheckArgAlignment() → getTypeAlignInChars() → getASTRecordLayout(X<int>) → ComputeEmptySubobjectSizes() → getASTRecordLayout(X<int>::Y) → assertion`
Based on this, the new approach handles the issue at the callers by checking `isInvalidDecl()` before requesting a record layout. Invalid bases/fields are skipped during layout computation, and the relevant alignment/layout checks return early.
`getASTRecordLayout()` itself is left unchanged, including the existing assertions. This keeps the error recovery closer to where the invalid declaration is encountered and avoids introducing dummy layout information.
CC: @AaronBallman @erichkeane @vgvassilev @tonykuttai @hubert-reinterpretcast @w2yehia
https://github.com/llvm/llvm-project/pull/208153
More information about the cfe-commits
mailing list