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

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 27 15:36:53 PDT 2018


vsk added inline comments.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:10689
 
-      S.DiagRuntimeBehavior(DRE->getBeginLoc(), DRE,
+      S.DiagRuntimeBehavior(DRE->getBeginOrDeclLoc(), DRE,
                             S.PDiag(diag)
----------------
rsmith wrote:
> I'm a bit surprised you updated this call to `DeclRefExpr::getBeginLoc()` (and no others). I think this should be unreachable for a `DeclRefExpr` that refers to an implicit lambda capture, because such a lambda-capture cannot refer to itself from its own (implicit) initializer.
IIUC, that's exactly what this visitor (SelfReferenceChecker) diagnoses. The only test I found which exercises this code path is SemaCXX/uninitialized.cpp. The relevant portion is updated in this diff, but to summarize, there's a DeclRefExpr in the CXXConstructExpr initializer generated for `a1` which self-refers to `a1`.


https://reviews.llvm.org/D50927





More information about the cfe-commits mailing list