[clang] [llvm] clang: fix lifetime_capture_by indexing for member functions (PR #212264)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 29 07:26:36 PDT 2026


================
@@ -1020,12 +1020,13 @@ void FactsGenerator::handleLifetimeCaptureBy(const FunctionDecl *FD,
   if (isa<CXXConstructorDecl>(FD))
     return;
   const auto *Method = dyn_cast<CXXMethodDecl>(FD);
-  bool IsInstance =
-      Method && Method->isInstance() && !isa<CXXConstructorDecl>(FD);
-  auto getArgCaptureBy = [FD,
-                          IsInstance](unsigned I) -> LifetimeCaptureByAttr * {
+  bool HasImplicitThisParam =
+      Method && Method->isImplicitObjectMemberFunction() &&
+      !isa<CXXConstructorDecl>(FD);
+  auto getArgCaptureBy =
+      [FD, HasImplicitThisParam](unsigned I) -> LifetimeCaptureByAttr * {
     const ParmVarDecl *PVD = nullptr;
-    if (IsInstance) {
+    if (HasImplicitThisParam) {
----------------
usx95 wrote:

I think this is indeed a useful change but I would appreciate if we can focus on the root cause in this PR and move this to a separate PR.

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


More information about the cfe-commits mailing list