[PATCH] D50927: [Sema] Remove location from implicit capture init expr

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 27 16:57:08 PDT 2018


rsmith added inline comments.


================
Comment at: clang/lib/Sema/SemaLambda.cpp:1422-1424
   auto Entity = InitializedEntity::InitializeLambdaCapture(
       Var->getIdentifier(), Field->getType(), Loc);
   InitializationKind InitKind = InitializationKind::CreateDirect(Loc, Loc, Loc);
----------------
Should these locations also be updated to `InitLoc`? If we're modeling the initialization as happening at the capture-default, we should do that consistently.


================
Comment at: clang/lib/Sema/SemaLambda.cpp:1612
+        auto InitResult = performLambdaVarCaptureInitialization(
+            *this, From, *CurField, IntroducerRange.getBegin(), IsImplicit);
         if (InitResult.isInvalid())
----------------
Use `CaptureDefaultLoc` here instead of the start of the introducer range.


================
Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp:78-84
+  // We're expecting the "i" in the lambda to be visited just once (for the
+  // DeclRefExpr for the use of "i" inside the lambda).
+  //
+  // Previously, the DeclRefExpr in the implicit lambda capture initialization
+  // (whose source code location was set to the first use of the variable) was
+  // also matched. This location was changed to the starting site of the
+  // capture list to improve stepping behavior.
----------------
Please describe what the status quo is and why rather than explaining what it used to be and why it's different. The history stops being interesting very soon after you commit the new behavior.


https://reviews.llvm.org/D50927





More information about the cfe-commits mailing list