diff options
| author | Vedant Kumar <vsk@apple.com> | 2018-09-13 23:28:25 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2018-09-13 23:28:25 +0000 |
| commit | 35d303adbfa2f9331058de0d9ad007e740437fb2 (patch) | |
| tree | 7ea63724ac16c3e12bf3ee718908dbd56909c3d4 /clang/lib/Sema | |
| parent | 975ff5a6d37734a247975e4c844ce17c764e521c (diff) | |
| download | bcm5719-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/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaLambda.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index 33915676585..8000cb4fbfd 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -1392,13 +1392,14 @@ static void addBlockPointerConversion(Sema &S, Class->addDecl(Conversion); } -static ExprResult performLambdaVarCaptureInitialization(Sema &S, - const Capture &Capture, - FieldDecl *Field) { +static ExprResult performLambdaVarCaptureInitialization( + Sema &S, const Capture &Capture, FieldDecl *Field, + SourceLocation ImplicitCaptureLoc, bool IsImplicitCapture) { assert(Capture.isVariableCapture() && "not a variable capture"); auto *Var = Capture.getVariable(); - SourceLocation Loc = Capture.getLocation(); + SourceLocation Loc = + IsImplicitCapture ? ImplicitCaptureLoc : Capture.getLocation(); // C++11 [expr.prim.lambda]p21: // When the lambda-expression is evaluated, the entities that @@ -1607,8 +1608,8 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, Var, From.getEllipsisLoc())); Expr *Init = From.getInitExpr(); if (!Init) { - auto InitResult = - performLambdaVarCaptureInitialization(*this, From, *CurField); + auto InitResult = performLambdaVarCaptureInitialization( + *this, From, *CurField, CaptureDefaultLoc, IsImplicit); if (InitResult.isInvalid()) return ExprError(); Init = InitResult.get(); |

