[clang] [clang-tools-extra] [llvm] [clang] WIP: Improved Context Declaration tracking (PR #107942)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 10 08:04:48 PDT 2024


================
@@ -18770,12 +18832,6 @@ bool Sema::tryCaptureVariable(
   if (CapturingFunctionScopes == 0 && (!BuildAndDiagnose || VarDC == DC))
     return true;
 
-  // Exception: Function parameters are not tied to the function's DeclContext
-  // until we enter the function definition. Capturing them anyway would result
-  // in an out-of-bounds error while traversing DC and its parents.
-  if (isa<ParmVarDecl>(Var) && !VarDC->isFunctionOrMethod())
----------------
zyn0217 wrote:

I think the rationale behind it is that every ParmVarDecl now has a context decl pointing to e.g. its function? Do we still need to set the ParmVarDecl's context separately (by calling `setOwningFunction`) now?
Sorry I haven't gotten around to the changes on VarDecls yet.

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


More information about the cfe-commits mailing list