summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-17 04:02:59 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-17 04:02:59 +0000
commit7ae3c75d97e46c56b7b40290381e0e4ef0c9125f (patch)
tree6b41462243b62ef9083df656dcceea3c99baf84e /clang/lib
parenta80cae11f6cdbc92b0a5c47c454534ac564452d3 (diff)
downloadbcm5719-llvm-7ae3c75d97e46c56b7b40290381e0e4ef0c9125f.tar.gz
bcm5719-llvm-7ae3c75d97e46c56b7b40290381e0e4ef0c9125f.zip
Only add 'const' to the type of variables captured in a lambda when
we're capturing it by value in a non-mutable lambda. llvm-svn: 150791
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5202f96354d..c15102c4da2 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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;
}
OpenPOWER on IntegriCloud