[all-commits] [llvm/llvm-project] 4050d7: [clang] Fix assertion failures involving code comp...
Harlen Batagelo via All-commits
all-commits at lists.llvm.org
Sun Jun 28 17:44:44 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4050d7a96903eec615c57e1d3d6f3c824096244c
https://github.com/llvm/llvm-project/commit/4050d7a96903eec615c57e1d3d6f3c824096244c
Author: Harlen Batagelo <hbatagelo at gmail.com>
Date: 2026-06-29 (Mon, 29 Jun 2026)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/Parse/ParseCXXInlineMethods.cpp
A clang/test/CodeCompletion/GH200879.cpp
Log Message:
-----------
[clang] Fix assertion failures involving code completion with delayed default arguments and exception specifications (#203794)
Fixes #200879.
This patch fixes crashes when code completion is invoked immediately
after the declaration of a top-level class containing methods with
default arguments or exception specifications.
Default-argument case: https://godbolt.org/z/4G9nTfnGd
Exception-specification case: https://godbolt.org/z/8frEv8von
When code completion is triggered right after the class body, the
lookahead token is `tok::code_completion` when late parsing begins. The
token is saved to the cached token stream and `ConsumeAnyToken()` is
called to consume it, but `ConsumeAnyToken()` defaults to rejecting
completion tokens, which cuts off parsing. In the default-arguments path
(as reported in #200879), the assertion `Tok.is(tok::equal) && "Default
argument not starting with '='"` is triggered because `cutOffParsing()`
sets the current token to `eof`.
Fix by using `ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true)` when
consuming the pushed token.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list