[clang] [clang][Parser] Fix an assertion during decltype error recovery with missing ; (PR #188123)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 31 08:05:25 PDT 2026


AaronBallman wrote:

> > I kind of wonder if it would make sense for us to have a recovery function that can be called consistently.
> 
> Thanks, that’s a fair point. I explored this further and believe that this inconsistency is a deliberate choice between different recovery strategies, each with its own trade-offs. Attempting to normalize these into a single strategy is a rabbit hole that causes various regressions.

Thank you for doing that exploratory work, it's really appreciated!

> Back to the current fix: the preprocessor cache remains correctly updated (the `Pos`) and the text buffer stays aligned with the written source code (I think this is by designed).
> 
> The issue is because this specific recovery path manually sets the current Token to `;` regardless of the actual source content. The assertion fails because it expects the token stream to match this synthetic parser state. Given that, removing the assertion seems reasonable to me.
> 
> I am less certain about modifying the preprocessor state to match the parser state, that feels like a much riskier change.

Okay, that seems reasonable to me.

https://github.com/llvm/llvm-project/pull/188123


More information about the cfe-commits mailing list