diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 9 |
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; } |