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.
11 lines
246 B
C++
11 lines
246 B
C++
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:2 %s
|
|
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:2 %s
|
|
|
|
struct A {
|
|
A(int = 0);
|
|
}/*invoke completion here*/;
|
|
|
|
struct B {
|
|
B() noexcept(false);
|
|
}/*invoke completion here*/;
|