Files
Harlen Batagelo a7ee75a807 [clang] Fix code completion crash in lambda trailing requires-clause (#206373)
Fixes #201632.

This patch fixes an assertion failure when code completion is triggered
inside an ill-formed lambda's trailing requires-clause, as in
```cpp
void f() {
  []() requires x /*invoke completion here*/
```
https://godbolt.org/z/a66s7Y5cx

When `tok::code_completion` is reached, parsing is cut off before the
end of the declarator. This leaves the lambda's call operator without a
type, thus triggering the `!isNull() && "Cannot retrieve a NULL type
pointer"` assertion when `AddOrdinaryNameResults` calls
`FunctionDecl::getReturnType()` later.

Fix by guarding the `getReturnType()` call with a null check.

Note: The crash stacktrace for the reproducer above differs slightly
from #201632. Here, parsing is cut off during the parsing of the
constraint expression. In #201632, parsing is cut off later during
actual template parsing in `Parser::ParseTemplateIdAfterTemplateName`.
Both leave the lambda without a `FunctionType`. Tests for both are
included.
2026-07-01 07:42:06 -04:00
..
…
…
…
…
…
…
…
…
…