@@ -222,10 +222,11 @@ UnsignedOrNone clang::getStackIndexOfNearestEnclosingCaptureCapableLambda(
222222 // Check if the capture-ready lambda can truly capture 'this' by checking
223223 // whether all enclosing lambdas of the capture-ready lambda can capture
224224 // 'this'.
225- const bool CanCaptureThis = !S.CheckCXXThisCapture (
226- CaptureReadyLambdaLSI->PotentialThisCaptureLocation ,
227- /* Explicit*/ false , /* BuildAndDiagnose*/ false ,
228- &IndexOfCaptureReadyLambda);
225+ const bool CanCaptureThis =
226+ !S.CheckCXXThisCapture (
227+ CaptureReadyLambdaLSI->PotentialThisCaptureLocation ,
228+ /* Explicit*/ false , /* BuildAndDiagnose*/ false ,
229+ &IndexOfCaptureReadyLambda);
229230 if (!CanCaptureThis)
230231 return NoLambdaIsCaptureCapable;
231232 }
@@ -240,7 +241,7 @@ getGenericLambdaTemplateParameterList(LambdaScopeInfo *LSI, Sema &SemaRef) {
240241 /* Template kw loc*/ SourceLocation (),
241242 /* L angle loc*/ LSI->ExplicitTemplateParamsRange .getBegin (),
242243 LSI->TemplateParams ,
243- /* R angle loc*/ LSI->ExplicitTemplateParamsRange .getEnd (),
244+ /* R angle loc*/ LSI->ExplicitTemplateParamsRange .getEnd (),
244245 LSI->RequiresClause .get ());
245246 }
246247 return LSI->GLTemplateParameterList ;
@@ -319,8 +320,8 @@ Sema::getCurrentMangleNumberContext(const DeclContext *DC) {
319320 }
320321
321322 if (ParmVarDecl *Param = dyn_cast<ParmVarDecl>(ManglingContextDecl)) {
322- if (const DeclContext *LexicalDC =
323- Param->getDeclContext ()->getLexicalParent ())
323+ if (const DeclContext *LexicalDC
324+ = Param->getDeclContext ()->getLexicalParent ())
324325 if (LexicalDC->isRecord ())
325326 return DefaultArgument;
326327 } else if (VarDecl *Var = dyn_cast<VarDecl>(ManglingContextDecl)) {
@@ -577,7 +578,8 @@ void Sema::ActOnLambdaExplicitTemplateParameterList(
577578 assert (LSI->TemplateParams .empty () &&
578579 " Explicit template parameters should come "
579580 " before invented (auto) ones" );
580- assert (!TParams.empty () && " No template parameters to act on" );
581+ assert (!TParams.empty () &&
582+ " No template parameters to act on" );
581583 LSI->TemplateParams .append (TParams.begin (), TParams.end ());
582584 LSI->NumExplicitTemplateParams = TParams.size ();
583585 LSI->ExplicitTemplateParamsRange = {LAngleLoc, RAngleLoc};
@@ -598,7 +600,8 @@ static EnumDecl *findEnumForBlockReturn(Expr *E) {
598600
599601 // - it is an enumerator whose enum type is T or
600602 if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
601- if (EnumConstantDecl *D = dyn_cast<EnumConstantDecl>(DRE->getDecl ())) {
603+ if (EnumConstantDecl *D
604+ = dyn_cast<EnumConstantDecl>(DRE->getDecl ())) {
602605 return cast<EnumDecl>(D->getDeclContext ());
603606 }
604607 return nullptr ;
@@ -662,13 +665,12 @@ static EnumDecl *findEnumForBlockReturn(ReturnStmt *ret) {
662665// / Attempt to find a common type T for which all of the returned
663666// / expressions in a block are enumerator-like expressions of that
664667// / type.
665- static EnumDecl *findCommonEnumForBlockReturns (ArrayRef<ReturnStmt *> returns) {
666- ArrayRef<ReturnStmt *>::iterator i = returns.begin (), e = returns.end ();
668+ static EnumDecl *findCommonEnumForBlockReturns (ArrayRef<ReturnStmt*> returns) {
669+ ArrayRef<ReturnStmt*>::iterator i = returns.begin (), e = returns.end ();
667670
668671 // Try to find one for the first return.
669672 EnumDecl *ED = findEnumForBlockReturn (*i);
670- if (!ED)
671- return nullptr ;
673+ if (!ED) return nullptr ;
672674
673675 // Check that the rest of the returns have the same enum.
674676 for (++i; i != e; ++i) {
@@ -677,18 +679,17 @@ static EnumDecl *findCommonEnumForBlockReturns(ArrayRef<ReturnStmt *> returns) {
677679 }
678680
679681 // Never infer an anonymous enum type.
680- if (!ED->hasNameForLinkage ())
681- return nullptr ;
682+ if (!ED->hasNameForLinkage ()) return nullptr ;
682683
683684 return ED;
684685}
685686
686687// / Adjust the given return statements so that they formally return
687688// / the given type. It should require, at most, an IntegralCast.
688- static void adjustBlockReturnsToEnum (Sema &S, ArrayRef<ReturnStmt *> returns,
689+ static void adjustBlockReturnsToEnum (Sema &S, ArrayRef<ReturnStmt*> returns,
689690 QualType returnType) {
690- for (ArrayRef<ReturnStmt *>::iterator i = returns. begin (), e = returns. end ();
691- i != e; ++i) {
691+ for (ArrayRef<ReturnStmt*>::iterator
692+ i = returns. begin (), e = returns. end (); i != e; ++i) {
692693 ReturnStmt *ret = *i;
693694 Expr *retValue = ret->getRetValue ();
694695 if (S.Context .hasSameType (retValue->getType (), returnType))
@@ -785,7 +786,7 @@ void Sema::deduceClosureReturnType(CapturingScopeInfo &CSI) {
785786 QualType ReturnType =
786787 (RetE ? RetE->getType () : Context.VoidTy ).getUnqualifiedType ();
787788 if (Context.getCanonicalFunctionResultType (ReturnType) ==
788- Context.getCanonicalFunctionResultType (CSI.ReturnType )) {
789+ Context.getCanonicalFunctionResultType (CSI.ReturnType )) {
789790 // Use the return type with the strictest possible nullability annotation.
790791 auto RetTyNullability = ReturnType->getNullability ();
791792 auto BlockNullability = CSI.ReturnType ->getNullability ();
@@ -837,7 +838,7 @@ QualType Sema::buildLambdaInitCaptureInitialization(
837838
838839 // Deduce the type of the init capture.
839840 QualType DeducedType = deduceVarTypeFromInitializer (
840- /* VarDecl*/ nullptr , DeclarationName (Id), DeductType, TSI,
841+ /* VarDecl*/ nullptr , DeclarationName (Id), DeductType, TSI,
841842 SourceRange (Loc, Loc), IsDirectInit, Init);
842843 if (DeducedType.isNull ())
843844 return QualType ();
@@ -1188,7 +1189,7 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
11881189 CheckCXXThisCapture (C->Loc , /* Explicit=*/ true , /* BuildAndDiagnose*/ true ,
11891190 /* FunctionScopeIndexToStopAtPtr*/ nullptr ,
11901191 C->Kind == LCK_StarThis);
1191- if (!LSI->Captures .empty ()) { //
1192+ if (!LSI->Captures .empty ()) {
11921193 SourceManager &SourceMgr = Context.getSourceManager ();
11931194 const LangOptions &LangOpts = Context.getLangOpts ();
11941195 SourceRange TrimmedRange =
@@ -1198,17 +1199,17 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
11981199 .getAsRange ();
11991200 LSI->ExplicitCaptureRanges [LSI->Captures .size () - 1 ] = TrimmedRange;
12001201 }
1201- continue ; // // skip further processing for `this` and `*this` captures.
1202+ continue ; // skip further processing for `this` and `*this` captures.
12021203 }
12031204
1204- if (!C->Id ) { //
1205- Diag (C->Loc , diag::err_expected_identifier_for_lambda_capture); //
1206- continue ; //
1205+ if (!C->Id ) {
1206+ Diag (C->Loc , diag::err_expected_identifier_for_lambda_capture);
1207+ continue ;
12071208 }
12081209
12091210 if (C->Init .isInvalid ()) {
1210- Diag (C->Loc , diag::err_invalid_lambda_capture_initializer_type); //
1211- continue ; //
1211+ Diag (C->Loc , diag::err_invalid_lambda_capture_initializer_type);
1212+ continue ;
12121213 }
12131214
12141215 ValueDecl *Var = nullptr ;
@@ -1230,16 +1231,14 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
12301231 continue ;
12311232 }
12321233
1233- if (!C->Init .get ()) {
1234+ if (!C->Init .get ())
12341235 continue ;
1235- }
12361236
12371237 ASTContext &Ctx = this ->Context ;
12381238 QualType DeducedType = C->Init .get ()->getType ();
12391239
1240- if (DeducedType.isNull ()) {
1240+ if (DeducedType.isNull ())
12411241 continue ;
1242- }
12431242
12441243 if (DeducedType->isVoidType ()) {
12451244 if (!DeducedType->isDependentType ()) {
@@ -1258,9 +1257,8 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
12581257 VarDecl::Create (Ctx, nullptr , C->Loc , C->Loc , DummyID, DummyType,
12591258 nullptr , SC_None);
12601259
1261- if (!TempVarDecl) {
1260+ if (!TempVarDecl)
12621261 continue ;
1263- }
12641262
12651263 DeducedType = deduceVarTypeFromInitializer (
12661264 TempVarDecl, TempVarDecl->getDeclName (), TempVarDecl->getType (),
@@ -1273,9 +1271,8 @@ void Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro,
12731271 }
12741272 }
12751273
1276- if (!DeducedType.isNull ()) {
1274+ if (!DeducedType.isNull ())
12771275 C->InitCaptureType = ParsedType::make (DeducedType);
1278- }
12791276 }
12801277
12811278 unsigned InitStyle;
@@ -1671,7 +1668,7 @@ void Sema::ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,
16711668 // Finalize the lambda.
16721669 CXXRecordDecl *Class = LSI->Lambda ;
16731670 Class->setInvalidDecl ();
1674- SmallVector<Decl *, 4 > Fields (Class->fields ());
1671+ SmallVector<Decl*, 4 > Fields (Class->fields ());
16751672 ActOnFields (nullptr , Class->getLocation (), Class, Fields, SourceLocation (),
16761673 SourceLocation (), ParsedAttributesView ());
16771674 CheckCompletedCXXClass (nullptr , Class);
@@ -1776,16 +1773,16 @@ static void addFunctionPointerConversion(Sema &S, SourceRange IntroducerRange,
17761773 // Create the type of the conversion function.
17771774 FunctionProtoType::ExtProtoInfo ConvExtInfo (
17781775 S.Context .getDefaultCallingConvention (
1779- /* IsVariadic=*/ false , /* IsCXXMethod=*/ true ));
1776+ /* IsVariadic=*/ false , /* IsCXXMethod=*/ true ));
17801777 // The conversion function is always const and noexcept.
17811778 ConvExtInfo.TypeQuals = Qualifiers ();
17821779 ConvExtInfo.TypeQuals .addConst ();
17831780 ConvExtInfo.ExceptionSpec .Type = EST_BasicNoexcept;
17841781 QualType ConvTy = S.Context .getFunctionType (PtrToFunctionTy, {}, ConvExtInfo);
17851782
17861783 SourceLocation Loc = IntroducerRange.getBegin ();
1787- DeclarationName ConversionName =
1788- S.Context .DeclarationNames .getCXXConversionFunctionName (
1784+ DeclarationName ConversionName
1785+ = S.Context .DeclarationNames .getCXXConversionFunctionName (
17891786 S.Context .getCanonicalType (PtrToFunctionTy));
17901787 // Construct a TypeSourceInfo for the conversion function, and wire
17911788 // all the parameters appropriately for the FunctionProtoTypeLoc
@@ -1871,10 +1868,12 @@ static void addFunctionPointerConversion(Sema &S, SourceRange IntroducerRange,
18711868 // Create a template version of the conversion operator, using the template
18721869 // parameter list of the function call operator.
18731870 FunctionTemplateDecl *TemplateCallOperator =
1874- CallOperator->getDescribedFunctionTemplate ();
1875- FunctionTemplateDecl *ConversionTemplate = FunctionTemplateDecl::Create (
1876- S.Context , Class, Loc, ConversionName,
1877- TemplateCallOperator->getTemplateParameters (), Conversion);
1871+ CallOperator->getDescribedFunctionTemplate ();
1872+ FunctionTemplateDecl *ConversionTemplate =
1873+ FunctionTemplateDecl::Create (S.Context , Class,
1874+ Loc, ConversionName,
1875+ TemplateCallOperator->getTemplateParameters (),
1876+ Conversion);
18781877 ConversionTemplate->setAccess (AS_public);
18791878 ConversionTemplate->setImplicit (true );
18801879 Conversion->setDescribedFunctionTemplate (ConversionTemplate);
@@ -1947,9 +1946,10 @@ static void addFunctionPointerConversions(Sema &S, SourceRange IntroducerRange,
19471946}
19481947
19491948// / Add a lambda's conversion to block pointer.
1950- static void addBlockPointerConversion (Sema &S, SourceRange IntroducerRange,
1951- CXXRecordDecl *Class,
1952- CXXMethodDecl *CallOperator) {
1949+ static void addBlockPointerConversion (Sema &S,
1950+ SourceRange IntroducerRange,
1951+ CXXRecordDecl *Class,
1952+ CXXMethodDecl *CallOperator) {
19531953 const FunctionProtoType *CallOpProto =
19541954 CallOperator->getType ()->castAs <FunctionProtoType>();
19551955 QualType FunctionTy = S.getLambdaConversionFunctionResultType (
@@ -1964,8 +1964,8 @@ static void addBlockPointerConversion(Sema &S, SourceRange IntroducerRange,
19641964 QualType ConvTy = S.Context .getFunctionType (BlockPtrTy, {}, ConversionEPI);
19651965
19661966 SourceLocation Loc = IntroducerRange.getBegin ();
1967- DeclarationName Name =
1968- S.Context .DeclarationNames .getCXXConversionFunctionName (
1967+ DeclarationName Name
1968+ = S.Context .DeclarationNames .getCXXConversionFunctionName (
19691969 S.Context .getCanonicalType (BlockPtrTy));
19701970 DeclarationNameLoc NameLoc = DeclarationNameLoc::makeNamedTypeLoc (
19711971 S.Context .getTrivialTypeSourceInfo (BlockPtrTy, Loc));
@@ -2198,8 +2198,8 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
21982198 CallOperator->setLexicalDeclContext (Class);
21992199 Decl *TemplateOrNonTemplateCallOperatorDecl =
22002200 CallOperator->getDescribedFunctionTemplate ()
2201- ? CallOperator->getDescribedFunctionTemplate ()
2202- : cast<Decl>(CallOperator);
2201+ ? CallOperator->getDescribedFunctionTemplate ()
2202+ : cast<Decl>(CallOperator);
22032203
22042204 // FIXME: Is this really the best choice? Keeping the lexical decl context
22052205 // set as CurContext seems more faithful to the source.
@@ -2331,7 +2331,7 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
23312331 addBlockPointerConversion (*this , IntroducerRange, Class, CallOperator);
23322332
23332333 // Finalize the lambda class.
2334- SmallVector<Decl *, 4 > Fields (Class->fields ());
2334+ SmallVector<Decl*, 4 > Fields (Class->fields ());
23352335 ActOnFields (nullptr , Class->getLocation (), Class, Fields, SourceLocation (),
23362336 SourceLocation (), ParsedAttributesView ());
23372337 CheckCompletedCXXClass (nullptr , Class);
@@ -2403,9 +2403,10 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation,
24032403 Expr *Src) {
24042404 // Make sure that the lambda call operator is marked used.
24052405 CXXRecordDecl *Lambda = Conv->getParent ();
2406- CXXMethodDecl *CallOperator = cast<CXXMethodDecl>(
2407- Lambda->lookup (Context.DeclarationNames .getCXXOperatorName (OO_Call))
2408- .front ());
2406+ CXXMethodDecl *CallOperator
2407+ = cast<CXXMethodDecl>(
2408+ Lambda->lookup (
2409+ Context.DeclarationNames .getCXXOperatorName (OO_Call)).front ());
24092410 CallOperator->setReferenced ();
24102411 CallOperator->markUsed (Context);
24112412
@@ -2443,10 +2444,13 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation,
24432444 // Add capture. The capture uses a fake variable, which doesn't correspond
24442445 // to any actual memory location. However, the initializer copy-initializes
24452446 // the lambda object.
2446- TypeSourceInfo *CapVarTSI = Context.getTrivialTypeSourceInfo (Src->getType ());
2447+ TypeSourceInfo *CapVarTSI =
2448+ Context.getTrivialTypeSourceInfo (Src->getType ());
24472449 VarDecl *CapVar =
2448- VarDecl::Create (Context, Block, ConvLocation, ConvLocation, nullptr ,
2449- Src->getType (), CapVarTSI, SC_None);
2450+ VarDecl::Create (Context, Block, ConvLocation,
2451+ ConvLocation, nullptr ,
2452+ Src->getType (), CapVarTSI,
2453+ SC_None);
24502454 BlockDecl::Capture Capture (/* variable=*/ CapVar, /* byRef=*/ false ,
24512455 /* nested=*/ false , /* copy=*/ Init.get ());
24522456 Block->setCaptures (Context, Capture, /* CapturesCXXThis=*/ false );
0 commit comments