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

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 28 11:39:37 PDT 2018


vsk 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);
----------------
rsmith wrote:
> 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.
I've revised the patch to use one location consistently here. The tradeoff is that a few diagnostics now point to CaptureDefaultLoc instead of within the lambda body, but I'm happy to defer to more experienced Sema hands.


================
Comment at: clang/lib/Sema/SemaLambda.cpp:1612
+        auto InitResult = performLambdaVarCaptureInitialization(
+            *this, From, *CurField, IntroducerRange.getBegin(), IsImplicit);
         if (InitResult.isInvalid())
----------------
rsmith wrote:
> Use `CaptureDefaultLoc` here instead of the start of the introducer range.
Sure. This does seem better for diagnostic reporting purposes. I'll just note that it may make the line table look awkward in the (admittedly unlikely) event that 'IntroducerRange.getBegin()' and 'CaptureDefaultLoc' are on different lines.


https://reviews.llvm.org/D50927





More information about the cfe-commits mailing list