[Sema] Remove location from implicit capture init expr
authorVedant Kumar <vsk@apple.com>
Thu, 13 Sep 2018 23:28:25 +0000 (23:28 +0000)
committerVedant Kumar <vsk@apple.com>
Thu, 13 Sep 2018 23:28:25 +0000 (23:28 +0000)
commit35d303adbfa2f9331058de0d9ad007e740437fb2
tree7ea63724ac16c3e12bf3ee718908dbd56909c3d4
parent975ff5a6d37734a247975e4c844ce17c764e521c
[Sema] Remove location from implicit capture init expr

A lambda's closure is initialized when the lambda is declared. For
implicit captures, the initialization code emitted from EmitLambdaExpr
references source locations *within the lambda body* in the function
containing the lambda. This results in a poor debugging experience: we
step to the line containing the lambda, then into lambda, out again,
over and over, until every capture's field is initialized.

To improve stepping behavior, assign the starting location of the lambda
to expressions which initialize an implicit capture within it.

rdar://39807527

Differential Revision: https://reviews.llvm.org/D50927

llvm-svn: 342194
clang/lib/Sema/SemaLambda.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
clang/test/CodeGenCXX/debug-info-lambda.cpp [new file with mode: 0644]
clang/test/SemaCXX/uninitialized.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp