[clang] [clang] Fix code completion crash in lambda trailing requires-clause (PR #206373)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 30 08:50:46 PDT 2026
================
@@ -2625,9 +2625,11 @@ AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC,
// "return expression ;" or "return ;", depending on the return type.
QualType ReturnType;
- if (const auto *Function = dyn_cast<FunctionDecl>(SemaRef.CurContext))
- ReturnType = Function->getReturnType();
- else if (const auto *Method = dyn_cast<ObjCMethodDecl>(SemaRef.CurContext))
+ if (const auto *Function = dyn_cast<FunctionDecl>(SemaRef.CurContext)) {
+ if (!Function->getType().isNull())
----------------
AaronBallman wrote:
Code completion is a bit weird because we have to handle every invalid construct imaginable, so it has to deal with invalid nodes a lot more than other parts of the compiler I think. We do a similar check below:
```
if (ReturnType.isNull() || ReturnType->isVoidType()) {
```
But at the same time, I'd expect `CurContext` to be an invalid declaration in this case; perhaps we should just bail early if the `CurContext` is invalid?
> Also, I don’t think we have a maintainer for code completion do we
We do not; Perhaps clangd maintainers might be the most familiar? CC @HighCommander4 @ArcsinX
https://github.com/llvm/llvm-project/pull/206373
More information about the cfe-commits
mailing list