Index: include/clang/AST/DeclCXX.h =================================================================== --- include/clang/AST/DeclCXX.h +++ include/clang/AST/DeclCXX.h @@ -226,7 +226,7 @@ return EllipsisLoc; } - /// \brief Returns the access specifier for this base specifier. + /// \brief Returns the access specifier for this base specifier. /// /// This is the actual base specifier as used for semantic analysis, so /// the result can never be AS_none. To retrieve the access specifier as @@ -489,7 +489,7 @@ CXXRecordDecl *Definition; /// \brief The first friend declaration in this class, or null if there - /// aren't any. + /// aren't any. /// /// This is actually currently stored in reverse order. LazyDeclPtr FirstFriend; @@ -526,11 +526,11 @@ struct LambdaDefinitionData : public DefinitionData { typedef LambdaCapture Capture; - LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info, - bool Dependent, bool IsGeneric, - LambdaCaptureDefault CaptureDefault) - : DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric), - CaptureDefault(CaptureDefault), NumCaptures(0), NumExplicitCaptures(0), + LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info, + bool Dependent, bool IsGeneric, + LambdaCaptureDefault CaptureDefault) + : DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric), + CaptureDefault(CaptureDefault), NumCaptures(0), NumExplicitCaptures(0), ManglingNumber(0), ContextDecl(nullptr), Captures(nullptr), MethodTyInfo(Info) { IsLambda = true; @@ -543,14 +543,14 @@ /// \brief Whether this lambda is known to be dependent, even if its /// context isn't dependent. - /// + /// /// A lambda with a non-dependent context can be dependent if it occurs /// within the default argument of a function template, because the /// lambda will have been created with the enclosing context as its /// declaration context, rather than function. This is an unfortunate - /// artifact of having to parse the default arguments before. + /// artifact of having to parse the default arguments before. unsigned Dependent : 1; - + /// \brief Whether this lambda is a generic lambda. unsigned IsGenericLambda : 1; @@ -563,23 +563,23 @@ /// \brief The number of explicit captures in this lambda. unsigned NumExplicitCaptures : 13; - /// \brief The number used to indicate this lambda expression for name + /// \brief The number used to indicate this lambda expression for name /// mangling in the Itanium C++ ABI. unsigned ManglingNumber; - + /// \brief The declaration that provides context for this lambda, if the /// actual DeclContext does not suffice. This is used for lambdas that /// occur within default arguments of function parameters within the class /// or within a data member initializer. Decl *ContextDecl; - - /// \brief The list of captures, both explicit and implicit, for this + + /// \brief The list of captures, both explicit and implicit, for this /// lambda. Capture *Captures; /// \brief The type of the call method. TypeSourceInfo *MethodTyInfo; - + }; struct DefinitionData *dataPtr() const { @@ -1028,22 +1028,22 @@ return DD && DD->IsLambda; } - /// \brief Determine whether this class describes a generic + /// \brief Determine whether this class describes a generic /// lambda function object (i.e. function call operator is - /// a template). - bool isGenericLambda() const; + /// a template). + bool isGenericLambda() const; /// \brief Retrieve the lambda call operator of the closure type /// if this is a closure type. - CXXMethodDecl *getLambdaCallOperator() const; + CXXMethodDecl *getLambdaCallOperator() const; /// \brief Retrieve the lambda static invoker, the address of which /// is returned by the conversion operator, and the body of which - /// is forwarded to the lambda call operator. - CXXMethodDecl *getLambdaStaticInvoker() const; + /// is forwarded to the lambda call operator. + CXXMethodDecl *getLambdaStaticInvoker() const; /// \brief Retrieve the generic lambda's template parameter list. - /// Returns null if the class does not represent a lambda or a generic + /// Returns null if the class does not represent a lambda or a generic /// lambda. TemplateParameterList *getGenericLambdaTemplateParameterList() const; @@ -1164,7 +1164,7 @@ /// not overridden. bool isAbstract() const { return data().Abstract; } - /// \brief Determine whether this class has standard layout per + /// \brief Determine whether this class has standard layout per /// (C++ [class]p7) bool isStandardLayout() const { return data().IsStandardLayout; } @@ -1656,28 +1656,28 @@ /// \brief If this is the closure type of a lambda expression, retrieve the /// number to be used for name mangling in the Itanium C++ ABI. /// - /// Zero indicates that this closure type has internal linkage, so the + /// Zero indicates that this closure type has internal linkage, so the /// mangling number does not matter, while a non-zero value indicates which /// lambda expression this is in this particular context. unsigned getLambdaManglingNumber() const { assert(isLambda() && "Not a lambda closure type!"); return getLambdaData().ManglingNumber; } - - /// \brief Retrieve the declaration that provides additional context for a + + /// \brief Retrieve the declaration that provides additional context for a /// lambda, when the normal declaration context is not specific enough. /// - /// Certain contexts (default arguments of in-class function parameters and + /// Certain contexts (default arguments of in-class function parameters and /// the initializers of data members) have separate name mangling rules for /// lambdas within the Itanium C++ ABI. For these cases, this routine provides - /// the declaration in which the lambda occurs, e.g., the function parameter + /// the declaration in which the lambda occurs, e.g., the function parameter /// or the non-static data member. Otherwise, it returns NULL to imply that /// the declaration context suffices. Decl *getLambdaContextDecl() const { assert(isLambda() && "Not a lambda closure type!"); - return getLambdaData().ContextDecl; + return getLambdaData().ContextDecl; } - + /// \brief Set the mangling number and context declaration for a lambda /// class. void setLambdaMangling(unsigned ManglingNumber, Decl *ContextDecl) { @@ -2513,7 +2513,7 @@ /// \brief Determine whether this conversion function is a conversion from /// a lambda closure type to a block pointer. bool isLambdaToBlockPointerConversion() const; - + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == CXXConversion; } @@ -2522,7 +2522,7 @@ friend class ASTDeclWriter; }; -/// \brief Represents a linkage specification. +/// \brief Represents a linkage specification. /// /// For example: /// \code @@ -2567,7 +2567,7 @@ SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces); static LinkageSpecDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + /// \brief Return the language specified by this linkage specification. LanguageIDs getLanguage() const { return LanguageIDs(Language); } /// \brief Set the language specified by this linkage specification. @@ -2935,12 +2935,12 @@ class ConstructorUsingShadowDecl final : public UsingShadowDecl { void anchor() override; - /// \brief If this constructor using declaration inherted the constructor + /// \brief If this constructor using declaration inherited the constructor /// from an indirect base class, this is the ConstructorUsingShadowDecl /// in the named direct base class from which the declaration was inherited. ConstructorUsingShadowDecl *NominatedBaseClassShadowDecl; - /// \brief If this constructor using declaration inherted the constructor + /// \brief If this constructor using declaration inherited the constructor /// from an indirect base class, this is the ConstructorUsingShadowDecl /// that will be used to construct the unique direct or virtual base class /// that receives the constructor arguments. @@ -3353,7 +3353,7 @@ Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed); static StaticAssertDecl *CreateDeserialized(ASTContext &C, unsigned ID); - + Expr *getAssertExpr() { return AssertExprAndFailed.getPointer(); } const Expr *getAssertExpr() const { return AssertExprAndFailed.getPointer(); } Index: lib/Sema/SemaExprCXX.cpp =================================================================== --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -292,7 +292,7 @@ if (isDependent) { // We didn't find our type, but that's okay: it's dependent // anyway. - + // FIXME: What if we have no nested-name-specifier? QualType T = CheckTypenameType(ETK_None, SourceLocation(), SS.getWithLocInContext(Context), @@ -326,14 +326,14 @@ ParsedType Sema::getDestructorType(const DeclSpec& DS, ParsedType ObjectType) { if (DS.getTypeSpecType() == DeclSpec::TST_error || !ObjectType) return nullptr; - assert(DS.getTypeSpecType() == DeclSpec::TST_decltype + assert(DS.getTypeSpecType() == DeclSpec::TST_decltype && "only get destructor types from declspecs"); QualType T = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc()); QualType SearchType = GetTypeFromParser(ObjectType); if (SearchType->isDependentType() || Context.hasSameUnqualifiedType(SearchType, T)) { return ParsedType::make(T); } - + Diag(DS.getTypeSpecTypeLoc(), diag::err_destructor_expr_type_mismatch) << T << SearchType; return nullptr; @@ -662,7 +662,7 @@ IsThrownVarInScope = true; break; } - + if (S->getFlags() & (Scope::FnScope | Scope::ClassScope | Scope::BlockScope | Scope::FunctionPrototypeScope | Scope::ObjCMethodScope | @@ -672,11 +672,11 @@ } } } - + return BuildCXXThrow(OpLoc, Ex, IsThrownVarInScope); } -ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, +ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope) { // Don't report an error if 'throw' is used in system headers. if (!getLangOpts().CXXExceptions && @@ -903,10 +903,10 @@ I-- && isa(FunctionScopes[I]); CurDC = getLambdaAwareParentOfDeclContext(CurDC)) { CurLSI = cast(FunctionScopes[I]); - - if (!CurLSI->isCXXThisCaptured()) + + if (!CurLSI->isCXXThisCaptured()) continue; - + auto C = CurLSI->getCXXThisCapture(); if (C.isCopyCapture()) { @@ -922,7 +922,7 @@ assert(CurLSI); assert(isGenericLambdaCallOperatorSpecialization(CurLSI->CallOperator)); assert(CurDC == getLambdaAwareParentOfDeclContext(CurLSI->CallOperator)); - + auto IsThisCaptured = [](CXXRecordDecl *Closure, bool &IsByCopy, bool &IsConst) { IsConst = false; @@ -992,10 +992,10 @@ return ThisTy; } -Sema::CXXThisScopeRAII::CXXThisScopeRAII(Sema &S, +Sema::CXXThisScopeRAII::CXXThisScopeRAII(Sema &S, Decl *ContextDecl, unsigned CXXThisTypeQuals, - bool Enabled) + bool Enabled) : S(S), OldCXXThisTypeOverride(S.CXXThisTypeOverride), Enabled(false) { if (!Enabled || !ContextDecl) @@ -1006,13 +1006,13 @@ Record = Template->getTemplatedDecl(); else Record = cast(ContextDecl); - + // We care only for CVR qualifiers here, so cut everything else. CXXThisTypeQuals &= Qualifiers::FastMask; S.CXXThisTypeOverride = S.Context.getPointerType( S.Context.getRecordType(Record).withCVRQualifiers(CXXThisTypeQuals)); - + this->Enabled = true; } @@ -1026,7 +1026,7 @@ static Expr *captureThis(Sema &S, ASTContext &Context, RecordDecl *RD, QualType ThisTy, SourceLocation Loc, const bool ByCopy) { - + QualType AdjustedThisTy = ThisTy; // The type of the corresponding data member (not a 'this' pointer if 'by // copy'). @@ -1039,7 +1039,7 @@ CaptureThisFieldTy.removeLocalCVRQualifiers(Qualifiers::CVRMask); AdjustedThisTy = Context.getPointerType(CaptureThisFieldTy); } - + FieldDecl *Field = FieldDecl::Create( Context, RD, Loc, Loc, nullptr, CaptureThisFieldTy, Context.getTrivialTypeSourceInfo(CaptureThisFieldTy, Loc), nullptr, false, @@ -1065,24 +1065,24 @@ return This; } -bool Sema::CheckCXXThisCapture(SourceLocation Loc, const bool Explicit, +bool Sema::CheckCXXThisCapture(SourceLocation Loc, const bool Explicit, bool BuildAndDiagnose, const unsigned *const FunctionScopeIndexToStopAt, const bool ByCopy) { // We don't need to capture this in an unevaluated context. if (isUnevaluatedContext() && !Explicit) return true; - + assert((!ByCopy || Explicit) && "cannot implicitly capture *this by value"); const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1; - + // Check that we can capture the *enclosing object* (referred to by '*this') - // by the capturing-entity/closure (lambda/block/etc) at - // MaxFunctionScopesIndex-deep on the FunctionScopes stack. + // by the capturing-entity/closure (lambda/block/etc) at + // MaxFunctionScopesIndex-deep on the FunctionScopes stack. - // Note: The *enclosing object* can only be captured by-value by a - // closure that is a lambda, using the explicit notation: + // Note: The *enclosing object* can only be captured by-value by a + // closure that is a lambda, using the explicit notation: // [*this] { ... }. // Every other capture of the *enclosing object* results in its by-reference // capture. @@ -1091,15 +1091,15 @@ // stack), we can capture the *enclosing object* only if: // - 'L' has an explicit byref or byval capture of the *enclosing object* // - or, 'L' has an implicit capture. - // AND + // AND // -- there is no enclosing closure - // -- or, there is some enclosing closure 'E' that has already captured the - // *enclosing object*, and every intervening closure (if any) between 'E' + // -- or, there is some enclosing closure 'E' that has already captured the + // *enclosing object*, and every intervening closure (if any) between 'E' // and 'L' can implicitly capture the *enclosing object*. - // -- or, every enclosing closure can implicitly capture the + // -- or, every enclosing closure can implicitly capture the // *enclosing object* - - + + unsigned NumCapturingClosures = 0; for (unsigned idx = MaxFunctionScopesIndex; idx != 0; idx--) { if (CapturingScopeInfo *CSI = @@ -1155,18 +1155,18 @@ // FIXME: We need to delay this marking in PotentiallyPotentiallyEvaluated // contexts. QualType ThisTy = getCurrentThisType(); - for (unsigned idx = MaxFunctionScopesIndex; NumCapturingClosures; + for (unsigned idx = MaxFunctionScopesIndex; NumCapturingClosures; --idx, --NumCapturingClosures) { CapturingScopeInfo *CSI = cast(FunctionScopes[idx]); Expr *ThisExpr = nullptr; - + if (LambdaScopeInfo *LSI = dyn_cast(CSI)) { // For lambda expressions, build a field and an initializing expression, // and capture the *enclosing object* by copy only if this is the first // iteration. ThisExpr = captureThis(*this, Context, LSI->Lambda, ThisTy, Loc, ByCopy && idx == MaxFunctionScopesIndex); - + } else if (CapturedRegionScopeInfo *RSI = dyn_cast(FunctionScopes[idx])) ThisExpr = @@ -1196,7 +1196,7 @@ // type for 'this'. if (CXXThisTypeOverride.isNull()) return false; - + // Determine whether we're looking into a class that's currently being // defined. CXXRecordDecl *Class = BaseType->getAsCXXRecordDecl(); @@ -1574,7 +1574,7 @@ << /*at end of FE*/0 << Inits[0]->getSourceRange(); } - // In ARC, infer 'retaining' for the allocated + // In ARC, infer 'retaining' for the allocated if (getLangOpts().ObjCAutoRefCount && AllocType.getObjCLifetime() == Qualifiers::OCL_None && AllocType->isObjCLifetimeType()) { @@ -1583,7 +1583,7 @@ } QualType ResultType = Context.getPointerType(AllocType); - + if (ArraySize && ArraySize->getType()->isNonOverloadPlaceholderType()) { ExprResult result = CheckPlaceholderExpr(ArraySize); if (result.isInvalid()) return ExprError(); @@ -1604,7 +1604,7 @@ ConvertedSize = PerformImplicitConversion(ArraySize, Context.getSizeType(), AA_Converting); - if (!ConvertedSize.isInvalid() && + if (!ConvertedSize.isInvalid() && ArraySize->getType()->getAs()) // Diagnose the compatibility of this conversion. Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion) @@ -1613,7 +1613,7 @@ class SizeConvertDiagnoser : public ICEConvertDiagnoser { protected: Expr *ArraySize; - + public: SizeConvertDiagnoser(Expr *ArraySize) : ICEConvertDiagnoser(/*AllowScopedEnumerations*/false, false, false), @@ -1872,7 +1872,7 @@ if (CXXDestructorDecl *dtor = LookupDestructor( cast(BaseRecordType->getDecl()))) { MarkFunctionReferenced(StartLoc, dtor); - CheckDestructorAccess(StartLoc, dtor, + CheckDestructorAccess(StartLoc, dtor, PDiag(diag::err_access_dtor) << BaseAllocType); if (DiagnoseUseOfDecl(dtor, StartLoc)) @@ -1921,7 +1921,7 @@ << BaseAllocType; } } - + return false; } @@ -2257,7 +2257,7 @@ if (Diagnose) { Diag(StartLoc, diag::err_ovl_deleted_call) << Best->Function->isDeleted() - << Name + << Name << getDeletedOrUnavailableSuffix(Best->Function) << Range; Candidates.NoteCandidates(*this, OCD_AllCandidates, Args); @@ -2428,7 +2428,7 @@ SourceLocation(), Name, FnType, /*TInfo=*/nullptr, SC_None, false, true); Alloc->setImplicit(); - + // Implicit sized deallocation functions always have default visibility. Alloc->addAttr(VisibilityAttr::CreateImplicit(Context, VisibilityAttr::Default)); @@ -2921,7 +2921,7 @@ QualType PointeeElem = Context.getBaseElementType(Pointee); if (unsigned AddressSpace = Pointee.getAddressSpace()) - return Diag(Ex.get()->getLocStart(), + return Diag(Ex.get()->getLocStart(), diag::err_address_space_qualified_delete) << Pointee.getUnqualifiedType() << AddressSpace; @@ -3003,7 +3003,7 @@ // Check access and ambiguity of operator delete and destructor. if (PointeeRD) { if (CXXDestructorDecl *Dtor = LookupDestructor(PointeeRD)) { - CheckDestructorAccess(Ex.get()->getExprLoc(), Dtor, + CheckDestructorAccess(Ex.get()->getExprLoc(), Dtor, PDiag(diag::err_access_dtor) << PointeeElem); } } @@ -3234,7 +3234,7 @@ ExprResult Sema::PerformImplicitConversion(Expr *From, QualType ToType, const ImplicitConversionSequence &ICS, - AssignmentAction Action, + AssignmentAction Action, CheckedConversionKind CCK) { switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: { @@ -3324,16 +3324,16 @@ ExprResult Sema::PerformImplicitConversion(Expr *From, QualType ToType, const StandardConversionSequence& SCS, - AssignmentAction Action, + AssignmentAction Action, CheckedConversionKind CCK) { bool CStyle = (CCK == CCK_CStyleCast || CCK == CCK_FunctionalCast); - + // Overall FIXME: we are recomputing too many types here and doing far too // much extra work. What this means is that we need to keep track of more // information that is computed when we try the implicit conversion initially, // so that we don't need to recompute anything here. QualType FromType = From->getType(); - + if (SCS.CopyConstructor) { // FIXME: When can ToType be a reference type? assert(!ToType->isReferenceType()); @@ -3403,13 +3403,13 @@ case ICK_Array_To_Pointer: FromType = Context.getArrayDecayedType(FromType); - From = ImpCastExprToType(From, FromType, CK_ArrayToPointerDecay, + From = ImpCastExprToType(From, FromType, CK_ArrayToPointerDecay, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; case ICK_Function_To_Pointer: FromType = Context.getPointerType(FromType); - From = ImpCastExprToType(From, FromType, CK_FunctionToPointerDecay, + From = ImpCastExprToType(From, FromType, CK_FunctionToPointerDecay, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; @@ -3452,7 +3452,7 @@ if (CheckExceptionSpecCompatibility(From, ToType)) return ExprError(); - From = ImpCastExprToType(From, ToType, CK_NoOp, + From = ImpCastExprToType(From, ToType, CK_NoOp, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; @@ -3472,7 +3472,7 @@ case ICK_Floating_Promotion: case ICK_Floating_Conversion: - From = ImpCastExprToType(From, ToType, CK_FloatingCast, + From = ImpCastExprToType(From, ToType, CK_FloatingCast, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; @@ -3491,22 +3491,22 @@ } else { CK = CK_IntegralComplexCast; } - From = ImpCastExprToType(From, ToType, CK, + From = ImpCastExprToType(From, ToType, CK, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; } case ICK_Floating_Integral: if (ToType->isRealFloatingType()) - From = ImpCastExprToType(From, ToType, CK_IntegralToFloating, + From = ImpCastExprToType(From, ToType, CK_IntegralToFloating, VK_RValue, /*BasePath=*/nullptr, CCK).get(); else - From = ImpCastExprToType(From, ToType, CK_FloatingToIntegral, + From = ImpCastExprToType(From, ToType, CK_FloatingToIntegral, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; case ICK_Compatible_Conversion: - From = ImpCastExprToType(From, ToType, CK_NoOp, + From = ImpCastExprToType(From, ToType, CK_NoOp, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; @@ -3528,20 +3528,20 @@ if (From->getType()->isObjCObjectPointerType() && ToType->isObjCObjectPointerType()) EmitRelatedResultTypeNote(From); - } + } else if (getLangOpts().ObjCAutoRefCount && - !CheckObjCARCUnavailableWeakConversion(ToType, + !CheckObjCARCUnavailableWeakConversion(ToType, From->getType())) { if (Action == AA_Initializing) - Diag(From->getLocStart(), + Diag(From->getLocStart(), diag::err_arc_weak_unavailable_assign); else Diag(From->getLocStart(), - diag::err_arc_convesion_of_weak_unavailable) - << (Action == AA_Casting) << From->getType() << ToType + diag::err_arc_convesion_of_weak_unavailable) + << (Action == AA_Casting) << From->getType() << ToType << From->getSourceRange(); } - + CastKind Kind = CK_Invalid; CXXCastPath BasePath; if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle)) @@ -3589,7 +3589,7 @@ } From = ImpCastExprToType(From, Context.BoolTy, - ScalarTypeToBooleanCastKind(FromType), + ScalarTypeToBooleanCastKind(FromType), VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; @@ -3610,7 +3610,7 @@ } case ICK_Vector_Conversion: - From = ImpCastExprToType(From, ToType, CK_BitCast, + From = ImpCastExprToType(From, ToType, CK_BitCast, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; @@ -3655,7 +3655,7 @@ // _Complex x -> x From = ImpCastExprToType(From, ElType, isFloatingComplex ? CK_FloatingComplexToReal - : CK_IntegralComplexToReal, + : CK_IntegralComplexToReal, VK_RValue, /*BasePath=*/nullptr, CCK).get(); // x -> y @@ -3663,23 +3663,23 @@ // do nothing } else if (ToType->isRealFloatingType()) { From = ImpCastExprToType(From, ToType, - isFloatingComplex ? CK_FloatingCast : CK_IntegralToFloating, + isFloatingComplex ? CK_FloatingCast : CK_IntegralToFloating, VK_RValue, /*BasePath=*/nullptr, CCK).get(); } else { assert(ToType->isIntegerType()); From = ImpCastExprToType(From, ToType, - isFloatingComplex ? CK_FloatingToIntegral : CK_IntegralCast, + isFloatingComplex ? CK_FloatingToIntegral : CK_IntegralCast, VK_RValue, /*BasePath=*/nullptr, CCK).get(); } } break; - + case ICK_Block_Pointer_Conversion: { From = ImpCastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast, VK_RValue, /*BasePath=*/nullptr, CCK).get(); break; } - + case ICK_TransparentUnionConversion: { ExprResult FromRes = From; Sema::AssignConvertType ConvTy = @@ -3882,8 +3882,8 @@ static bool HasNoThrowOperator(const RecordType *RT, OverloadedOperatorKind Op, Sema &Self, SourceLocation KeyLoc, ASTContext &C, - bool (CXXRecordDecl::*HasTrivial)() const, - bool (CXXRecordDecl::*HasNonTrivial)() const, + bool (CXXRecordDecl::*HasTrivial)() const, + bool (CXXRecordDecl::*HasNonTrivial)() const, bool (CXXMethodDecl::*IsDesiredOp)() const) { CXXRecordDecl *RD = cast(RT->getDecl()); @@ -3979,7 +3979,7 @@ return false; } } - + return T->isScalarType(); case UTT_IsCompound: return T->isCompoundType(); @@ -4158,12 +4158,12 @@ // false. if (T.isPODType(C) || T->isReferenceType()) return true; - + // Objective-C++ ARC: autorelease types don't require destruction. - if (T->isObjCLifetimeType() && + if (T->isObjCLifetimeType() && T.getObjCLifetime() == Qualifiers::OCL_Autoreleasing) return true; - + if (CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) return RD->hasTrivialDestructor(); return false; @@ -4223,6 +4223,9 @@ // resolution point. if (isa(ND)) continue; + // Using(Shadow)Decl itself is not a constructor + if (isa(ND) || isa(ND)) + continue; const CXXConstructorDecl *Constructor = cast(ND); if (Constructor->isCopyConstructor(FoundTQs)) { FoundConstructor = true; @@ -4259,6 +4262,9 @@ // FIXME: In C++0x, a constructor template can be a default constructor. if (isa(ND)) continue; + // Using(Shadow)Decl itself is not a constructor + if (isa(ND) || isa(ND)) + continue; const CXXConstructorDecl *Constructor = cast(ND); if (Constructor->isDefaultConstructor()) { FoundConstructor = true; @@ -4339,9 +4345,9 @@ // definition for is_constructible, as defined below, is known to call // no operation that is not trivial. // - // The predicate condition for a template specialization - // is_constructible shall be satisfied if and only if the - // following variable definition would be well-formed for some invented + // The predicate condition for a template specialization + // is_constructible shall be satisfied if and only if the + // following variable definition would be well-formed for some invented // variable t: // // T t(create()...); @@ -4355,7 +4361,7 @@ if (ArgTy->isVoidType() || ArgTy->isIncompleteArrayType()) continue; - if (S.RequireCompleteType(KWLoc, ArgTy, + if (S.RequireCompleteType(KWLoc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr)) return false; } @@ -4385,7 +4391,7 @@ for (Expr &E : OpaqueArgExprs) ArgExprs.push_back(&E); - // Perform the initialization in an unevaluated context within a SFINAE + // Perform the initialization in an unevaluated context within a SFINAE // trap at translation unit scope. EnterExpressionEvaluationContext Unevaluated(S, Sema::Unevaluated); Sema::SFINAETrap SFINAE(S, /*AccessCheckingSFINAE=*/true); @@ -4424,12 +4430,12 @@ } default: llvm_unreachable("not a TT"); } - + return false; } -ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, - ArrayRef Args, +ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, + ArrayRef Args, SourceLocation RParenLoc) { QualType ResultType = Context.getLogicalOperationType(); @@ -4458,14 +4464,14 @@ SourceLocation RParenLoc) { SmallVector ConvertedArgs; ConvertedArgs.reserve(Args.size()); - + for (unsigned I = 0, N = Args.size(); I != N; ++I) { TypeSourceInfo *TInfo; QualType T = GetTypeFromParser(Args[I], &TInfo); if (!TInfo) TInfo = Context.getTrivialTypeSourceInfo(T, KWLoc); - - ConvertedArgs.push_back(TInfo); + + ConvertedArgs.push_back(TInfo); } return BuildTypeTrait(Kind, KWLoc, ConvertedArgs, RParenLoc); @@ -4499,7 +4505,7 @@ // If Base and Derived are class types and are different types // (ignoring possible cv-qualifiers) then Derived shall be a // complete type. - if (Self.RequireCompleteType(KeyLoc, RhsT, + if (Self.RequireCompleteType(KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr)) return false; @@ -4516,21 +4522,21 @@ // C++0x [meta.rel]p4: // Given the following function prototype: // - // template + // template // typename add_rvalue_reference::type create(); // - // the predicate condition for a template specialization - // is_convertible shall be satisfied if and only if - // the return expression in the following code would be + // the predicate condition for a template specialization + // is_convertible shall be satisfied if and only if + // the return expression in the following code would be // well-formed, including any implicit conversions to the return // type of the function: // - // To test() { + // To test() { // return create(); // } // - // Access checking is performed as if in a context unrelated to To and - // From. Only the validity of the immediate context of the expression + // Access checking is performed as if in a context unrelated to To and + // From. Only the validity of the immediate context of the expression // of the return-statement (including conversions to the return type) // is considered. // @@ -4559,10 +4565,10 @@ OpaqueValueExpr From(KeyLoc, LhsT.getNonLValueExprType(Self.Context), Expr::getValueKindForType(LhsT)); Expr *FromPtr = &From; - InitializationKind Kind(InitializationKind::CreateCopy(KeyLoc, + InitializationKind Kind(InitializationKind::CreateCopy(KeyLoc, SourceLocation())); - - // Perform the initialization in an unevaluated context within a SFINAE + + // Perform the initialization in an unevaluated context within a SFINAE // trap at translation unit scope. EnterExpressionEvaluationContext Unevaluated(Self, Sema::Unevaluated); Sema::SFINAETrap SFINAE(Self, /*AccessCheckingSFINAE=*/true); @@ -4584,17 +4590,17 @@ // is_assignable, is known to call no operation that is not trivial // // is_assignable is defined as: - // The expression declval() = declval() is well-formed when + // The expression declval() = declval() is well-formed when // treated as an unevaluated operand (Clause 5). // - // For both, T and U shall be complete types, (possibly cv-qualified) + // For both, T and U shall be complete types, (possibly cv-qualified) // void, or arrays of unknown bound. if (!LhsT->isVoidType() && !LhsT->isIncompleteArrayType() && - Self.RequireCompleteType(KeyLoc, LhsT, + Self.RequireCompleteType(KeyLoc, LhsT, diag::err_incomplete_type_used_in_type_trait_expr)) return false; if (!RhsT->isVoidType() && !RhsT->isIncompleteArrayType() && - Self.RequireCompleteType(KeyLoc, RhsT, + Self.RequireCompleteType(KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr)) return false; @@ -4602,7 +4608,7 @@ if (LhsT->isVoidType() || RhsT->isVoidType()) return false; - // Build expressions that emulate the effect of declval() and + // Build expressions that emulate the effect of declval() and // declval(). if (LhsT->isObjectType() || LhsT->isFunctionType()) LhsT = Self.Context.getRValueReferenceType(LhsT); @@ -4612,8 +4618,8 @@ Expr::getValueKindForType(LhsT)); OpaqueValueExpr Rhs(KeyLoc, RhsT.getNonLValueExprType(Self.Context), Expr::getValueKindForType(RhsT)); - - // Attempt the assignment in an unevaluated context within a SFINAE + + // Attempt the assignment in an unevaluated context within a SFINAE // trap at translation unit scope. EnterExpressionEvaluationContext Unevaluated(Self, Sema::Unevaluated); Sema::SFINAETrap SFINAE(Self, /*AccessCheckingSFINAE=*/true); @@ -5046,7 +5052,7 @@ Self.MarkFunctionReferenced(QuestionLoc, Best->Function); return false; } - + case OR_No_Viable_Function: // Emit a better diagnostic if one of the expressions is a null pointer @@ -5612,14 +5618,14 @@ else if (MemberExpr *Mem = dyn_cast(Callee)) T = Mem->getMemberDecl()->getType(); } - + if (const PointerType *Ptr = T->getAs()) T = Ptr->getPointeeType(); else if (const BlockPointerType *Ptr = T->getAs()) T = Ptr->getPointeeType(); else if (const MemberPointerType *MemPtr = T->getAs()) T = MemPtr->getPointeeType(); - + const FunctionType *FTy = T->getAs(); assert(FTy && "call to value not of function type?"); ReturnsRetained = FTy->getExtInfo().getProducesResult(); @@ -6006,7 +6012,7 @@ // so adjust the base type to the object type itself. if (BaseType->isObjCObjectPointerType()) BaseType = BaseType->getPointeeType(); - + // C++ [basic.lookup.classref]p2: // [...] If the type of the object expression is of pointer to scalar // type, the unqualified-id is looked up in the context of the complete @@ -6031,7 +6037,7 @@ // The object type must be complete (or dependent), or // C++11 [expr.prim.general]p3: // Unlike the object expression in other contexts, *this is not required to - // be of complete type for purposes of class member access (5.2.5) outside + // be of complete type for purposes of class member access (5.2.5) outside // the member function body. if (!BaseType->isDependentType() && !isThisOutsideMemberFunctionBody(BaseType) && @@ -6047,7 +6053,7 @@ return Base; } -static bool CheckArrow(Sema& S, QualType& ObjectType, Expr *&Base, +static bool CheckArrow(Sema& S, QualType& ObjectType, Expr *&Base, tok::TokenKind& OpKind, SourceLocation OpLoc) { if (Base->hasPlaceholderType()) { ExprResult result = S.CheckPlaceholderExpr(Base); @@ -6123,9 +6129,9 @@ DestructedTypeInfo = Context.getTrivialTypeSourceInfo(ObjectType, DestructedTypeStart); Destructed = PseudoDestructorTypeStorage(DestructedTypeInfo); - } else if (DestructedType.getObjCLifetime() != + } else if (DestructedType.getObjCLifetime() != ObjectType.getObjCLifetime()) { - + if (DestructedType.getObjCLifetime() == Qualifiers::OCL_None) { // Okay: just pretend that the user provided the correctly-qualified // type. @@ -6134,7 +6140,7 @@ << ObjectType << DestructedType << Base->getSourceRange() << DestructedTypeInfo->getTypeLoc().getLocalSourceRange(); } - + // Recover by setting the destructed type to the object type. DestructedType = ObjectType; DestructedTypeInfo = Context.getTrivialTypeSourceInfo(ObjectType, @@ -6318,7 +6324,7 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, - SourceLocation TildeLoc, + SourceLocation TildeLoc, const DeclSpec& DS) { QualType ObjectType; if (CheckArrow(*this, ObjectType, Base, OpKind, OpLoc)) @@ -6513,7 +6519,7 @@ if (Res.isInvalid()) return E; E = Res.get(); - } + } return E; } @@ -6543,13 +6549,13 @@ // we can unambiguously check if the variable is a constant expression. // - if the initializer is not value dependent - we can determine whether // it can be used to initialize a constant expression. If Init can not -// be used to initialize a constant expression we conclude that Var can +// be used to initialize a constant expression we conclude that Var can // never be a constant expression. // - FXIME: if the initializer is dependent, we can still do some analysis and // identify certain cases unambiguously as non-const by using a Visitor: // - such as those that involve odr-use of a ParmVarDecl, involve a new // delete, lambda-expr, dynamic-cast, reinterpret-cast etc... -static inline bool VariableCanNeverBeAConstantExpression(VarDecl *Var, +static inline bool VariableCanNeverBeAConstantExpression(VarDecl *Var, ASTContext &Context) { if (isa(Var)) return true; const VarDecl *DefVD = nullptr; @@ -6569,29 +6575,29 @@ return false; } - return !IsVariableAConstantExpression(Var, Context); + return !IsVariableAConstantExpression(Var, Context); } -/// \brief Check if the current lambda has any potential captures -/// that must be captured by any of its enclosing lambdas that are ready to -/// capture. If there is a lambda that can capture a nested -/// potential-capture, go ahead and do so. Also, check to see if any -/// variables are uncaptureable or do not involve an odr-use so do not +/// \brief Check if the current lambda has any potential captures +/// that must be captured by any of its enclosing lambdas that are ready to +/// capture. If there is a lambda that can capture a nested +/// potential-capture, go ahead and do so. Also, check to see if any +/// variables are uncaptureable or do not involve an odr-use so do not /// need to be captured. static void CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures( Expr *const FE, LambdaScopeInfo *const CurrentLSI, Sema &S) { - assert(!S.isUnevaluatedContext()); - assert(S.CurContext->isDependentContext()); - assert(CurrentLSI->CallOperator == S.CurContext && + assert(!S.isUnevaluatedContext()); + assert(S.CurContext->isDependentContext()); + assert(CurrentLSI->CallOperator == S.CurContext && "The current call operator must be synchronized with Sema's CurContext"); const bool IsFullExprInstantiationDependent = FE->isInstantiationDependent(); ArrayRef FunctionScopesArrayRef( S.FunctionScopes.data(), S.FunctionScopes.size()); - + // All the potentially captureable variables in the current nested // lambda (within a generic outer lambda), must be captured by an // outer lambda that is enclosed within a non-dependent context. @@ -6602,7 +6608,7 @@ VarDecl *Var = nullptr; CurrentLSI->getPotentialVariableCapture(I, Var, VarExpr); // If the variable is clearly identified as non-odr-used and the full - // expression is not instantiation dependent, only then do we not + // expression is not instantiation dependent, only then do we not // need to check enclosing lambda's for speculative captures. // For e.g.: // Even though 'x' is not odr-used, it should be captured. @@ -6624,27 +6630,27 @@ const unsigned FunctionScopeIndexOfCapturableLambda = Index.getValue(); MarkVarDeclODRUsed(Var, VarExpr->getExprLoc(), S, &FunctionScopeIndexOfCapturableLambda); - } - const bool IsVarNeverAConstantExpression = + } + const bool IsVarNeverAConstantExpression = VariableCanNeverBeAConstantExpression(Var, S.Context); if (!IsFullExprInstantiationDependent || IsVarNeverAConstantExpression) { // This full expression is not instantiation dependent or the variable - // can not be used in a constant expression - which means - // this variable must be odr-used here, so diagnose a + // can not be used in a constant expression - which means + // this variable must be odr-used here, so diagnose a // capture violation early, if the variable is un-captureable. // This is purely for diagnosing errors early. Otherwise, this // error would get diagnosed when the lambda becomes capture ready. QualType CaptureType, DeclRefType; SourceLocation ExprLoc = VarExpr->getExprLoc(); if (S.tryCaptureVariable(Var, ExprLoc, S.TryCapture_Implicit, - /*EllipsisLoc*/ SourceLocation(), - /*BuildAndDiagnose*/false, CaptureType, + /*EllipsisLoc*/ SourceLocation(), + /*BuildAndDiagnose*/false, CaptureType, DeclRefType, nullptr)) { // We will never be able to capture this variable, and we need // to be able to in any and all instantiations, so diagnose it. S.tryCaptureVariable(Var, ExprLoc, S.TryCapture_Implicit, - /*EllipsisLoc*/ SourceLocation(), - /*BuildAndDiagnose*/true, CaptureType, + /*EllipsisLoc*/ SourceLocation(), + /*BuildAndDiagnose*/true, CaptureType, DeclRefType, nullptr); } } @@ -6971,15 +6977,15 @@ ExprResult Sema::ActOnFinishFullExpr(Expr *FE, SourceLocation CC, bool DiscardedValue, - bool IsConstexpr, + bool IsConstexpr, bool IsLambdaInitCaptureInitializer) { ExprResult FullExpr = FE; if (!FullExpr.get()) return ExprError(); - - // If we are an init-expression in a lambdas init-capture, we should not - // diagnose an unexpanded pack now (will be diagnosed once lambda-expr + + // If we are an init-expression in a lambdas init-capture, we should not + // diagnose an unexpanded pack now (will be diagnosed once lambda-expr // containing full-expression is done). // template void test(Ts ... t) { // test([&a(t)]() { <-- (t) is an init-expr that shouldn't be diagnosed now. @@ -6993,7 +6999,7 @@ // lambda where we've entered the introducer but not the body, or represent a // lambda where we've entered the body, depending on where the // parser/instantiation has got to). - if (!IsLambdaInitCaptureInitializer && + if (!IsLambdaInitCaptureInitializer && DiagnoseUnexpandedParameterPack(FullExpr.get())) return ExprError(); @@ -7021,13 +7027,13 @@ CheckCompletedExpr(FullExpr.get(), CC, IsConstexpr); - // At the end of this full expression (which could be a deeply nested - // lambda), if there is a potential capture within the nested lambda, + // At the end of this full expression (which could be a deeply nested + // lambda), if there is a potential capture within the nested lambda, // have the outer capture-able lambda try and capture it. // Consider the following code: // void f(int, int); // void f(const int&, double); - // void foo() { + // void foo() { // const int x = 10, y = 20; // auto L = [=](auto a) { // auto M = [=](auto b) { @@ -7037,34 +7043,34 @@ // }; // } - // FIXME: Also consider what happens for something like this that involves - // the gnu-extension statement-expressions or even lambda-init-captures: + // FIXME: Also consider what happens for something like this that involves + // the gnu-extension statement-expressions or even lambda-init-captures: // void f() { // const int n = 0; // auto L = [&](auto a) { // +n + ({ 0; a; }); // }; // } - // - // Here, we see +n, and then the full-expression 0; ends, so we don't - // capture n (and instead remove it from our list of potential captures), - // and then the full-expression +n + ({ 0; }); ends, but it's too late + // + // Here, we see +n, and then the full-expression 0; ends, so we don't + // capture n (and instead remove it from our list of potential captures), + // and then the full-expression +n + ({ 0; }); ends, but it's too late // for us to see that we need to capture n after all. LambdaScopeInfo *const CurrentLSI = getCurLambda(); - // FIXME: PR 17877 showed that getCurLambda() can return a valid pointer + // FIXME: PR 17877 showed that getCurLambda() can return a valid pointer // even if CurContext is not a lambda call operator. Refer to that Bug Report - // for an example of the code that might cause this asynchrony. + // for an example of the code that might cause this asynchrony. // By ensuring we are in the context of a lambda's call operator // we can fix the bug (we only need to check whether we need to capture - // if we are within a lambda's body); but per the comments in that + // if we are within a lambda's body); but per the comments in that // PR, a proper fix would entail : // "Alternative suggestion: - // - Add to Sema an integer holding the smallest (outermost) scope - // index that we are *lexically* within, and save/restore/set to - // FunctionScopes.size() in InstantiatingTemplate's + // - Add to Sema an integer holding the smallest (outermost) scope + // index that we are *lexically* within, and save/restore/set to + // FunctionScopes.size() in InstantiatingTemplate's // constructor/destructor. - // - Teach the handful of places that iterate over FunctionScopes to + // - Teach the handful of places that iterate over FunctionScopes to // stop at the outermost enclosing lexical scope." const bool IsInLambdaDeclContext = isLambdaCallOperator(CurContext); if (IsInLambdaDeclContext && CurrentLSI && @@ -7080,34 +7086,34 @@ return MaybeCreateStmtWithCleanups(FullStmt); } -Sema::IfExistsResult +Sema::IfExistsResult Sema::CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS, const DeclarationNameInfo &TargetNameInfo) { DeclarationName TargetName = TargetNameInfo.getName(); if (!TargetName) return IER_DoesNotExist; - + // If the name itself is dependent, then the result is dependent. if (TargetName.isDependentName()) return IER_Dependent; - + // Do the redeclaration lookup in the current scope. LookupResult R(*this, TargetNameInfo, Sema::LookupAnyName, Sema::NotForRedeclaration); LookupParsedName(R, S, &SS); R.suppressDiagnostics(); - + switch (R.getResultKind()) { case LookupResult::Found: case LookupResult::FoundOverloaded: case LookupResult::FoundUnresolvedValue: case LookupResult::Ambiguous: return IER_Exists; - + case LookupResult::NotFound: return IER_DoesNotExist; - + case LookupResult::NotFoundInCurrentInstantiation: return IER_Dependent; } @@ -7115,23 +7121,23 @@ llvm_unreachable("Invalid LookupResult Kind!"); } -Sema::IfExistsResult +Sema::IfExistsResult Sema::CheckMicrosoftIfExistsSymbol(Scope *S, SourceLocation KeywordLoc, bool IsIfExists, CXXScopeSpec &SS, UnqualifiedId &Name) { DeclarationNameInfo TargetNameInfo = GetNameFromUnqualifiedId(Name); - + // Check for unexpanded parameter packs. SmallVector Unexpanded; collectUnexpandedParameterPacks(SS, Unexpanded); collectUnexpandedParameterPacks(TargetNameInfo, Unexpanded); if (!Unexpanded.empty()) { DiagnoseUnexpandedParameterPacks(KeywordLoc, - IsIfExists? UPPC_IfExists - : UPPC_IfNotExists, + IsIfExists? UPPC_IfExists + : UPPC_IfNotExists, Unexpanded); return IER_Error; } - + return CheckMicrosoftIfExistsSymbol(S, SS, TargetNameInfo); }