[clang] [clang][sema] Fix crash on class template instantiation when a member variable partial specialization has an invalid primary template (PR #202006)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 23 06:25:10 PDT 2026
erichkeane wrote:
> This feels like Dejavu, since I reviewed a very similar issue not long ago.
>
> My suggestion is to avoid relying on isInvalidDecl for error recovery, as this is a very fragile.
>
> You can make sure error recovery for the primary template always produces a template with a valid type, by recovering an invalid / unknown type as if the user had written 'int'.
Getting error recovery to produce a valid template type is actually REALLY fragile as well, and would be a massive amount of re-write, we leave empty/invalid decls all over the place. It is also actually quite important that we mark decls as 'invalid' in quite a few places, as it saves us from having to hit recursion problems in quite a few places.
`!Expr`, or `ExprResult::IsUsable/IsInvalid` are REALLY common ways we use to detect failures and give up. IMO, its the right answer in Decls as well, and what we do fairly consistently.
The Deja-Vu you are getting is because of `RecoveryExpr`, which is a 75% implemented feature that we're still working through the kinks of.
https://github.com/llvm/llvm-project/pull/202006
More information about the cfe-commits
mailing list