summaryrefslogtreecommitdiffstats
path: root/clang/unittests
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-09-13 23:28:25 +0000
committerVedant Kumar <vsk@apple.com>2018-09-13 23:28:25 +0000
commit35d303adbfa2f9331058de0d9ad007e740437fb2 (patch)
tree7ea63724ac16c3e12bf3ee718908dbd56909c3d4 /clang/unittests
parent975ff5a6d37734a247975e4c844ce17c764e521c (diff)
downloadbcm5719-llvm-35d303adbfa2f9331058de0d9ad007e740437fb2.tar.gz
bcm5719-llvm-35d303adbfa2f9331058de0d9ad007e740437fb2.zip
[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
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
index 67640486efb..cd0e4260a8b 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
@@ -75,11 +75,11 @@ TEST(RecursiveASTVisitor, VisitsUseOfImplicitLambdaCapture) {
TEST(RecursiveASTVisitor, VisitsImplicitLambdaCaptureInit) {
DeclRefExprVisitor Visitor;
Visitor.setShouldVisitImplicitCode(true);
- // We're expecting the "i" in the lambda to be visited twice:
- // - Once for the DeclRefExpr in the lambda capture initialization (whose
- // source code location is set to the first use of the variable).
- // - Once for the DeclRefExpr for the use of "i" inside the lambda.
- Visitor.ExpectMatch("i", 1, 24, /*Times=*/2);
+ // We're expecting "i" to be visited twice: once for the initialization expr
+ // for the captured variable "i" outside of the lambda body, and again for
+ // the use of "i" inside the lambda.
+ Visitor.ExpectMatch("i", 1, 20, /*Times=*/1);
+ Visitor.ExpectMatch("i", 1, 24, /*Times=*/1);
EXPECT_TRUE(Visitor.runOver(
"void f() { int i; [=]{ i; }; }",
DeclRefExprVisitor::Lang_CXX11));
OpenPOWER on IntegriCloud