[clang] [clang] Fix code completion crash in lambda trailing requires-clause (PR #206373)

Harlen Batagelo via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 30 20:35:28 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())
----------------
hbatagelo wrote:

> perhaps we should just bail early if the `CurContext` is invalid?

Hi. I checked but `CurContext` isn't marked as invalid here. Code completion is triggered before the parser reaches `ActOnLambdaError` (which only flags the closure class anyway, not the `CXXMethodDecl`).

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


More information about the cfe-commits mailing list