diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-17 04:02:59 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-17 04:02:59 +0000 |
commit | bd64520ca4e4d4c531637d311f8ea384c912fce8 (patch) | |
tree | 22c54e052513fab28aa3342fbb4c1fd5078af80f /lib/Sema/SemaExpr.cpp | |
parent | b3f323d6c41cb614a249dbc4af7493762786521a (diff) |
Only add 'const' to the type of variables captured in a lambda when
we're capturing it by value in a non-mutable lambda.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 5202f96354..c15102c4da 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -9575,8 +9575,13 @@ static bool shouldAddConstForScope(CapturingScopeInfo *CSI, VarDecl *VD) { return false; if (isa<BlockScopeInfo>(CSI)) return true; - if (LambdaScopeInfo *LSI = dyn_cast<LambdaScopeInfo>(CSI)) - return !LSI->Mutable; + if (LambdaScopeInfo *LSI = dyn_cast<LambdaScopeInfo>(CSI)) { + if (LSI->isCaptured(VD)) + return LSI->getCapture(VD).isCopyCapture() && !LSI->Mutable; + + return LSI->ImpCaptureStyle == LambdaScopeInfo::ImpCap_LambdaByval && + !LSI->Mutable; + } return false; } |