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
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5202f96..c15102c 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9575,8 +9575,13 @@
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;
}