r236002 - Silencing a -Wuninitialized warning in a different way. This replaces r235981, but is still NFC.
Aaron Ballman
aaron at aaronballman.com
Tue Apr 28 10:34:38 PDT 2015
Author: aaronballman
Date: Tue Apr 28 12:34:38 2015
New Revision: 236002
URL: http://llvm.org/viewvc/llvm-project?rev=236002&view=rev
Log:
Silencing a -Wuninitialized warning in a different way. This replaces r235981, but is still NFC.
Modified:
cfe/trunk/lib/Sema/SemaLambda.cpp
Modified: cfe/trunk/lib/Sema/SemaLambda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLambda.cpp?rev=236002&r1=236001&r2=236002&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLambda.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLambda.cpp Tue Apr 28 12:34:38 2015
@@ -1477,13 +1477,30 @@ ExprResult Sema::ActOnLambdaExpr(SourceL
return BuildLambdaExpr(StartLoc, Body->getLocEnd(), &LSI);
}
+static LambdaCaptureDefault
+mapImplicitCaptureStyle(CapturingScopeInfo::ImplicitCaptureStyle ICS) {
+ switch (ICS) {
+ case CapturingScopeInfo::ImpCap_None:
+ return LCD_None;
+ case CapturingScopeInfo::ImpCap_LambdaByval:
+ return LCD_ByCopy;
+ case CapturingScopeInfo::ImpCap_CapturedRegion:
+ case CapturingScopeInfo::ImpCap_LambdaByref:
+ return LCD_ByRef;
+ case CapturingScopeInfo::ImpCap_Block:
+ llvm_unreachable("block capture in lambda");
+ }
+ llvm_unreachable("Unknown implicit capture style");
+}
+
ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
LambdaScopeInfo *LSI) {
// Collect information from the lambda scope.
SmallVector<LambdaCapture, 4> Captures;
SmallVector<Expr *, 4> CaptureInits;
- LambdaCaptureDefault CaptureDefault = LCD_None;
- SourceLocation CaptureDefaultLoc;
+ SourceLocation CaptureDefaultLoc = LSI->CaptureDefaultLoc;
+ LambdaCaptureDefault CaptureDefault =
+ mapImplicitCaptureStyle(LSI->ImpCaptureStyle);
CXXRecordDecl *Class;
CXXMethodDecl *CallOperator;
SourceRange IntroducerRange;
@@ -1553,26 +1570,6 @@ ExprResult Sema::BuildLambdaExpr(SourceL
CaptureInits.push_back(Init);
}
- switch (LSI->ImpCaptureStyle) {
- case CapturingScopeInfo::ImpCap_None:
- CaptureDefault = LCD_None;
- break;
-
- case CapturingScopeInfo::ImpCap_LambdaByval:
- CaptureDefault = LCD_ByCopy;
- break;
-
- case CapturingScopeInfo::ImpCap_CapturedRegion:
- case CapturingScopeInfo::ImpCap_LambdaByref:
- CaptureDefault = LCD_ByRef;
- break;
-
- case CapturingScopeInfo::ImpCap_Block:
- llvm_unreachable("block capture in lambda");
- break;
- }
- CaptureDefaultLoc = LSI->CaptureDefaultLoc;
-
// C++11 [expr.prim.lambda]p6:
// The closure type for a lambda-expression with no lambda-capture
// has a public non-virtual non-explicit const conversion function
More information about the cfe-commits
mailing list