From: NAKAMURA Takumi Date: Thu, 27 Jan 2011 07:10:08 +0000 (+0000) Subject: Fix whitespace. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dfbb02a16ac8c764b5ba1742450513d6212d2f9f;p=clang Fix whitespace. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124364 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp index 4eea2bc239..db9f7f2c83 100644 --- a/lib/Analysis/PrintfFormatString.cpp +++ b/lib/Analysis/PrintfFormatString.cpp @@ -100,7 +100,7 @@ static PrintfSpecifierResult ParsePrintfSpecifier(FormatStringHandler &H, for ( ; I != E; ++I) { switch (*I) { default: hasMore = false; break; - case '\'': + case '\'': // FIXME: POSIX specific. Always accept? FS.setHasThousandsGrouping(I); break; @@ -281,7 +281,7 @@ const char *ConversionSpecifier::toString() const { ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx) const { const PrintfConversionSpecifier &CS = getConversionSpecifier(); - + if (!CS.consumesDataArgument()) return ArgTypeResult::Invalid(); @@ -292,7 +292,7 @@ ArgTypeResult PrintfSpecifier::getArgType(ASTContext &Ctx) const { default: return ArgTypeResult::Invalid(); } - + if (CS.isIntArg()) switch (LM.getKind()) { case LengthModifier::AsLongDouble: @@ -593,7 +593,7 @@ bool PrintfSpecifier::hasValidLeftJustified() const { bool PrintfSpecifier::hasValidThousandsGroupingPrefix() const { if (!HasThousandsGrouping) return true; - + switch (CS.getKind()) { case ConversionSpecifier::dArg: case ConversionSpecifier::iArg: diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 7e0cb8a433..53679d370c 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -31,7 +31,7 @@ using namespace clang; using namespace sema; ParsedType Sema::getDestructorName(SourceLocation TildeLoc, - IdentifierInfo &II, + IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectTypePtr, @@ -71,11 +71,11 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, if (SS.isSet()) { NestedNameSpecifier *NNS = (NestedNameSpecifier *)SS.getScopeRep(); - + bool AlreadySearched = false; bool LookAtPrefix = true; // C++ [basic.lookup.qual]p6: - // If a pseudo-destructor-name (5.2.4) contains a nested-name-specifier, + // If a pseudo-destructor-name (5.2.4) contains a nested-name-specifier, // the type-names are looked up as types in the scope designated by the // nested-name-specifier. In a qualified-id of the form: // @@ -86,11 +86,11 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // // ::opt nested-name-specifier class-name :: ~ class-name // - // the class-names are looked up as types in the scope designated by + // the class-names are looked up as types in the scope designated by // the nested-name-specifier. // // Here, we check the first case (completely) and determine whether the - // code below is permitted to look at the prefix of the + // code below is permitted to look at the prefix of the // nested-name-specifier. DeclContext *DC = computeDeclContext(SS, EnteringContext); if (DC && DC->isFileContext()) { @@ -99,7 +99,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, isDependent = false; } else if (DC && isa(DC)) LookAtPrefix = false; - + // The second case from the C++03 rules quoted further above. NestedNameSpecifier *Prefix = 0; if (AlreadySearched) { @@ -116,7 +116,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, LookupCtx = computeDeclContext(SS, EnteringContext); isDependent = LookupCtx && LookupCtx->isDependentContext(); } - + LookInScope = false; } else if (ObjectTypePtr) { // C++ [basic.lookup.classref]p3: @@ -128,7 +128,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // cv-qualified) T. LookupCtx = computeDeclContext(SearchType); isDependent = SearchType->isDependentType(); - assert((isDependent || !SearchType->isIncompleteType()) && + assert((isDependent || !SearchType->isIncompleteType()) && "Caller should have completed object type"); LookInScope = true; @@ -170,7 +170,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // nested-name-specifier (if present) or the object type, then // this is the destructor for that class. // FIXME: This is a workaround until we get real drafting for core - // issue 399, for which there isn't even an obvious direction. + // issue 399, for which there isn't even an obvious direction. if (ClassTemplateDecl *Template = Found.getAsSingle()) { QualType MemberOfType; if (SS.isSet()) { @@ -182,7 +182,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, } if (MemberOfType.isNull()) MemberOfType = SearchType; - + if (MemberOfType.isNull()) continue; @@ -199,7 +199,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, continue; } - + // We're referring to an unresolved class template // specialization. Determine whether we class template we found // is the same as the template being specialized or, if we don't @@ -220,7 +220,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, // The class template we found has the same name as the // (dependent) template name being specialized. - if (DependentTemplateName *DepTemplate + if (DependentTemplateName *DepTemplate = SpecName.getAsDependentTemplateName()) { if (DepTemplate->isIdentifier() && DepTemplate->getIdentifier() == Template->getIdentifier()) @@ -253,7 +253,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, if (ObjectTypePtr) Diag(NameLoc, diag::err_ident_in_pseudo_dtor_not_a_type) - << &II; + << &II; else Diag(NameLoc, diag::err_destructor_class_name); @@ -266,9 +266,9 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, TypeSourceInfo *Operand, SourceLocation RParenLoc) { // C++ [expr.typeid]p4: - // The top-level cv-qualifiers of the lvalue expression or the type-id + // The top-level cv-qualifiers of the lvalue expression or the type-id // that is the operand of typeid are always ignored. - // If the type of the type-id is a class type or a reference to a class + // If the type of the type-id is a class type or a reference to a class // type, the class shall be completely-defined. Qualifiers Quals; QualType T @@ -277,7 +277,7 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, if (T->getAs() && RequireCompleteType(TypeidLoc, T, diag::err_incomplete_typeid)) return ExprError(); - + return Owned(new (Context) CXXTypeidExpr(TypeInfoType.withConst(), Operand, SourceRange(TypeidLoc, RParenLoc))); @@ -298,7 +298,7 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, // shall be completely-defined. if (RequireCompleteType(TypeidLoc, T, diag::err_incomplete_typeid)) return ExprError(); - + // C++ [expr.typeid]p3: // When typeid is applied to an expression other than an glvalue of a // polymorphic class type [...] [the] expression is an unevaluated @@ -310,11 +310,11 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, MarkVTableUsed(TypeidLoc, RecordD); } } - + // C++ [expr.typeid]p4: // [...] If the type of the type-id is a reference to a possibly - // cv-qualified type, the result of the typeid expression refers to a - // std::type_info object representing the cv-unqualified referenced + // cv-qualified type, the result of the typeid expression refers to a + // std::type_info object representing the cv-unqualified referenced // type. Qualifiers Quals; QualType UnqualT = Context.getUnqualifiedArrayType(T, Quals); @@ -323,16 +323,16 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, ImpCastExprToType(E, UnqualT, CK_NoOp, CastCategory(E)); } } - + // If this is an unevaluated operand, clear out the set of // declaration references we have been computing and eliminate any // temporaries introduced in its computation. if (isUnevaluatedOperand) ExprEvalContexts.back().Context = Unevaluated; - + return Owned(new (Context) CXXTypeidExpr(TypeInfoType.withConst(), E, - SourceRange(TypeidLoc, RParenLoc))); + SourceRange(TypeidLoc, RParenLoc))); } /// ActOnCXXTypeidOfType - Parse typeid( type-id ) or typeid (expression); @@ -351,9 +351,9 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, if (!CXXTypeInfoDecl) return ExprError(Diag(OpLoc, diag::err_need_header_before_typeid)); } - + QualType TypeInfoType = Context.getTypeDeclType(CXXTypeInfoDecl); - + if (isType) { // The operand is a type; handle it as such. TypeSourceInfo *TInfo = 0; @@ -361,14 +361,14 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, &TInfo); if (T.isNull()) return ExprError(); - + if (!TInfo) TInfo = Context.getTrivialTypeSourceInfo(T, OpLoc); return BuildCXXTypeId(TypeInfoType, OpLoc, TInfo, RParenLoc); } - // The operand is an expression. + // The operand is an expression. return BuildCXXTypeId(TypeInfoType, OpLoc, (Expr*)TyOrExpr, RParenLoc); } @@ -400,7 +400,7 @@ ExprResult Sema::BuildCXXUuidof(QualType TypeInfoType, if (!GetUuidAttrOfType(Operand->getType())) return ExprError(Diag(TypeidLoc, diag::err_uuidof_without_guid)); } - + // FIXME: add __uuidof semantic analysis for type operand. return Owned(new (Context) CXXUuidofExpr(TypeInfoType.withConst(), Operand, @@ -413,21 +413,21 @@ ExprResult Sema::BuildCXXUuidof(QualType TypeInfoType, Expr *E, SourceLocation RParenLoc) { if (!E->getType()->isDependentType()) { - if (!GetUuidAttrOfType(E->getType()) && + if (!GetUuidAttrOfType(E->getType()) && !E->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) return ExprError(Diag(TypeidLoc, diag::err_uuidof_without_guid)); } // FIXME: add __uuidof semantic analysis for type operand. return Owned(new (Context) CXXUuidofExpr(TypeInfoType.withConst(), E, - SourceRange(TypeidLoc, RParenLoc))); + SourceRange(TypeidLoc, RParenLoc))); } /// ActOnCXXUuidof - Parse __uuidof( type-id ) or __uuidof (expression); ExprResult Sema::ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc) { - // If MSVCGuidDecl has not been cached, do the lookup. + // If MSVCGuidDecl has not been cached, do the lookup. if (!MSVCGuidDecl) { IdentifierInfo *GuidII = &PP.getIdentifierTable().get("_GUID"); LookupResult R(*this, GuidII, SourceLocation(), LookupTagName); @@ -435,10 +435,10 @@ Sema::ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, MSVCGuidDecl = R.getAsSingle(); if (!MSVCGuidDecl) return ExprError(Diag(OpLoc, diag::err_need_header_before_ms_uuidof)); - } - + } + QualType GuidType = Context.getTypeDeclType(MSVCGuidDecl); - + if (isType) { // The operand is a type; handle it as such. TypeSourceInfo *TInfo = 0; @@ -446,14 +446,14 @@ Sema::ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, &TInfo); if (T.isNull()) return ExprError(); - + if (!TInfo) TInfo = Context.getTrivialTypeSourceInfo(T, OpLoc); return BuildCXXUuidof(GuidType, OpLoc, TInfo, RParenLoc); } - // The operand is an expression. + // The operand is an expression. return BuildCXXUuidof(GuidType, OpLoc, (Expr*)TyOrExpr, RParenLoc); } @@ -486,12 +486,12 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) { // A throw-expression initializes a temporary object, called the exception // object, the type of which is determined by removing any top-level // cv-qualifiers from the static type of the operand of throw and adjusting - // the type from "array of T" or "function returning T" to "pointer to T" + // the type from "array of T" or "function returning T" to "pointer to T" // or "pointer to function returning T", [...] if (E->getType().hasQualifiers()) ImpCastExprToType(E, E->getType().getUnqualifiedType(), CK_NoOp, CastCategory(E)); - + DefaultFunctionArrayConversion(E); // If the type of the exception would be an incomplete type or a pointer @@ -523,7 +523,7 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) { InitializedEntity Entity = InitializedEntity::InitializeException(ThrowLoc, E->getType(), /*NRVO=*/false); - ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOVariable, + ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOVariable, QualType(), E); if (Res.isInvalid()) return true; @@ -547,7 +547,7 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) { if (RD->hasTrivialDestructor()) return false; - CXXDestructorDecl *Destructor + CXXDestructorDecl *Destructor = const_cast(LookupDestructor(RD)); if (!Destructor) return false; @@ -580,7 +580,7 @@ Sema::ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation RParenLoc) { if (!TypeRep) return ExprError(); - + TypeSourceInfo *TInfo; QualType Ty = GetTypeFromParser(TypeRep, &TInfo); if (!TInfo) @@ -622,7 +622,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, PDiag(diag::err_invalid_incomplete_type_use) << FullRange)) return ExprError(); - + if (RequireNonAbstractType(TyBeginLoc, Ty, diag::err_allocation_of_abstract_type)) return ExprError(); @@ -637,7 +637,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, CastKind Kind = CK_Invalid; ExprValueKind VK = VK_RValue; CXXCastPath BasePath; - if (CheckCastTypes(TInfo->getTypeLoc().getSourceRange(), Ty, Exprs[0], + if (CheckCastTypes(TInfo->getTypeLoc().getSourceRange(), Ty, Exprs[0], Kind, VK, BasePath, /*FunctionalStyle=*/true)) return ExprError(); @@ -655,7 +655,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, InitializationKind Kind = NumExprs ? InitializationKind::CreateDirect(TyBeginLoc, LParenLoc, RParenLoc) - : InitializationKind::CreateValue(TyBeginLoc, + : InitializationKind::CreateValue(TyBeginLoc, LParenLoc, RParenLoc); InitializationSequence InitSeq(*this, Entity, Kind, Exprs, NumExprs); ExprResult Result = InitSeq.Perform(*this, Entity, Kind, move(exprs)); @@ -673,7 +673,7 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, ExprResult Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, - SourceLocation PlacementRParen, SourceRange TypeIdParens, + SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, SourceLocation ConstructorLParen, MultiExprArg ConstructorArgs, SourceLocation ConstructorRParen) { @@ -715,10 +715,10 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, QualType AllocType = TInfo->getType(); if (D.isInvalidType()) return ExprError(); - + if (!TInfo) TInfo = Context.getTrivialTypeSourceInfo(AllocType); - + return BuildCXXNew(StartLoc, UseGlobal, PlacementLParen, move(PlacementArgs), @@ -766,9 +766,9 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, // C++ 5.3.4p6: "The expression in a direct-new-declarator shall have integral // or enumeration type with a non-negative value." if (ArraySize && !ArraySize->isTypeDependent()) { - + QualType SizeType = ArraySize->getType(); - + ExprResult ConvertedSize = ConvertToIntegralOrEnumerationType(StartLoc, ArraySize, PDiag(diag::err_array_size_not_integral), @@ -778,16 +778,16 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, PDiag(diag::note_array_size_conversion), PDiag(diag::err_array_size_ambiguous_conversion), PDiag(diag::note_array_size_conversion), - PDiag(getLangOptions().CPlusPlus0x? 0 + PDiag(getLangOptions().CPlusPlus0x? 0 : diag::ext_array_size_conversion)); if (ConvertedSize.isInvalid()) return ExprError(); - + ArraySize = ConvertedSize.take(); SizeType = ArraySize->getType(); if (!SizeType->isIntegralOrUnscopedEnumerationType()) return ExprError(); - + // Let's see if this is a constant < 0. If so, we reject it out of hand. // We don't care about special rules, so we tell the machinery it's not // evaluated - it gives us a result in more cases. @@ -795,17 +795,17 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, llvm::APSInt Value; if (ArraySize->isIntegerConstantExpr(Value, Context, 0, false)) { if (Value < llvm::APSInt( - llvm::APInt::getNullValue(Value.getBitWidth()), + llvm::APInt::getNullValue(Value.getBitWidth()), Value.isUnsigned())) return ExprError(Diag(ArraySize->getSourceRange().getBegin(), diag::err_typecheck_negative_array_size) << ArraySize->getSourceRange()); - + if (!AllocType->isDependentType()) { unsigned ActiveSizeBits = ConstantArrayType::getNumAddressingBits(Context, AllocType, Value); if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context)) { - Diag(ArraySize->getSourceRange().getBegin(), + Diag(ArraySize->getSourceRange().getBegin(), diag::err_array_too_large) << Value.toString(10) << ArraySize->getSourceRange(); @@ -818,11 +818,11 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, << ArraySize->getSourceRange() << FixItHint::CreateRemoval(TypeIdParens.getBegin()) << FixItHint::CreateRemoval(TypeIdParens.getEnd()); - + TypeIdParens = SourceRange(); } } - + ImpCastExprToType(ArraySize, Context.getSizeType(), CK_IntegralCast); } @@ -831,7 +831,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, FunctionDecl *OperatorDelete = 0; Expr **PlaceArgs = (Expr**)PlacementArgs.get(); unsigned NumPlaceArgs = PlacementArgs.size(); - + if (!AllocType->isDependentType() && !Expr::hasAnyTypeDependentArguments(PlaceArgs, NumPlaceArgs) && FindAllocationFunctions(StartLoc, @@ -842,21 +842,21 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, llvm::SmallVector AllPlaceArgs; if (OperatorNew) { // Add default arguments, if any. - const FunctionProtoType *Proto = + const FunctionProtoType *Proto = OperatorNew->getType()->getAs(); - VariadicCallType CallType = + VariadicCallType CallType = Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply; - + if (GatherArgumentsForCall(PlacementLParen, OperatorNew, - Proto, 1, PlaceArgs, NumPlaceArgs, + Proto, 1, PlaceArgs, NumPlaceArgs, AllPlaceArgs, CallType)) return ExprError(); - + NumPlaceArgs = AllPlaceArgs.size(); if (NumPlaceArgs > 0) PlaceArgs = &AllPlaceArgs[0]; } - + bool Init = ConstructorLParen.isValid(); // --- Choosing a constructor --- CXXConstructorDecl *Constructor = 0; @@ -868,7 +868,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, if (NumConsArgs && (ResultType->isArrayType() || ArraySize)) { SourceRange InitRange(ConsArgs[0]->getLocStart(), ConsArgs[NumConsArgs - 1]->getLocEnd()); - + Diag(StartLoc, diag::err_new_array_init_args) << InitRange; return ExprError(); } @@ -883,21 +883,21 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, // initialized (8.5); if no initialization is performed, // the object has indeterminate value = !Init? InitializationKind::CreateDefault(TypeRange.getBegin()) - // - Otherwise, the new-initializer is interpreted according to the + // - Otherwise, the new-initializer is interpreted according to the // initialization rules of 8.5 for direct-initialization. : InitializationKind::CreateDirect(TypeRange.getBegin(), - ConstructorLParen, + ConstructorLParen, ConstructorRParen); - + InitializedEntity Entity = InitializedEntity::InitializeNew(StartLoc, AllocType); InitializationSequence InitSeq(*this, Entity, Kind, ConsArgs, NumConsArgs); - ExprResult FullInit = InitSeq.Perform(*this, Entity, Kind, + ExprResult FullInit = InitSeq.Perform(*this, Entity, Kind, move(ConstructorArgs)); if (FullInit.isInvalid()) return ExprError(); - - // FullInit is our initializer; walk through it to determine if it's a + + // FullInit is our initializer; walk through it to determine if it's a // constructor call, which CXXNewExpr handles directly. if (Expr *FullInitExpr = (Expr *)FullInit.get()) { if (CXXBindTemporaryExpr *Binder @@ -917,12 +917,12 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, } else { // No initialization required. } - + // Take the converted arguments and use them for the new expression. NumConsArgs = ConvertedConstructorArgs.size(); ConsArgs = (Expr **)ConvertedConstructorArgs.take(); } - + // Mark the new and delete operators as referenced. if (OperatorNew) MarkDeclarationReferenced(StartLoc, OperatorNew); @@ -930,10 +930,10 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, MarkDeclarationReferenced(StartLoc, OperatorDelete); // FIXME: Also check that the destructor is accessible. (C++ 5.3.4p16) - + PlacementArgs.release(); ConstructorArgs.release(); - + return Owned(new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew, PlaceArgs, NumPlaceArgs, TypeIdParens, ArraySize, Constructor, Init, @@ -969,7 +969,7 @@ bool Sema::CheckAllocatedType(QualType AllocType, SourceLocation Loc, else if (AllocType->isVariablyModifiedType()) return Diag(Loc, diag::err_variably_modified_new_type) << AllocType; - + return false; } @@ -1099,7 +1099,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // same number of parameters and, after parameter transformations // (8.3.5), all parameter types except the first are // identical. [...] - // + // // To perform this comparison, we compute the function type that // the deallocation function should have, and use that type both // for template argument deduction and for comparison purposes. @@ -1111,7 +1111,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, = OperatorNew->getType()->getAs(); llvm::SmallVector ArgTypes; - ArgTypes.push_back(Context.VoidPtrTy); + ArgTypes.push_back(Context.VoidPtrTy); for (unsigned I = 1, N = Proto->getNumArgs(); I < N; ++I) ArgTypes.push_back(Proto->getArgType(I)); @@ -1123,11 +1123,11 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, ArgTypes.size(), EPI); } - for (LookupResult::iterator D = FoundDelete.begin(), + for (LookupResult::iterator D = FoundDelete.begin(), DEnd = FoundDelete.end(); D != DEnd; ++D) { FunctionDecl *Fn = 0; - if (FunctionTemplateDecl *FnTmpl + if (FunctionTemplateDecl *FnTmpl = dyn_cast((*D)->getUnderlyingDecl())) { // Perform template argument deduction to try to match the // expected function type. @@ -1144,7 +1144,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // C++ [expr.new]p20: // [...] Any non-placement deallocation function matches a // non-placement allocation function. [...] - for (LookupResult::iterator D = FoundDelete.begin(), + for (LookupResult::iterator D = FoundDelete.begin(), DEnd = FoundDelete.end(); D != DEnd; ++D) { if (FunctionDecl *Fn = dyn_cast((*D)->getUnderlyingDecl())) @@ -1169,7 +1169,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, if (NumPlaceArgs && getLangOptions().CPlusPlus0x && isNonPlacementDeallocationFunction(OperatorDelete)) { Diag(StartLoc, diag::err_placement_new_non_placement_delete) - << SourceRange(PlaceArgs[0]->getLocStart(), + << SourceRange(PlaceArgs[0]->getLocStart(), PlaceArgs[NumPlaceArgs - 1]->getLocEnd()); Diag(OperatorDelete->getLocation(), diag::note_previous_decl) << DeleteName; @@ -1203,7 +1203,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, R.suppressDiagnostics(); OverloadCandidateSet Candidates(StartLoc); - for (LookupResult::iterator Alloc = R.begin(), AllocEnd = R.end(); + for (LookupResult::iterator Alloc = R.begin(), AllocEnd = R.end(); Alloc != AllocEnd; ++Alloc) { // Even member operator new/delete are implicitly treated as // static, so don't use AddMemberCandidate. @@ -1242,7 +1242,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, Owned(Args[i])); if (Result.isInvalid()) return true; - + Args[i] = Result.takeAs(); } Operator = FnDecl; @@ -1287,18 +1287,18 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, void Sema::DeclareGlobalNewDelete() { if (GlobalNewDeleteDeclared) return; - + // C++ [basic.std.dynamic]p2: - // [...] The following allocation and deallocation functions (18.4) are - // implicitly declared in global scope in each translation unit of a + // [...] The following allocation and deallocation functions (18.4) are + // implicitly declared in global scope in each translation unit of a // program - // + // // void* operator new(std::size_t) throw(std::bad_alloc); - // void* operator new[](std::size_t) throw(std::bad_alloc); - // void operator delete(void*) throw(); + // void* operator new[](std::size_t) throw(std::bad_alloc); + // void operator delete(void*) throw(); // void operator delete[](void*) throw(); // - // These implicit declarations introduce only the function names operator + // These implicit declarations introduce only the function names operator // new, operator new[], operator delete, operator delete[]. // // Here, we need to refer to std::bad_alloc, so we will implicitly declare @@ -1308,14 +1308,14 @@ void Sema::DeclareGlobalNewDelete() { if (!StdBadAlloc) { // The "std::bad_alloc" class has not yet been declared, so build it // implicitly. - StdBadAlloc = CXXRecordDecl::Create(Context, TTK_Class, - getOrCreateStdNamespace(), - SourceLocation(), - &PP.getIdentifierTable().get("bad_alloc"), + StdBadAlloc = CXXRecordDecl::Create(Context, TTK_Class, + getOrCreateStdNamespace(), + SourceLocation(), + &PP.getIdentifierTable().get("bad_alloc"), SourceLocation(), 0); getStdBadAlloc()->setImplicit(true); } - + GlobalNewDeleteDeclared = true; QualType VoidPtr = Context.getPointerType(Context.VoidTy); @@ -1365,7 +1365,7 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, } QualType BadAllocType; - bool HasBadAllocExceptionSpec + bool HasBadAllocExceptionSpec = (Name.getCXXOverloadedOperator() == OO_New || Name.getCXXOverloadedOperator() == OO_Array_New); if (HasBadAllocExceptionSpec) { @@ -1379,17 +1379,17 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, EPI.NumExceptions = 1; EPI.Exceptions = &BadAllocType; } - + QualType FnType = Context.getFunctionType(Return, &Argument, 1, EPI); FunctionDecl *Alloc = FunctionDecl::Create(Context, GlobalCtx, SourceLocation(), Name, FnType, /*TInfo=*/0, SC_None, SC_None, false, true); Alloc->setImplicit(); - + if (AddMallocAttr) Alloc->addAttr(::new (Context) MallocAttr(SourceLocation(), Context)); - + ParmVarDecl *Param = ParmVarDecl::Create(Context, Alloc, SourceLocation(), 0, Argument, /*TInfo=*/0, SC_None, @@ -1408,7 +1408,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, LookupResult Found(*this, Name, StartLoc, LookupOrdinaryName); // Try to find operator delete/operator delete[] in class scope. LookupQualifiedName(Found, RD); - + if (Found.isAmbiguous()) return true; @@ -1452,7 +1452,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, if (!Found.empty()) { Diag(StartLoc, diag::err_no_suitable_delete_member_function_found) << Name << RD; - + for (LookupResult::iterator F = Found.begin(), FEnd = Found.end(); F != FEnd; ++F) Diag((*F)->getUnderlyingDecl()->getLocation(), @@ -1464,7 +1464,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, // Look for a global declaration. DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); - + CXXNullPtrLiteralExpr Null(Context.VoidPtrTy, SourceLocation()); Expr* DeallocArgs[1]; DeallocArgs[0] = &Null; @@ -1497,14 +1497,14 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, QualType Type = Ex->getType(); if (const RecordType *Record = Type->getAs()) { - if (RequireCompleteType(StartLoc, Type, + if (RequireCompleteType(StartLoc, Type, PDiag(diag::err_delete_incomplete_class_type))) return ExprError(); - + llvm::SmallVector ObjectPtrConversions; CXXRecordDecl *RD = cast(Record->getDecl()); - const UnresolvedSetImpl *Conversions = RD->getVisibleConversionFunctions(); + const UnresolvedSetImpl *Conversions = RD->getVisibleConversionFunctions(); for (UnresolvedSetImpl::iterator I = Conversions->begin(), E = Conversions->end(); I != E; ++I) { NamedDecl *D = I.getDecl(); @@ -1514,9 +1514,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // Skip over templated conversion functions; they aren't considered. if (isa(D)) continue; - + CXXConversionDecl *Conv = cast(D); - + QualType ConvType = Conv->getConversionType().getNonReferenceType(); if (const PointerType *ConvPtrType = ConvType->getAs()) if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType()) @@ -1547,7 +1547,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, QualType Pointee = Type->getAs()->getPointeeType(); if (Pointee->isVoidType() && !isSFINAEContext()) { - // The C++ standard bans deleting a pointer to a non-object type, which + // The C++ standard bans deleting a pointer to a non-object type, which // effectively bans deletion of "void*". However, most compilers support // this, so we treat it as a warning unless we're in a SFINAE context. Diag(StartLoc, diag::ext_delete_void_ptr_operand) @@ -1562,11 +1562,11 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, return ExprError(); // C++ [expr.delete]p2: - // [Note: a pointer to a const type can be the operand of a - // delete-expression; it is not necessary to cast away the constness - // (5.2.11) of the pointer expression before it is used as the operand + // [Note: a pointer to a const type can be the operand of a + // delete-expression; it is not necessary to cast away the constness + // (5.2.11) of the pointer expression before it is used as the operand // of the delete-expression. ] - ImpCastExprToType(Ex, Context.getPointerType(Context.VoidTy), + ImpCastExprToType(Ex, Context.getPointerType(Context.VoidTy), CK_NoOp); if (Pointee->isArrayType() && !ArrayForm) { @@ -1583,10 +1583,10 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, if (const RecordType *RT = PointeeElem->getAs()) { CXXRecordDecl *RD = cast(RT->getDecl()); - if (!UseGlobal && + if (!UseGlobal && FindDeallocationFunction(StartLoc, RD, DeleteName, OperatorDelete)) return ExprError(); - + if (!RD->hasTrivialDestructor()) if (CXXDestructorDecl *Dtor = LookupDestructor(RD)) { MarkDeclarationReferenced(StartLoc, @@ -1594,7 +1594,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, DiagnoseUseOfDecl(Dtor, StartLoc); } } - + if (!OperatorDelete) { // Look for a global declaration. DeclareGlobalNewDelete(); @@ -1621,25 +1621,25 @@ ExprResult Sema::CheckConditionVariable(VarDecl *ConditionVar, SourceLocation StmtLoc, bool ConvertToBoolean) { QualType T = ConditionVar->getType(); - + // C++ [stmt.select]p2: // The declarator shall not specify a function or an array. if (T->isFunctionType()) - return ExprError(Diag(ConditionVar->getLocation(), + return ExprError(Diag(ConditionVar->getLocation(), diag::err_invalid_use_of_function_type) << ConditionVar->getSourceRange()); else if (T->isArrayType()) - return ExprError(Diag(ConditionVar->getLocation(), + return ExprError(Diag(ConditionVar->getLocation(), diag::err_invalid_use_of_array_type) << ConditionVar->getSourceRange()); Expr *Condition = DeclRefExpr::Create(Context, 0, SourceRange(), ConditionVar, - ConditionVar->getLocation(), + ConditionVar->getLocation(), ConditionVar->getType().getNonReferenceType(), VK_LValue); if (ConvertToBoolean && CheckBooleanCondition(Condition, StmtLoc)) return ExprError(); - + return Owned(Condition); } @@ -1687,7 +1687,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) { return false; } -static ExprResult BuildCXXCastArgument(Sema &S, +static ExprResult BuildCXXCastArgument(Sema &S, SourceLocation CastLoc, QualType Ty, CastKind Kind, @@ -1698,35 +1698,35 @@ static ExprResult BuildCXXCastArgument(Sema &S, default: assert(0 && "Unhandled cast kind!"); case CK_ConstructorConversion: { ASTOwningVector ConstructorArgs(S); - + if (S.CompleteConstructorCall(cast(Method), MultiExprArg(&From, 1), CastLoc, ConstructorArgs)) return ExprError(); - - ExprResult Result = - S.BuildCXXConstructExpr(CastLoc, Ty, cast(Method), + + ExprResult Result = + S.BuildCXXConstructExpr(CastLoc, Ty, cast(Method), move_arg(ConstructorArgs), /*ZeroInit*/ false, CXXConstructExpr::CK_Complete, SourceRange()); if (Result.isInvalid()) return ExprError(); - + return S.MaybeBindToTemporary(Result.takeAs()); } - + case CK_UserDefinedConversion: { assert(!From->getType()->isPointerType() && "Arg can't have pointer type!"); - + // Create an implicit call expr that calls it. ExprResult Result = S.BuildCXXMemberCallExpr(From, FoundDecl, Method); if (Result.isInvalid()) return ExprError(); - + return S.MaybeBindToTemporary(Result.get()); } } -} +} /// PerformImplicitConversion - Perform an implicit conversion of the /// expression From to the type ToType using the pre-computed implicit @@ -1746,13 +1746,13 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, break; case ImplicitConversionSequence::UserDefinedConversion: { - + FunctionDecl *FD = ICS.UserDefined.ConversionFunction; CastKind CastKind; QualType BeforeToType; if (const CXXConversionDecl *Conv = dyn_cast(FD)) { CastKind = CK_UserDefinedConversion; - + // If the user-defined conversion is specified by a conversion function, // the initial standard conversion sequence converts the source type to // the implicit object parameter of the conversion function. @@ -1762,21 +1762,21 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, CastKind = CK_ConstructorConversion; // Do no conversion if dealing with ... for the first conversion. if (!ICS.UserDefined.EllipsisConversion) { - // If the user-defined conversion is specified by a constructor, the + // If the user-defined conversion is specified by a constructor, the // initial standard conversion sequence converts the source type to the // type required by the argument of the constructor BeforeToType = Ctor->getParamDecl(0)->getType().getNonReferenceType(); } - } + } // Watch out for elipsis conversion. if (!ICS.UserDefined.EllipsisConversion) { - if (PerformImplicitConversion(From, BeforeToType, + if (PerformImplicitConversion(From, BeforeToType, ICS.UserDefined.Before, AA_Converting, CStyle)) return true; } - - ExprResult CastArg + + ExprResult CastArg = BuildCXXCastArgument(*this, From->getLocStart(), ToType.getNonReferenceType(), @@ -1798,7 +1798,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, PDiag(diag::err_typecheck_ambiguous_condition) << From->getSourceRange()); return true; - + case ImplicitConversionSequence::EllipsisConversion: assert(false && "Cannot perform an ellipsis conversion"); return false; @@ -1834,7 +1834,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, ASTOwningVector ConstructorArgs(*this); if (CompleteConstructorCall(cast(SCS.CopyConstructor), MultiExprArg(*this, &From, 1), - /*FIXME:ConstructLoc*/SourceLocation(), + /*FIXME:ConstructLoc*/SourceLocation(), ConstructorArgs)) return true; ExprResult FromResult = @@ -1874,7 +1874,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, if (DiagnoseUseOfDecl(Fn, From->getSourceRange().getBegin())) return true; - + From = FixOverloadedFunctionReference(From, Found, Fn); FromType = From->getType(); } @@ -1926,11 +1926,11 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, // If both sides are functions (or pointers/references to them), there could // be incompatible exception declarations. if (CheckExceptionSpecCompatibility(From, ToType)) - return true; - + return true; + ImpCastExprToType(From, ToType, CK_NoOp); break; - + case ICK_Integral_Promotion: case ICK_Integral_Conversion: ImpCastExprToType(From, ToType, CK_IntegralCast); @@ -1979,7 +1979,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, << From->getType() << ToType << Action << From->getSourceRange(); } - + CastKind Kind = CK_Invalid; CXXCastPath BasePath; if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle)) @@ -1987,7 +1987,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath); break; } - + case ICK_Pointer_Member: { CastKind Kind = CK_Invalid; CXXCastPath BasePath; @@ -2009,17 +2009,17 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, case Type::STK_IntegralComplex: Kind = CK_IntegralComplexToBoolean; break; case Type::STK_FloatingComplex: Kind = CK_FloatingComplexToBoolean; break; } - + ImpCastExprToType(From, Context.BoolTy, Kind); break; } case ICK_Derived_To_Base: { CXXCastPath BasePath; - if (CheckDerivedToBaseConversion(From->getType(), + if (CheckDerivedToBaseConversion(From->getType(), ToType.getNonReferenceType(), From->getLocStart(), - From->getSourceRange(), + From->getSourceRange(), &BasePath, CStyle)) return true; @@ -2037,7 +2037,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, case ICK_Vector_Splat: ImpCastExprToType(From, ToType, CK_VectorSplat); break; - + case ICK_Complex_Real: // Case 1. x -> _Complex y if (const ComplexType *ToComplex = ToType->getAs()) { @@ -2086,7 +2086,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, } } break; - + case ICK_Lvalue_To_Rvalue: case ICK_Array_To_Pointer: case ICK_Function_To_Pointer: @@ -2357,7 +2357,7 @@ ExprResult Sema::BuildUnaryTypeTrait(UnaryTypeTrait UTT, TypeSourceInfo *TSInfo, SourceLocation RParen) { QualType T = TSInfo->getType(); - + // According to http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html // all traits except __is_class, __is_enum and __is_union require a the type // to be complete, an array of unknown bound, or void. @@ -2409,7 +2409,7 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT, // Base is a base class of Derived without regard to cv-qualifiers or // Base and Derived are not unions and name the same class type without // regard to cv-qualifiers. - if (Self.IsDerivedFrom(RhsT, LhsT) || + if (Self.IsDerivedFrom(RhsT, LhsT) || (!LhsT->isUnionType() && !RhsT->isUnionType() && LhsT->getAsCXXRecordDecl() == RhsT->getAsCXXRecordDecl())) return true; @@ -2429,7 +2429,7 @@ ExprResult Sema::BuildBinaryTypeTrait(BinaryTypeTrait BTT, SourceLocation RParen) { QualType LhsT = LhsTSInfo->getType(); QualType RhsT = RhsTSInfo->getType(); - + if (BTT == BTT_IsBaseOf) { // C++0x [meta.rel]p2 // If Base and Derived are class types and are different types @@ -2558,9 +2558,9 @@ QualType Sema::CheckPointerToMemberOperands(Expr *&lex, Expr *&rex, // C++0x [expr.mptr.oper]p6: // In a .* expression whose object expression is an rvalue, the program is - // ill-formed if the second operand is a pointer to member function with - // ref-qualifier &. In a ->* expression or in a .* expression whose object - // expression is an lvalue, the program is ill-formed if the second operand + // ill-formed if the second operand is a pointer to member function with + // ref-qualifier &. In a ->* expression or in a .* expression whose object + // expression is an lvalue, the program is ill-formed if the second operand // is a pointer to member function with ref-qualifier &&. if (const FunctionProtoType *Proto = Result->getAs()) { switch (Proto->getRefQualifier()) { @@ -2573,7 +2573,7 @@ QualType Sema::CheckPointerToMemberOperands(Expr *&lex, Expr *&rex, Diag(Loc, diag::err_pointer_to_member_oper_value_classify) << RType << 1 << lex->getSourceRange(); break; - + case RQ_RValue: if (isIndirect || !lex->Classify(Context).isRValue()) Diag(Loc, diag::err_pointer_to_member_oper_value_classify) @@ -2581,7 +2581,7 @@ QualType Sema::CheckPointerToMemberOperands(Expr *&lex, Expr *&rex, break; } } - + // C++ [expr.mptr.oper]p6: // The result of a .* expression whose second operand is a pointer // to a data member is of the same value category as its @@ -2612,8 +2612,8 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, QualType &ToType) { HaveConversion = false; ToType = To->getType(); - - InitializationKind Kind = InitializationKind::CreateCopy(To->getLocStart(), + + InitializationKind Kind = InitializationKind::CreateCopy(To->getLocStart(), SourceLocation()); // C++0x 5.16p3 // The process for determining whether an operand expression E1 of type T1 @@ -2627,14 +2627,14 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, // conversion the reference must bind directly to E1. QualType T = Self.Context.getLValueReferenceType(ToType); InitializedEntity Entity = InitializedEntity::InitializeTemporary(T); - + InitializationSequence InitSeq(Self, Entity, Kind, &From, 1); if (InitSeq.isDirectReferenceBinding()) { ToType = T; HaveConversion = true; return false; } - + if (InitSeq.isAmbiguous()) return InitSeq.Diagnose(Self, Entity, Kind, &From, 1); } @@ -2646,9 +2646,9 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, QualType TTy = To->getType(); const RecordType *FRec = FTy->getAs(); const RecordType *TRec = TTy->getAs(); - bool FDerivedFromT = FRec && TRec && FRec != TRec && + bool FDerivedFromT = FRec && TRec && FRec != TRec && Self.IsDerivedFrom(FTy, TTy); - if (FRec && TRec && + if (FRec && TRec && (FRec == TRec || FDerivedFromT || Self.IsDerivedFrom(TTy, FTy))) { // E1 can be converted to match E2 if the class of T2 is the // same type as, or a base class of, the class of T1, and @@ -2661,28 +2661,28 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, HaveConversion = true; return false; } - + if (InitSeq.isAmbiguous()) return InitSeq.Diagnose(Self, Entity, Kind, &From, 1); - } + } } - + return false; } - + // -- Otherwise: E1 can be converted to match E2 if E1 can be // implicitly converted to the type that expression E2 would have - // if E2 were converted to an rvalue (or the type it has, if E2 is + // if E2 were converted to an rvalue (or the type it has, if E2 is // an rvalue). // // This actually refers very narrowly to the lvalue-to-rvalue conversion, not // to the array-to-pointer or function-to-pointer conversions. if (!TTy->getAs()) TTy = TTy.getUnqualifiedType(); - + InitializedEntity Entity = InitializedEntity::InitializeTemporary(TTy); InitializationSequence InitSeq(Self, Entity, Kind, &From, 1); - HaveConversion = InitSeq.getKind() != InitializationSequence::FailedSequence; + HaveConversion = InitSeq.getKind() != InitializationSequence::FailedSequence; ToType = TTy; if (InitSeq.isAmbiguous()) return InitSeq.Diagnose(Self, Entity, Kind, &From, 1); @@ -2743,7 +2743,7 @@ static bool ConvertForConditional(Sema &Self, Expr *&E, QualType T) { ExprResult Result = InitSeq.Perform(Self, Entity, Kind, MultiExprArg(&E, 1)); if (Result.isInvalid()) return true; - + E = Result.takeAs(); return false; } @@ -2822,7 +2822,7 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, // Otherwise, if the second and third operand have different types, and // either has (cv) class type, and attempt is made to convert each of those // operands to the other. - if (!Context.hasSameType(LTy, RTy) && + if (!Context.hasSameType(LTy, RTy) && (LTy->isRecordType() || RTy->isRecordType())) { ImplicitConversionSequence ICSLeftToRight, ICSRightToLeft; // These return true if a single direction is already ambiguous. @@ -2832,7 +2832,7 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, return QualType(); if (TryClassUnification(*this, RHS, LHS, QuestionLoc, HaveR2L, R2LType)) return QualType(); - + // If both can be converted, [...] the program is ill-formed. if (HaveL2R && HaveR2L) { Diag(QuestionLoc, diag::err_conditional_ambiguous) @@ -2905,18 +2905,18 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, if (LTy->isRecordType()) { // The operands have class type. Make a temporary copy. InitializedEntity Entity = InitializedEntity::InitializeTemporary(LTy); - ExprResult LHSCopy = PerformCopyInitialization(Entity, - SourceLocation(), + ExprResult LHSCopy = PerformCopyInitialization(Entity, + SourceLocation(), Owned(LHS)); if (LHSCopy.isInvalid()) return QualType(); - - ExprResult RHSCopy = PerformCopyInitialization(Entity, - SourceLocation(), + + ExprResult RHSCopy = PerformCopyInitialization(Entity, + SourceLocation(), Owned(RHS)); if (RHSCopy.isInvalid()) return QualType(); - + LHS = LHSCopy.takeAs(); RHS = RHSCopy.takeAs(); } @@ -2925,7 +2925,7 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, } // Extension: conditional operator involving vector types. - if (LTy->isVectorType() || RTy->isVectorType()) + if (LTy->isVectorType() || RTy->isVectorType()) return CheckVectorOperands(QuestionLoc, LHS, RHS); // -- The second and third operands have arithmetic or enumeration type; @@ -2951,14 +2951,14 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, isSFINAEContext()? 0 : &NonStandardCompositeType); if (!Composite.isNull()) { if (NonStandardCompositeType) - Diag(QuestionLoc, + Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands_nonstandard) << LTy << RTy << Composite << LHS->getSourceRange() << RHS->getSourceRange(); - + return Composite; } - + // Similarly, attempt to find composite type of two objective-c pointers. Composite = FindCompositeObjCPointerType(LHS, RHS, QuestionLoc); if (!Composite.isNull()) @@ -2984,12 +2984,12 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, /// a non-standard (but still sane) composite type to which both expressions /// can be converted. When such a type is chosen, \c *NonStandardCompositeType /// will be set true. -QualType Sema::FindCompositePointerType(SourceLocation Loc, +QualType Sema::FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool *NonStandardCompositeType) { if (NonStandardCompositeType) *NonStandardCompositeType = false; - + assert(getLangOptions().CPlusPlus && "This function assumes C++"); QualType T1 = E1->getType(), T2 = E2->getType(); @@ -3040,20 +3040,20 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, ContainingClassVector MemberOfClass; QualType Composite1 = Context.getCanonicalType(T1), Composite2 = Context.getCanonicalType(T2); - unsigned NeedConstBefore = 0; + unsigned NeedConstBefore = 0; do { const PointerType *Ptr1, *Ptr2; if ((Ptr1 = Composite1->getAs()) && (Ptr2 = Composite2->getAs())) { Composite1 = Ptr1->getPointeeType(); Composite2 = Ptr2->getPointeeType(); - + // If we're allowed to create a non-standard composite type, keep track - // of where we need to fill in additional 'const' qualifiers. + // of where we need to fill in additional 'const' qualifiers. if (NonStandardCompositeType && Composite1.getCVRQualifiers() != Composite2.getCVRQualifiers()) NeedConstBefore = QualifierUnion.size(); - + QualifierUnion.push_back( Composite1.getCVRQualifiers() | Composite2.getCVRQualifiers()); MemberOfClass.push_back(std::make_pair((const Type *)0, (const Type *)0)); @@ -3065,13 +3065,13 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, (MemPtr2 = Composite2->getAs())) { Composite1 = MemPtr1->getPointeeType(); Composite2 = MemPtr2->getPointeeType(); - + // If we're allowed to create a non-standard composite type, keep track - // of where we need to fill in additional 'const' qualifiers. + // of where we need to fill in additional 'const' qualifiers. if (NonStandardCompositeType && Composite1.getCVRQualifiers() != Composite2.getCVRQualifiers()) NeedConstBefore = QualifierUnion.size(); - + QualifierUnion.push_back( Composite1.getCVRQualifiers() | Composite2.getCVRQualifiers()); MemberOfClass.push_back(std::make_pair(MemPtr1->getClass(), @@ -3087,7 +3087,7 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, if (NeedConstBefore && NonStandardCompositeType) { // Extension: Add 'const' to qualifiers that come before the first qualifier - // mismatch, so that our (non-standard!) composite type meets the + // mismatch, so that our (non-standard!) composite type meets the // requirements of C++ [conv.qual]p4 bullet 3. for (unsigned I = 0; I != NeedConstBefore; ++I) { if ((QualifierUnion[I] & Qualifiers::Const) == 0) { @@ -3096,7 +3096,7 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, } } } - + // Rewrap the composites as pointers or member pointers with the union CVRs. ContainingClassVector::reverse_iterator MOC = MemberOfClass.rbegin(); @@ -3159,7 +3159,7 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, if (E2Result.isInvalid()) return QualType(); E2 = E2Result.takeAs(); - + return Composite1; } @@ -3170,28 +3170,28 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, InitializationSequence E2ToC2(*this, Entity2, Kind, &E2, 1); if (!E1ToC2 || !E2ToC2) return QualType(); - + // Convert E1 to Composite2 ExprResult E1Result = E1ToC2.Perform(*this, Entity2, Kind, MultiExprArg(*this, &E1, 1)); if (E1Result.isInvalid()) return QualType(); E1 = E1Result.takeAs(); - + // Convert E2 to Composite2 ExprResult E2Result = E2ToC2.Perform(*this, Entity2, Kind, MultiExprArg(*this, &E2, 1)); if (E2Result.isInvalid()) return QualType(); E2 = E2Result.takeAs(); - + return Composite2; } ExprResult Sema::MaybeBindToTemporary(Expr *E) { if (!E) return ExprError(); - + if (!Context.getLangOptions().CPlusPlus) return Owned(E); @@ -3209,7 +3209,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { } else if (ObjCMessageExpr *ME = dyn_cast(E)) { if (const ObjCMethodDecl *MD = ME->getMethodDecl()) { if (MD->getResultType()->isReferenceType()) - return Owned(E); + return Owned(E); } } @@ -3251,11 +3251,11 @@ Expr *Sema::MaybeCreateExprWithCleanups(Expr *SubExpr) { return E; } -ExprResult +ExprResult Sema::MaybeCreateExprWithCleanups(ExprResult SubExpr) { if (SubExpr.isInvalid()) return ExprError(); - + return Owned(MaybeCreateExprWithCleanups(SubExpr.take())); } @@ -3297,7 +3297,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, if (OpKind == tok::arrow) if (const PointerType *Ptr = BaseType->getAs()) BaseType = Ptr->getPointeeType(); - + ObjectType = ParsedType::make(BaseType); MayBePseudoDestructor = true; return Owned(Base); @@ -3311,7 +3311,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, llvm::SmallPtrSet CTypes; llvm::SmallVector Locations; CTypes.insert(Context.getCanonicalType(BaseType)); - + while (BaseType->isRecordType()) { Result = BuildOverloadedArrowExpr(S, Base, OpLoc); if (Result.isInvalid()) @@ -3351,10 +3351,10 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, // The object type must be complete (or dependent). if (!BaseType->isDependentType() && - RequireCompleteType(OpLoc, BaseType, + RequireCompleteType(OpLoc, BaseType, PDiag(diag::err_incomplete_member_access))) return ExprError(); - + // C++ [basic.lookup.classref]p2: // If the id-expression in a class member access (5.2.5) is an // unqualified-id, and the type of the object expression is of a class @@ -3370,7 +3370,7 @@ ExprResult Sema::DiagnoseDtorReference(SourceLocation NameLoc, Diag(MemExpr->getLocStart(), diag::err_dtor_expr_without_call) << isa(MemExpr) << FixItHint::CreateInsertion(ExpectedLParenLoc, "()"); - + return ActOnCallExpr(/*Scope*/ 0, MemExpr, /*LPLoc*/ ExpectedLParenLoc, @@ -3388,11 +3388,11 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, PseudoDestructorTypeStorage Destructed, bool HasTrailingLParen) { TypeSourceInfo *DestructedTypeInfo = Destructed.getTypeSourceInfo(); - + // C++ [expr.pseudo]p2: - // The left-hand side of the dot operator shall be of scalar type. The + // The left-hand side of the dot operator shall be of scalar type. The // left-hand side of the arrow operator shall be of pointer to scalar type. - // This scalar type is the object type. + // This scalar type is the object type. QualType ObjectType = Base->getType(); if (OpKind == tok::arrow) { if (const PointerType *Ptr = ObjectType->getAs()) { @@ -3404,11 +3404,11 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, << FixItHint::CreateReplacement(OpLoc, "."); if (isSFINAEContext()) return ExprError(); - + OpKind = tok::period; } } - + if (!ObjectType->isDependentType() && !ObjectType->isScalarType()) { Diag(OpLoc, diag::err_pseudo_dtor_base_not_scalar) << ObjectType << Base->getSourceRange(); @@ -3416,7 +3416,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, } // C++ [expr.pseudo]p2: - // [...] The cv-unqualified versions of the object type and of the type + // [...] The cv-unqualified versions of the object type and of the type // designated by the pseudo-destructor-name shall be the same type. if (DestructedTypeInfo) { QualType DestructedType = DestructedTypeInfo->getType(); @@ -3427,7 +3427,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch) << ObjectType << DestructedType << Base->getSourceRange() << DestructedTypeInfo->getTypeLoc().getLocalSourceRange(); - + // Recover by setting the destructed type to the object type. DestructedType = ObjectType; DestructedTypeInfo = Context.getTrivialTypeSourceInfo(ObjectType, @@ -3435,29 +3435,29 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, Destructed = PseudoDestructorTypeStorage(DestructedTypeInfo); } } - + // C++ [expr.pseudo]p2: // [...] Furthermore, the two type-names in a pseudo-destructor-name of the // form // - // ::[opt] nested-name-specifier[opt] type-name :: ~ type-name + // ::[opt] nested-name-specifier[opt] type-name :: ~ type-name // // shall designate the same scalar type. if (ScopeTypeInfo) { QualType ScopeType = ScopeTypeInfo->getType(); if (!ScopeType->isDependentType() && !ObjectType->isDependentType() && !Context.hasSameUnqualifiedType(ScopeType, ObjectType)) { - + Diag(ScopeTypeInfo->getTypeLoc().getLocalSourceRange().getBegin(), diag::err_pseudo_dtor_type_mismatch) << ObjectType << ScopeType << Base->getSourceRange() << ScopeTypeInfo->getTypeLoc().getLocalSourceRange(); - + ScopeType = QualType(); ScopeTypeInfo = 0; } } - + Expr *Result = new (Context) CXXPseudoDestructorExpr(Context, Base, OpKind == tok::arrow, OpLoc, @@ -3466,10 +3466,10 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, CCLoc, TildeLoc, Destructed); - + if (HasTrailingLParen) return Owned(Result); - + return DiagnoseDtorReference(Destructed.getLocation(), Result); } @@ -3490,9 +3490,9 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, "Invalid second type name in pseudo-destructor"); // C++ [expr.pseudo]p2: - // The left-hand side of the dot operator shall be of scalar type. The + // The left-hand side of the dot operator shall be of scalar type. The // left-hand side of the arrow operator shall be of pointer to scalar type. - // This scalar type is the object type. + // This scalar type is the object type. QualType ObjectType = Base->getType(); if (OpKind == tok::arrow) { if (const PointerType *Ptr = ObjectType->getAs()) { @@ -3504,7 +3504,7 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, << FixItHint::CreateReplacement(OpLoc, "."); if (isSFINAEContext()) return ExprError(); - + OpKind = tok::period; } } @@ -3518,32 +3518,32 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, else if (ObjectType->isDependentType()) ObjectTypePtrForLookup = ParsedType::make(Context.DependentTy); } - - // Convert the name of the type being destructed (following the ~) into a + + // Convert the name of the type being destructed (following the ~) into a // type (with source-location information). QualType DestructedType; TypeSourceInfo *DestructedTypeInfo = 0; PseudoDestructorTypeStorage Destructed; if (SecondTypeName.getKind() == UnqualifiedId::IK_Identifier) { - ParsedType T = getTypeName(*SecondTypeName.Identifier, + ParsedType T = getTypeName(*SecondTypeName.Identifier, SecondTypeName.StartLocation, S, &SS, true, ObjectTypePtrForLookup); - if (!T && + if (!T && ((SS.isSet() && !computeDeclContext(SS, false)) || (!SS.isSet() && ObjectType->isDependentType()))) { - // The name of the type being destroyed is a dependent name, and we + // The name of the type being destroyed is a dependent name, and we // couldn't find anything useful in scope. Just store the identifier and // it's location, and we'll perform (qualified) name lookup again at // template instantiation time. Destructed = PseudoDestructorTypeStorage(SecondTypeName.Identifier, SecondTypeName.StartLocation); } else if (!T) { - Diag(SecondTypeName.StartLocation, + Diag(SecondTypeName.StartLocation, diag::err_pseudo_dtor_destructor_non_type) << SecondTypeName.Identifier << ObjectType; if (isSFINAEContext()) return ExprError(); - + // Recover by assuming we had the right type all along. DestructedType = ObjectType; } else @@ -3565,8 +3565,8 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, } else DestructedType = GetTypeFromParser(T.get(), &DestructedTypeInfo); } - - // If we've performed some kind of recovery, (re-)build the type source + + // If we've performed some kind of recovery, (re-)build the type source // information. if (!DestructedType.isNull()) { if (!DestructedTypeInfo) @@ -3574,24 +3574,24 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SecondTypeName.StartLocation); Destructed = PseudoDestructorTypeStorage(DestructedTypeInfo); } - + // Convert the name of the scope type (the type prior to '::') into a type. TypeSourceInfo *ScopeTypeInfo = 0; QualType ScopeType; - if (FirstTypeName.getKind() == UnqualifiedId::IK_TemplateId || + if (FirstTypeName.getKind() == UnqualifiedId::IK_TemplateId || FirstTypeName.Identifier) { if (FirstTypeName.getKind() == UnqualifiedId::IK_Identifier) { - ParsedType T = getTypeName(*FirstTypeName.Identifier, + ParsedType T = getTypeName(*FirstTypeName.Identifier, FirstTypeName.StartLocation, S, &SS, false, ObjectTypePtrForLookup); if (!T) { - Diag(FirstTypeName.StartLocation, + Diag(FirstTypeName.StartLocation, diag::err_pseudo_dtor_destructor_non_type) << FirstTypeName.Identifier << ObjectType; - + if (isSFINAEContext()) return ExprError(); - + // Just drop this type. It's unnecessary anyway. ScopeType = QualType(); } else @@ -3611,15 +3611,15 @@ ExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base, // Recover by dropping this type. ScopeType = QualType(); } else - ScopeType = GetTypeFromParser(T.get(), &ScopeTypeInfo); + ScopeType = GetTypeFromParser(T.get(), &ScopeTypeInfo); } } - + if (!ScopeType.isNull() && !ScopeTypeInfo) ScopeTypeInfo = Context.getTrivialTypeSourceInfo(ScopeType, FirstTypeName.StartLocation); - + return BuildPseudoDestructorExpr(Base, OpLoc, OpKind, SS, ScopeTypeInfo, CCLoc, TildeLoc, Destructed, HasTrailingLParen); @@ -3631,7 +3631,7 @@ ExprResult Sema::BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, FoundDecl, Method)) return true; - MemberExpr *ME = + MemberExpr *ME = new (Context) MemberExpr(Exp, /*IsArrow=*/false, Method, SourceLocation(), Method->getType(), VK_RValue, OK_Ordinary); @@ -3692,7 +3692,7 @@ void Sema::IgnoredValueConversions(Expr *&E) { } ExprResult Sema::ActOnFinishFullExpr(Expr *FullExpr) { - if (!FullExpr) + if (!FullExpr) return ExprError(); if (DiagnoseUnexpandedParameterPack(FullExpr)) diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index a2a087a55e..2169a73a1b 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -229,11 +229,11 @@ public: void InitListChecker::FillInValueInitForField(unsigned Init, FieldDecl *Field, const InitializedEntity &ParentEntity, - InitListExpr *ILE, + InitListExpr *ILE, bool &RequiresSecondPass) { SourceLocation Loc = ILE->getSourceRange().getBegin(); unsigned NumInits = ILE->getNumInits(); - InitializedEntity MemberEntity + InitializedEntity MemberEntity = InitializedEntity::InitializeMember(Field, &ParentEntity); if (Init >= NumInits || !ILE->getInit(Init)) { // FIXME: We probably don't need to handle references @@ -252,7 +252,7 @@ void InitListChecker::FillInValueInitForField(unsigned Init, FieldDecl *Field, hadError = true; return; } - + InitializationKind Kind = InitializationKind::CreateValue(Loc, Loc, Loc, true); InitializationSequence InitSeq(SemaRef, MemberEntity, Kind, 0, 0); @@ -261,14 +261,14 @@ void InitListChecker::FillInValueInitForField(unsigned Init, FieldDecl *Field, hadError = true; return; } - + ExprResult MemberInit = InitSeq.Perform(SemaRef, MemberEntity, Kind, MultiExprArg()); if (MemberInit.isInvalid()) { hadError = true; return; } - + if (hadError) { // Do nothing } else if (Init < NumInits) { @@ -284,14 +284,14 @@ void InitListChecker::FillInValueInitForField(unsigned Init, FieldDecl *Field, } } else if (InitListExpr *InnerILE = dyn_cast(ILE->getInit(Init))) - FillInValueInitializations(MemberEntity, InnerILE, - RequiresSecondPass); + FillInValueInitializations(MemberEntity, InnerILE, + RequiresSecondPass); } /// Recursively replaces NULL values within the given initializer list /// with expressions that perform value-initialization of the /// appropriate type. -void +void InitListChecker::FillInValueInitializations(const InitializedEntity &Entity, InitListExpr *ILE, bool &RequiresSecondPass) { @@ -342,17 +342,17 @@ InitListChecker::FillInValueInitializations(const InitializedEntity &Entity, ElementType = AType->getElementType(); if (const ConstantArrayType *CAType = dyn_cast(AType)) NumElements = CAType->getSize().getZExtValue(); - ElementEntity = InitializedEntity::InitializeElement(SemaRef.Context, + ElementEntity = InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity); } else if (const VectorType *VType = ILE->getType()->getAs()) { ElementType = VType->getElementType(); NumElements = VType->getNumElements(); - ElementEntity = InitializedEntity::InitializeElement(SemaRef.Context, + ElementEntity = InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity); } else ElementType = ILE->getType(); - + for (unsigned Init = 0; Init != NumElements; ++Init) { if (hadError) return; @@ -407,7 +407,7 @@ InitListChecker::InitListChecker(Sema &S, const InitializedEntity &Entity, unsigned newStructuredIndex = 0; FullyStructuredList = getStructuredSubobjectInit(IL, newIndex, T, 0, 0, IL->getSourceRange()); - CheckExplicitInitList(Entity, IL, T, newIndex, + CheckExplicitInitList(Entity, IL, T, newIndex, FullyStructuredList, newStructuredIndex, /*TopLevelObject=*/true); @@ -415,7 +415,7 @@ InitListChecker::InitListChecker(Sema &S, const InitializedEntity &Entity, bool RequiresSecondPass = false; FillInValueInitializations(Entity, FullyStructuredList, RequiresSecondPass); if (RequiresSecondPass && !hadError) - FillInValueInitializations(Entity, FullyStructuredList, + FillInValueInitializations(Entity, FullyStructuredList, RequiresSecondPass); } } @@ -480,7 +480,7 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity, // Check the element types and build the structural subobject. unsigned StartIndex = Index; - CheckListElementTypes(Entity, ParentIList, T, + CheckListElementTypes(Entity, ParentIList, T, /*SubobjectIsDesignatorContext=*/false, Index, StructuredSubobjectInitList, StructuredSubobjectInitIndex, @@ -495,16 +495,16 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity, = ParentIList->getInit(EndIndex)->getSourceRange().getEnd(); StructuredSubobjectInitList->setRBraceLoc(EndLoc); } - + // Warn about missing braces. if (T->isArrayType() || T->isRecordType()) { SemaRef.Diag(StructuredSubobjectInitList->getLocStart(), diag::warn_missing_braces) << StructuredSubobjectInitList->getSourceRange() - << FixItHint::CreateInsertion(StructuredSubobjectInitList->getLocStart(), + << FixItHint::CreateInsertion(StructuredSubobjectInitList->getLocStart(), "{") << FixItHint::CreateInsertion(SemaRef.PP.getLocForEndOfToken( - StructuredSubobjectInitList->getLocEnd()), + StructuredSubobjectInitList->getLocEnd()), "}"); } } @@ -518,7 +518,7 @@ void InitListChecker::CheckExplicitInitList(const InitializedEntity &Entity, assert(IList->isExplicit() && "Illegal Implicit InitListExpr"); SyntacticToSemantic[IList] = StructuredList; StructuredList->setSyntacticForm(IList); - CheckListElementTypes(Entity, IList, T, /*SubobjectIsDesignatorContext=*/true, + CheckListElementTypes(Entity, IList, T, /*SubobjectIsDesignatorContext=*/true, Index, StructuredList, StructuredIndex, TopLevelObject); QualType ExprTy = T.getNonLValueExprType(SemaRef.Context); IList->setType(ExprTy); @@ -583,7 +583,7 @@ void InitListChecker::CheckListElementTypes(const InitializedEntity &Entity, CheckScalarType(Entity, IList, DeclType, Index, StructuredList, StructuredIndex); } else if (DeclType->isVectorType()) { - CheckVectorType(Entity, IList, DeclType, Index, + CheckVectorType(Entity, IList, DeclType, Index, StructuredList, StructuredIndex); } else if (DeclType->isAggregateType()) { if (DeclType->isRecordType()) { @@ -596,7 +596,7 @@ void InitListChecker::CheckListElementTypes(const InitializedEntity &Entity, llvm::APSInt Zero( SemaRef.Context.getTypeSize(SemaRef.Context.getSizeType()), false); - CheckArrayType(Entity, IList, DeclType, Zero, + CheckArrayType(Entity, IList, DeclType, Zero, SubobjectIsDesignatorContext, Index, StructuredList, StructuredIndex); } else @@ -656,7 +656,7 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, UpdateStructuredListElement(StructuredList, StructuredIndex, Str); ++Index; } else if (ElemType->isScalarType()) { - CheckScalarType(Entity, IList, ElemType, Index, + CheckScalarType(Entity, IList, ElemType, Index, StructuredList, StructuredIndex); } else if (ElemType->isReferenceType()) { CheckReferenceType(Entity, IList, ElemType, Index, @@ -670,17 +670,17 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, // member, the member is initialized. [...] // FIXME: Better EqualLoc? - InitializationKind Kind = + InitializationKind Kind = InitializationKind::CreateCopy(expr->getLocStart(), SourceLocation()); InitializationSequence Seq(SemaRef, Entity, Kind, &expr, 1); - + if (Seq) { - ExprResult Result = + ExprResult Result = Seq.Perform(SemaRef, Entity, Kind, MultiExprArg(&expr, 1)); if (Result.isInvalid()) hadError = true; - - UpdateStructuredListElement(StructuredList, StructuredIndex, + + UpdateStructuredListElement(StructuredList, StructuredIndex, Result.takeAs()); ++Index; return; @@ -720,7 +720,7 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, } else { // We cannot initialize this element, so let // PerformCopyInitialization produce the appropriate diagnostic. - SemaRef.PerformCopyInitialization(Entity, SourceLocation(), + SemaRef.PerformCopyInitialization(Entity, SourceLocation(), SemaRef.Owned(expr)); hadError = true; ++Index; @@ -772,7 +772,7 @@ void InitListChecker::CheckScalarType(const InitializedEntity &Entity, hadError = true; // types weren't compatible. else { ResultExpr = Result.takeAs(); - + if (ResultExpr != expr) { // The type was promoted, update initializer list. IList->setInit(Index, ResultExpr); @@ -859,7 +859,7 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, hadError = true; // types weren't compatible. else { ResultExpr = Result.takeAs(); - + if (ResultExpr != Init) { // The type was promoted, update initializer list. IList->setInit(Index, ResultExpr); @@ -875,12 +875,12 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, InitializedEntity ElementEntity = InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity); - + for (unsigned i = 0; i < maxElements; ++i, ++numEltsInit) { // Don't attempt to go past the end of the init list if (Index >= IList->getNumInits()) break; - + ElementEntity.setElementIndex(Index); CheckSubElementType(ElementEntity, IList, elementType, Index, StructuredList, StructuredIndex); @@ -890,13 +890,13 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, InitializedEntity ElementEntity = InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity); - + // OpenCL initializers allows vectors to be constructed from vectors. for (unsigned i = 0; i < maxElements; ++i) { // Don't attempt to go past the end of the init list if (Index >= IList->getNumInits()) break; - + ElementEntity.setElementIndex(Index); QualType IType = IList->getInit(Index)->getType(); @@ -908,7 +908,7 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, QualType VecType; const VectorType *IVT = IType->getAs(); unsigned numIElts = IVT->getNumElements(); - + if (IType->isExtVectorType()) VecType = SemaRef.Context.getExtVectorType(elementType, numIElts); else @@ -1018,7 +1018,7 @@ void InitListChecker::CheckArrayType(const InitializedEntity &Entity, break; InitializedEntity ElementEntity = - InitializedEntity::InitializeElement(SemaRef.Context, StructuredIndex, + InitializedEntity::InitializeElement(SemaRef.Context, StructuredIndex, Entity); // Check this element. CheckSubElementType(ElementEntity, IList, elementType, Index, @@ -1145,7 +1145,7 @@ void InitListChecker::CheckStructUnionTypes(const InitializedEntity &Entity, } // Emit warnings for missing struct field initializers. - if (InitializedSomething && CheckForMissingFields && Field != FieldEnd && + if (InitializedSomething && CheckForMissingFields && Field != FieldEnd && !Field->getType()->isIncompleteArrayType() && !DeclType->isUnionType()) { // It is possible we have one or more unnamed bitfields remaining. // Find first (if any) named field and emit warning. @@ -1185,12 +1185,12 @@ void InitListChecker::CheckStructUnionTypes(const InitializedEntity &Entity, InitializedEntity MemberEntity = InitializedEntity::InitializeMember(*Field, &Entity); - + if (isa(IList->getInit(Index))) - CheckSubElementType(MemberEntity, IList, Field->getType(), Index, + CheckSubElementType(MemberEntity, IList, Field->getType(), Index, StructuredList, StructuredIndex); else - CheckImplicitInitList(MemberEntity, IList, Field->getType(), Index, + CheckImplicitInitList(MemberEntity, IList, Field->getType(), Index, StructuredList, StructuredIndex); } @@ -1226,7 +1226,7 @@ static void ExpandAnonymousFieldDesignator(Sema &SemaRef, &Replacements[0] + Replacements.size()); } -/// \brief Given an implicit anonymous field, search the IndirectField that +/// \brief Given an implicit anonymous field, search the IndirectField that /// corresponds to FieldName. static IndirectFieldDecl *FindIndirectFieldDesignator(FieldDecl *AnonField, IdentifierInfo *FieldName) { @@ -1357,7 +1357,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, for (; Field != FieldEnd; ++Field) { if (Field->isUnnamedBitfield()) continue; - + // If we find a field representing an anonymous field, look in the // IndirectFieldDecl that follow for the designated initializer. if (!KnownField && Field->isAnonymousStructOrUnion()) { @@ -1387,19 +1387,19 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, if (Lookup.first == Lookup.second) { // Name lookup didn't find anything. Determine whether this // was a typo for another field name. - LookupResult R(SemaRef, FieldName, D->getFieldLoc(), + LookupResult R(SemaRef, FieldName, D->getFieldLoc(), Sema::LookupMemberName); if (SemaRef.CorrectTypo(R, /*Scope=*/0, /*SS=*/0, RT->getDecl(), false, - Sema::CTC_NoKeywords) && + Sema::CTC_NoKeywords) && (ReplacementField = R.getAsSingle()) && ReplacementField->getDeclContext()->getRedeclContext() ->Equals(RT->getDecl())) { - SemaRef.Diag(D->getFieldLoc(), + SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_unknown_suggest) << FieldName << CurrentObjectType << R.getLookupName() << FixItHint::CreateReplacement(D->getFieldLoc(), R.getLookupName().getAsString()); - SemaRef.Diag(ReplacementField->getLocation(), + SemaRef.Diag(ReplacementField->getLocation(), diag::note_previous_decl) << ReplacementField->getDeclName(); } else { @@ -1409,7 +1409,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, return true; } } - + if (!ReplacementField) { // Name lookup found something, but it wasn't a field. SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_nonfield) @@ -1429,7 +1429,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, if (Field->isUnnamedBitfield()) continue; - if (ReplacementField == *Field || + if (ReplacementField == *Field || Field->getIdentifier() == ReplacementField->getIdentifier()) break; @@ -1521,11 +1521,11 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // Recurse to check later designated subobjects. QualType FieldType = (*Field)->getType(); unsigned newStructuredIndex = FieldIndex; - + InitializedEntity MemberEntity = InitializedEntity::InitializeMember(*Field, &Entity); - if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1, - FieldType, 0, 0, Index, + if (CheckDesignatedInitializer(MemberEntity, IList, DIE, DesigIdx + 1, + FieldType, 0, 0, Index, StructuredList, newStructuredIndex, true, false)) return true; @@ -1554,7 +1554,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // Check the remaining fields within this class/struct/union subobject. bool prevHadError = hadError; - + CheckStructUnionTypes(Entity, IList, CurrentObjectType, Field, false, Index, StructuredList, FieldIndex); return hadError && !prevHadError; @@ -1644,7 +1644,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // Move to the next designator unsigned ElementIndex = DesignatedStartIndex.getZExtValue(); unsigned OldIndex = Index; - + InitializedEntity ElementEntity = InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity); @@ -1652,10 +1652,10 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // Recurse to check later designated subobjects. QualType ElementType = AT->getElementType(); Index = OldIndex; - + ElementEntity.setElementIndex(ElementIndex); - if (CheckDesignatedInitializer(ElementEntity, IList, DIE, DesigIdx + 1, - ElementType, 0, 0, Index, + if (CheckDesignatedInitializer(ElementEntity, IList, DIE, DesigIdx + 1, + ElementType, 0, 0, Index, StructuredList, ElementIndex, (DesignatedStartIndex == DesignatedEndIndex), false)) @@ -1680,7 +1680,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // Check the remaining elements within this array subobject. bool prevHadError = hadError; - CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex, + CheckArrayType(Entity, IList, CurrentObjectType, DesignatedStartIndex, /*SubobjectIsDesignatorContext=*/false, Index, StructuredList, ElementIndex); return hadError && !prevHadError; @@ -1913,11 +1913,11 @@ ExprResult Sema::ActOnDesignatedInitializer(Designation &Desig, Designators.data(), Designators.size(), InitExpressions.data(), InitExpressions.size(), Loc, GNUSyntax, Init.takeAs()); - + if (getLangOptions().CPlusPlus) Diag(DIE->getLocStart(), diag::ext_designated_init) << DIE->getSourceRange(); - + return Owned(DIE); } @@ -1934,9 +1934,9 @@ bool Sema::CheckInitList(const InitializedEntity &Entity, // Initialization entity //===----------------------------------------------------------------------===// -InitializedEntity::InitializedEntity(ASTContext &Context, unsigned Index, +InitializedEntity::InitializedEntity(ASTContext &Context, unsigned Index, const InitializedEntity &Parent) - : Parent(&Parent), Index(Index) + : Parent(&Parent), Index(Index) { if (const ArrayType *AT = Context.getAsArrayType(Parent.getType())) { Kind = EK_ArrayElement; @@ -1947,7 +1947,7 @@ InitializedEntity::InitializedEntity(ASTContext &Context, unsigned Index, } } -InitializedEntity InitializedEntity::InitializeBase(ASTContext &Context, +InitializedEntity InitializedEntity::InitializeBase(ASTContext &Context, CXXBaseSpecifier *Base, bool IsInheritedVirtualBase) { @@ -1956,7 +1956,7 @@ InitializedEntity InitializedEntity::InitializeBase(ASTContext &Context, Result.Base = reinterpret_cast(Base); if (IsInheritedVirtualBase) Result.Base |= 0x01; - + Result.Type = Base->getType(); return Result; } @@ -1982,7 +1982,7 @@ DeclarationName InitializedEntity::getName() const { case EK_BlockElement: return DeclarationName(); } - + // Silence GCC warning return DeclarationName(); } @@ -2004,7 +2004,7 @@ DeclaratorDecl *InitializedEntity::getDecl() const { case EK_BlockElement: return 0; } - + // Silence GCC warning return 0; } @@ -2014,7 +2014,7 @@ bool InitializedEntity::allowsNRVO() const { case EK_Result: case EK_Exception: return LocAndNRVO.NRVO; - + case EK_Variable: case EK_Parameter: case EK_Member: @@ -2054,7 +2054,7 @@ void InitializationSequence::Step::Destroy() { case SK_StringInit: case SK_ObjCObjectConversion: break; - + case SK_ConversionSequence: delete ICS; } @@ -2067,7 +2067,7 @@ bool InitializationSequence::isDirectReferenceBinding() const { bool InitializationSequence::isAmbiguous() const { if (getKind() != FailedSequence) return false; - + switch (getFailureKind()) { case FK_TooManyInitsForReference: case FK_ArrayNeedsInitList: @@ -2085,13 +2085,13 @@ bool InitializationSequence::isAmbiguous() const { case FK_DefaultInitOfConst: case FK_Incomplete: return false; - + case FK_ReferenceInitOverloadFailed: case FK_UserConversionOverloadFailed: case FK_ConstructorOverloadFailed: return FailedOverloadResult == OR_Ambiguous; } - + return false; } @@ -2110,7 +2110,7 @@ void InitializationSequence::AddAddressOverloadResolutionStep( Steps.push_back(S); } -void InitializationSequence::AddDerivedToBaseCastStep(QualType BaseType, +void InitializationSequence::AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind VK) { Step S; switch (VK) { @@ -2123,7 +2123,7 @@ void InitializationSequence::AddDerivedToBaseCastStep(QualType BaseType, Steps.push_back(S); } -void InitializationSequence::AddReferenceBindingStep(QualType T, +void InitializationSequence::AddReferenceBindingStep(QualType T, bool BindingTemporary) { Step S; S.Kind = BindingTemporary? SK_BindReferenceToTemporary : SK_BindReference; @@ -2185,7 +2185,7 @@ void InitializationSequence::AddListInitializationStep(QualType T) { Steps.push_back(S); } -void +void InitializationSequence::AddConstructorInitializationStep( CXXConstructorDecl *Constructor, AccessSpecifier Access, @@ -2226,7 +2226,7 @@ void InitializationSequence::AddObjCObjectConversionStep(QualType T) { Steps.push_back(S); } -void InitializationSequence::SetOverloadFailure(FailureKind Failure, +void InitializationSequence::SetOverloadFailure(FailureKind Failure, OverloadingResult Result) { SequenceKind = FailedSequence; this->Failure = Failure; @@ -2237,8 +2237,8 @@ void InitializationSequence::SetOverloadFailure(FailureKind Failure, // Attempt initialization //===----------------------------------------------------------------------===// -/// \brief Attempt list initialization (C++0x [dcl.init.list]) -static void TryListInitialization(Sema &S, +/// \brief Attempt list initialization (C++0x [dcl.init.list]) +static void TryListInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitListExpr *InitList, @@ -2254,7 +2254,7 @@ static void TryListInitialization(Sema &S, QualType DestType = Entity.getType(); // C++ [dcl.init]p13: - // If T is a scalar type, then a declaration of the form + // If T is a scalar type, then a declaration of the form // // T x = { a }; // @@ -2301,7 +2301,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, bool DerivedToBase; bool ObjCConversion; - assert(!S.CompareReferenceRelationship(Initializer->getLocStart(), + assert(!S.CompareReferenceRelationship(Initializer->getLocStart(), T1, T2, DerivedToBase, ObjCConversion) && "Must have incompatible references when binding via conversion"); @@ -2316,7 +2316,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, // Determine whether we are allowed to call explicit constructors or // explicit conversion operators. bool AllowExplicit = Kind.getKind() == InitializationKind::IK_Direct; - + const RecordType *T1RecordType = 0; if (AllowRValues && (T1RecordType = T1->getAs()) && !S.RequireCompleteType(Kind.getLocation(), T1, 0)) { @@ -2338,7 +2338,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, ConstructorTmpl->getTemplatedDecl()); else Constructor = cast(D); - + if (!Constructor->isInvalidDecl() && Constructor->isConvertingConstructor(AllowExplicit)) { if (ConstructorTmpl) @@ -2351,11 +2351,11 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, &Initializer, 1, CandidateSet, /*SuppressUserConversions=*/true); } - } + } } if (T1RecordType && T1RecordType->getDecl()->isInvalidDecl()) return OR_No_Viable_Function; - + const RecordType *T2RecordType = 0; if ((T2RecordType = T2->getAs()) && !S.RequireCompleteType(Kind.getLocation(), T2, 0)) { @@ -2371,19 +2371,19 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, CXXRecordDecl *ActingDC = cast(D->getDeclContext()); if (isa(D)) D = cast(D)->getTargetDecl(); - + FunctionTemplateDecl *ConvTemplate = dyn_cast(D); CXXConversionDecl *Conv; if (ConvTemplate) Conv = cast(ConvTemplate->getTemplatedDecl()); else Conv = cast(D); - + // If the conversion function doesn't return a reference type, // it can't be considered for this conversion unless we're allowed to // consider rvalues. - // FIXME: Do we need to make sure that we only consider conversion - // candidates with reference-compatible results? That might be needed to + // FIXME: Do we need to make sure that we only consider conversion + // candidates with reference-compatible results? That might be needed to // break recursion. if ((AllowExplicit || !Conv->isExplicit()) && (AllowRValues || Conv->getConversionType()->isLValueReferenceType())){ @@ -2399,12 +2399,12 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, } if (T2RecordType && T2RecordType->getDecl()->isInvalidDecl()) return OR_No_Viable_Function; - + SourceLocation DeclLoc = Initializer->getLocStart(); - // Perform overload resolution. If it fails, return the failed result. + // Perform overload resolution. If it fails, return the failed result. OverloadCandidateSet::iterator Best; - if (OverloadingResult Result + if (OverloadingResult Result = CandidateSet.BestViableFunction(S, DeclLoc, Best, true)) return Result; @@ -2420,7 +2420,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, Sequence.AddUserConversionStep(Function, Best->FoundDecl, T2.getNonLValueExprType(S.Context)); - // Determine whether we need to perform derived-to-base or + // Determine whether we need to perform derived-to-base or // cv-qualification adjustments. ExprValueKind VK = VK_RValue; if (T2->isLValueReferenceType()) @@ -2431,7 +2431,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, bool NewDerivedToBase = false; bool NewObjCConversion = false; Sema::ReferenceCompareResult NewRefRelationship - = S.CompareReferenceRelationship(DeclLoc, T1, + = S.CompareReferenceRelationship(DeclLoc, T1, T2.getNonLValueExprType(S.Context), NewDerivedToBase, NewObjCConversion); if (NewRefRelationship == Sema::Ref_Incompatible) { @@ -2447,7 +2447,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, } else if (NewDerivedToBase) Sequence.AddDerivedToBaseCastStep( S.Context.getQualifiedType(T1, - T2.getNonReferenceType().getQualifiers()), + T2.getNonReferenceType().getQualifiers()), VK); else if (NewObjCConversion) Sequence.AddObjCObjectConversionStep( @@ -2456,13 +2456,13 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, if (cv1T1.getQualifiers() != T2.getNonReferenceType().getQualifiers()) Sequence.AddQualificationConversionStep(cv1T1, VK); - + Sequence.AddReferenceBindingStep(cv1T1, !T2->isReferenceType()); return OR_Success; } - -/// \brief Attempt reference initialization (C++0x [dcl.init.ref]) -static void TryReferenceInitialization(Sema &S, + +/// \brief Attempt reference initialization (C++0x [dcl.init.ref]) +static void TryReferenceInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, @@ -2483,7 +2483,7 @@ static void TryReferenceInitialization(Sema &S, // type of the resulting function. if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy) { DeclAccessPair Found; - if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(Initializer, + if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(Initializer, T1, false, Found)) { @@ -2507,10 +2507,10 @@ static void TryReferenceInitialization(Sema &S, ObjCConversion); // C++0x [dcl.init.ref]p5: - // A reference to type "cv1 T1" is initialized by an expression of type + // A reference to type "cv1 T1" is initialized by an expression of type // "cv2 T2" as follows: // - // - If the reference is an lvalue reference and the initializer + // - If the reference is an lvalue reference and the initializer // expression // Note the analogous bullet points for rvlaue refs to functions. Because // there are no function rvalues in C++, rvalue refs to functions are treated @@ -2518,21 +2518,21 @@ static void TryReferenceInitialization(Sema &S, OverloadingResult ConvOvlResult = OR_Success; bool T1Function = T1->isFunctionType(); if (isLValueRef || T1Function) { - if (InitCategory.isLValue() && + if (InitCategory.isLValue() && (RefRelationship >= Sema::Ref_Compatible_With_Added_Qualification || - (Kind.isCStyleOrFunctionalCast() && + (Kind.isCStyleOrFunctionalCast() && RefRelationship == Sema::Ref_Related))) { - // - is an lvalue (but is not a bit-field), and "cv1 T1" is + // - is an lvalue (but is not a bit-field), and "cv1 T1" is // reference-compatible with "cv2 T2," or // - // Per C++ [over.best.ics]p2, we don't diagnose whether the lvalue is a + // Per C++ [over.best.ics]p2, we don't diagnose whether the lvalue is a // bit-field when we're determining whether the reference initialization // can occur. However, we do pay attention to whether it is a bit-field // to decide whether we're actually binding to a temporary created from // the bit-field. if (DerivedToBase) Sequence.AddDerivedToBaseCastStep( - S.Context.getQualifiedType(T1, T2Quals), + S.Context.getQualifiedType(T1, T2Quals), VK_LValue); else if (ObjCConversion) Sequence.AddObjCObjectConversionStep( @@ -2545,18 +2545,18 @@ static void TryReferenceInitialization(Sema &S, Sequence.AddReferenceBindingStep(cv1T1, BindingTemporary); return; } - - // - has a class type (i.e., T2 is a class type), where T1 is not - // reference-related to T2, and can be implicitly converted to an - // lvalue of type "cv3 T3," where "cv1 T1" is reference-compatible - // with "cv3 T3" (this conversion is selected by enumerating the + + // - has a class type (i.e., T2 is a class type), where T1 is not + // reference-related to T2, and can be implicitly converted to an + // lvalue of type "cv3 T3," where "cv1 T1" is reference-compatible + // with "cv3 T3" (this conversion is selected by enumerating the // applicable conversion functions (13.3.1.6) and choosing the best // one through overload resolution (13.3)), // If we have an rvalue ref to function type here, the rhs must be // an rvalue. if (RefRelationship == Sema::Ref_Incompatible && T2->isRecordType() && (isLValueRef || InitCategory.isRValue())) { - ConvOvlResult = TryRefInitWithConversionFunction(S, Entity, Kind, + ConvOvlResult = TryRefInitWithConversionFunction(S, Entity, Kind, Initializer, /*AllowRValues=*/isRValueRef, Sequence); @@ -2570,7 +2570,7 @@ static void TryReferenceInitialization(Sema &S, } } - // - Otherwise, the reference shall be an lvalue reference to a + // - Otherwise, the reference shall be an lvalue reference to a // non-volatile const type (i.e., cv1 shall be const), or the reference // shall be an rvalue reference. if (isLValueRef && !(T1Quals.hasConst() && !T1Quals.hasVolatile())) { @@ -2596,7 +2596,7 @@ static void TryReferenceInitialization(Sema &S, // Note: functions are handled below. if (!T1Function && (RefRelationship >= Sema::Ref_Compatible_With_Added_Qualification || - (Kind.isCStyleOrFunctionalCast() && + (Kind.isCStyleOrFunctionalCast() && RefRelationship == Sema::Ref_Related)) && (InitCategory.isXValue() || (InitCategory.isPRValue() && T2->isRecordType()) || @@ -2615,23 +2615,23 @@ static void TryReferenceInitialization(Sema &S, if (!S.getLangOptions().CPlusPlus0x && !S.getLangOptions().Microsoft) Sequence.AddExtraneousCopyToTemporary(cv2T2); } - + if (DerivedToBase) Sequence.AddDerivedToBaseCastStep(S.Context.getQualifiedType(T1, T2Quals), ValueKind); else if (ObjCConversion) Sequence.AddObjCObjectConversionStep( S.Context.getQualifiedType(T1, T2Quals)); - + if (T1Quals != T2Quals) Sequence.AddQualificationConversionStep(cv1T1, ValueKind); - Sequence.AddReferenceBindingStep(cv1T1, + Sequence.AddReferenceBindingStep(cv1T1, /*bindingTemporary=*/(InitCategory.isPRValue() && !T2->isArrayType())); - return; + return; } - - // - has a class type (i.e., T2 is a class type), where T1 is not - // reference-related to T2, and can be implicitly converted to an + + // - has a class type (i.e., T2 is a class type), where T1 is not + // reference-related to T2, and can be implicitly converted to an // xvalue, class prvalue, or function lvalue of type "cv3 T3", // where "cv1 T1" is reference-compatible with "cv3 T3", if (T2->isRecordType()) { @@ -2644,17 +2644,17 @@ static void TryReferenceInitialization(Sema &S, Sequence.SetOverloadFailure( InitializationSequence::FK_ReferenceInitOverloadFailed, ConvOvlResult); - + return; } - + Sequence.SetFailed(InitializationSequence::FK_ReferenceInitDropsQualifiers); return; } // - Otherwise, a temporary of type "cv1 T1" is created and initialized // from the initializer expression using the rules for a non-reference - // copy initialization (8.5). The reference is then bound to the + // copy initialization (8.5). The reference is then bound to the // temporary. [...] // Determine whether we are allowed to call explicit constructors or @@ -2688,28 +2688,28 @@ static void TryReferenceInitialization(Sema &S, // than, cv2; otherwise, the program is ill-formed. unsigned T1CVRQuals = T1Quals.getCVRQualifiers(); unsigned T2CVRQuals = T2Quals.getCVRQualifiers(); - if (RefRelationship == Sema::Ref_Related && + if (RefRelationship == Sema::Ref_Related && (T1CVRQuals | T2CVRQuals) != T1CVRQuals) { Sequence.SetFailed(InitializationSequence::FK_ReferenceInitDropsQualifiers); return; } - // [...] If T1 is reference-related to T2 and the reference is an rvalue + // [...] If T1 is reference-related to T2 and the reference is an rvalue // reference, the initializer expression shall not be an lvalue. - if (RefRelationship >= Sema::Ref_Related && !isLValueRef && + if (RefRelationship >= Sema::Ref_Related && !isLValueRef && InitCategory.isLValue()) { Sequence.SetFailed( InitializationSequence::FK_RValueReferenceBindingToLValue); return; } - + Sequence.AddReferenceBindingStep(cv1T1, /*bindingTemporary=*/true); return; } /// \brief Attempt character array initialization from a string literal -/// (C++ [dcl.init.string], C99 6.7.8). -static void TryStringLiteralInitialization(Sema &S, +/// (C++ [dcl.init.string], C99 6.7.8). +static void TryStringLiteralInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, @@ -2721,19 +2721,19 @@ static void TryStringLiteralInitialization(Sema &S, /// \brief Attempt initialization by constructor (C++ [dcl.init]), which /// enumerates the constructors of the initialized entity and performs overload /// resolution to select the best. -static void TryConstructorInitialization(Sema &S, +static void TryConstructorInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr **Args, unsigned NumArgs, QualType DestType, InitializationSequence &Sequence) { Sequence.setSequenceKind(InitializationSequence::ConstructorInitialization); - + // Build the candidate set directly in the initialization sequence // structure, so that it will persist if we fail. OverloadCandidateSet &CandidateSet = Sequence.getFailedCandidateSet(); CandidateSet.clear(); - + // Determine whether we are allowed to call explicit constructors or // explicit conversion operators. bool AllowExplicit = (Kind.getKind() == InitializationKind::IK_Direct || @@ -2745,21 +2745,21 @@ static void TryConstructorInitialization(Sema &S, Sequence.SetFailed(InitializationSequence::FK_Incomplete); return; } - + // The type we're converting to is a class type. Enumerate its constructors // to see if one is suitable. const RecordType *DestRecordType = DestType->getAs(); - assert(DestRecordType && "Constructor initialization requires record type"); + assert(DestRecordType && "Constructor initialization requires record type"); CXXRecordDecl *DestRecordDecl = cast(DestRecordType->getDecl()); - + DeclContext::lookup_iterator Con, ConEnd; for (llvm::tie(Con, ConEnd) = S.LookupConstructors(DestRecordDecl); Con != ConEnd; ++Con) { NamedDecl *D = *Con; DeclAccessPair FoundDecl = DeclAccessPair::make(D, D->getAccess()); bool SuppressUserConversions = false; - + // Find the constructor (which may be a template). CXXConstructorDecl *Constructor = 0; FunctionTemplateDecl *ConstructorTmpl = dyn_cast(D); @@ -2769,14 +2769,14 @@ static void TryConstructorInitialization(Sema &S, else { Constructor = cast(D); - // If we're performing copy initialization using a copy constructor, we + // If we're performing copy initialization using a copy constructor, we // suppress user-defined conversions on the arguments. // FIXME: Move constructors? if (Kind.getKind() == InitializationKind::IK_Copy && Constructor->isCopyConstructor()) SuppressUserConversions = true; } - + if (!Constructor->isInvalidDecl() && (AllowExplicit || !Constructor->isExplicit())) { if (ConstructorTmpl) @@ -2789,16 +2789,16 @@ static void TryConstructorInitialization(Sema &S, Args, NumArgs, CandidateSet, SuppressUserConversions); } - } - + } + SourceLocation DeclLoc = Kind.getLocation(); - - // Perform overload resolution. If it fails, return the failed result. + + // Perform overload resolution. If it fails, return the failed result. OverloadCandidateSet::iterator Best; - if (OverloadingResult Result + if (OverloadingResult Result = CandidateSet.BestViableFunction(S, DeclLoc, Best)) { Sequence.SetOverloadFailure( - InitializationSequence::FK_ConstructorOverloadFailed, + InitializationSequence::FK_ConstructorOverloadFailed, Result); return; } @@ -2817,13 +2817,13 @@ static void TryConstructorInitialization(Sema &S, // Add the constructor initialization step. Any cv-qualification conversion is // subsumed by the initialization. Sequence.AddConstructorInitializationStep( - cast(Best->Function), + cast(Best->Function), Best->FoundDecl.getAccess(), DestType); } /// \brief Attempt value initialization (C++ [dcl.init]p7). -static void TryValueInitialization(Sema &S, +static void TryValueInitialization(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, InitializationSequence &Sequence) { @@ -2831,11 +2831,11 @@ static void TryValueInitialization(Sema &S, // // To value-initialize an object of type T means: QualType T = Entity.getType(); - + // -- if T is an array type, then each element is value-initialized; while (const ArrayType *AT = S.Context.getAsArrayType(T)) T = AT->getElementType(); - + if (const RecordType *RT = T->getAs()) { if (CXXRecordDecl *ClassDecl = dyn_cast(RT->getDecl())) { // -- if T is a class type (clause 9) with a user-declared @@ -2847,7 +2847,7 @@ static void TryValueInitialization(Sema &S, // but Entity doesn't have a way to capture that (yet). if (ClassDecl->hasUserDeclaredConstructor()) return TryConstructorInitialization(S, Entity, Kind, 0, 0, T, Sequence); - + // -- if T is a (possibly cv-qualified) non-union class type // without a user-provided constructor, then the object is // zero-initialized and, if T's implicitly-declared default @@ -2855,7 +2855,7 @@ static void TryValueInitialization(Sema &S, if ((ClassDecl->getTagKind() == TTK_Class || ClassDecl->getTagKind() == TTK_Struct)) { Sequence.AddZeroInitializationStep(Entity.getType()); - return TryConstructorInitialization(S, Entity, Kind, 0, 0, T, Sequence); + return TryConstructorInitialization(S, Entity, Kind, 0, 0, T, Sequence); } } } @@ -2870,14 +2870,14 @@ static void TryDefaultInitialization(Sema &S, const InitializationKind &Kind, InitializationSequence &Sequence) { assert(Kind.getKind() == InitializationKind::IK_Default); - + // C++ [dcl.init]p6: // To default-initialize an object of type T means: // - if T is an array type, each element is default-initialized; QualType DestType = Entity.getType(); while (const ArrayType *Array = S.Context.getAsArrayType(DestType)) DestType = Array->getElementType(); - + // - if T is a (possibly cv-qualified) class type (Clause 9), the default // constructor for T is called (and the initialization is ill-formed if // T has no accessible default constructor); @@ -2885,12 +2885,12 @@ static void TryDefaultInitialization(Sema &S, TryConstructorInitialization(S, Entity, Kind, 0, 0, DestType, Sequence); return; } - + // - otherwise, no initialization is performed. Sequence.setSequenceKind(InitializationSequence::NoInitialization); - + // If a program calls for the default initialization of an object of - // a const-qualified type T, T shall be a class type with a user-provided + // a const-qualified type T, T shall be a class type with a user-provided // default constructor. if (DestType.isConstQualified() && S.getLangOptions().CPlusPlus) Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst); @@ -2899,42 +2899,42 @@ static void TryDefaultInitialization(Sema &S, /// \brief Attempt a user-defined conversion between two types (C++ [dcl.init]), /// which enumerates all conversion functions and performs overload resolution /// to select the best. -static void TryUserDefinedConversion(Sema &S, +static void TryUserDefinedConversion(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr *Initializer, InitializationSequence &Sequence) { Sequence.setSequenceKind(InitializationSequence::UserDefinedConversion); - + QualType DestType = Entity.getType(); assert(!DestType->isReferenceType() && "References are handled elsewhere"); QualType SourceType = Initializer->getType(); assert((DestType->isRecordType() || SourceType->isRecordType()) && "Must have a class type to perform a user-defined conversion"); - + // Build the candidate set directly in the initialization sequence // structure, so that it will persist if we fail. OverloadCandidateSet &CandidateSet = Sequence.getFailedCandidateSet(); CandidateSet.clear(); - + // Determine whether we are allowed to call explicit constructors or // explicit conversion operators. bool AllowExplicit = Kind.getKind() == InitializationKind::IK_Direct; - + if (const RecordType *DestRecordType = DestType->getAs()) { // The type we're converting to is a class type. Enumerate its constructors // to see if there is a suitable conversion. CXXRecordDecl *DestRecordDecl = cast(DestRecordType->getDecl()); - + // Try to complete the type we're converting to. - if (!S.RequireCompleteType(Kind.getLocation(), DestType, 0)) { + if (!S.RequireCompleteType(Kind.getLocation(), DestType, 0)) { DeclContext::lookup_iterator Con, ConEnd; for (llvm::tie(Con, ConEnd) = S.LookupConstructors(DestRecordDecl); Con != ConEnd; ++Con) { NamedDecl *D = *Con; DeclAccessPair FoundDecl = DeclAccessPair::make(D, D->getAccess()); - + // Find the constructor (which may be a template). CXXConstructorDecl *Constructor = 0; FunctionTemplateDecl *ConstructorTmpl @@ -2944,7 +2944,7 @@ static void TryUserDefinedConversion(Sema &S, ConstructorTmpl->getTemplatedDecl()); else Constructor = cast(D); - + if (!Constructor->isInvalidDecl() && Constructor->isConvertingConstructor(AllowExplicit)) { if (ConstructorTmpl) @@ -2957,7 +2957,7 @@ static void TryUserDefinedConversion(Sema &S, &Initializer, 1, CandidateSet, /*SuppressUserConversions=*/true); } - } + } } } @@ -2972,24 +2972,24 @@ static void TryUserDefinedConversion(Sema &S, if (!S.RequireCompleteType(DeclLoc, SourceType, 0)) { CXXRecordDecl *SourceRecordDecl = cast(SourceRecordType->getDecl()); - + const UnresolvedSetImpl *Conversions = SourceRecordDecl->getVisibleConversionFunctions(); for (UnresolvedSetImpl::const_iterator I = Conversions->begin(), - E = Conversions->end(); + E = Conversions->end(); I != E; ++I) { NamedDecl *D = *I; CXXRecordDecl *ActingDC = cast(D->getDeclContext()); if (isa(D)) D = cast(D)->getTargetDecl(); - + FunctionTemplateDecl *ConvTemplate = dyn_cast(D); CXXConversionDecl *Conv; if (ConvTemplate) Conv = cast(ConvTemplate->getTemplatedDecl()); else Conv = cast(D); - + if (AllowExplicit || !Conv->isExplicit()) { if (ConvTemplate) S.AddTemplateConversionCandidate(ConvTemplate, I.getPair(), @@ -3002,19 +3002,19 @@ static void TryUserDefinedConversion(Sema &S, } } } - - // Perform overload resolution. If it fails, return the failed result. + + // Perform overload resolution. If it fails, return the failed result. OverloadCandidateSet::iterator Best; if (OverloadingResult Result = CandidateSet.BestViableFunction(S, DeclLoc, Best, true)) { Sequence.SetOverloadFailure( - InitializationSequence::FK_UserConversionOverloadFailed, + InitializationSequence::FK_UserConversionOverloadFailed, Result); return; } FunctionDecl *Function = Best->Function; - + if (isa(Function)) { // Add the user-defined conversion step. Any cv-qualification conversion is // subsumed by the initialization. @@ -3036,7 +3036,7 @@ static void TryUserDefinedConversion(Sema &S, } Sequence.AddUserConversionStep(Function, Best->FoundDecl, ConvType); - + // If the conversion following the call to the conversion function // is interesting, add it as a separate step. if (Best->FinalConversion.First || Best->FinalConversion.Second || @@ -3055,12 +3055,12 @@ InitializationSequence::InitializationSequence(Sema &S, unsigned NumArgs) : FailedCandidateSet(Kind.getLocation()) { ASTContext &Context = S.Context; - + // C++0x [dcl.init]p16: - // The semantics of initializers are as follows. The destination type is - // the type of the object or reference being initialized and the source + // The semantics of initializers are as follows. The destination type is + // the type of the object or reference being initialized and the source // type is the type of the initializer expression. The source type is not - // defined when the initializer is a braced-init-list or when it is a + // defined when the initializer is a braced-init-list or when it is a // parenthesized list of expressions. QualType DestType = Entity.getType(); @@ -3081,14 +3081,14 @@ InitializationSequence::InitializationSequence(Sema &S, if (!isa(Initializer)) SourceType = Initializer->getType(); } - - // - If the initializer is a braced-init-list, the object is + + // - If the initializer is a braced-init-list, the object is // list-initialized (8.5.4). if (InitListExpr *InitList = dyn_cast_or_null(Initializer)) { TryListInitialization(S, Entity, Kind, InitList, *this); return; } - + // - If the destination type is a reference type, see 8.5.3. if (DestType->isReferenceType()) { // C++0x [dcl.init.ref]p1: @@ -3102,36 +3102,36 @@ InitializationSequence::InitializationSequence(Sema &S, TryReferenceInitialization(S, Entity, Kind, Args[0], *this); return; } - - // - If the destination type is an array of characters, an array of - // char16_t, an array of char32_t, or an array of wchar_t, and the + + // - If the destination type is an array of characters, an array of + // char16_t, an array of char32_t, or an array of wchar_t, and the // initializer is a string literal, see 8.5.2. if (Initializer && IsStringInit(Initializer, DestType, Context)) { TryStringLiteralInitialization(S, Entity, Kind, Initializer, *this); return; } - + // - If the initializer is (), the object is value-initialized. if (Kind.getKind() == InitializationKind::IK_Value || (Kind.getKind() == InitializationKind::IK_Direct && NumArgs == 0)) { TryValueInitialization(S, Entity, Kind, *this); return; } - + // Handle default initialization. if (Kind.getKind() == InitializationKind::IK_Default) { TryDefaultInitialization(S, Entity, Kind, *this); return; } - // - Otherwise, if the destination type is an array, the program is + // - Otherwise, if the destination type is an array, the program is // ill-formed. if (const ArrayType *AT = Context.getAsArrayType(DestType)) { if (AT->getElementType()->isAnyCharacterType()) SetFailed(FK_ArrayNeedsInitListOrStringLiteral); else SetFailed(FK_ArrayNeedsInitList); - + return; } @@ -3141,22 +3141,22 @@ InitializationSequence::InitializationSequence(Sema &S, AddCAssignmentStep(DestType); return; } - + // - If the destination type is a (possibly cv-qualified) class type: if (DestType->isRecordType()) { - // - If the initialization is direct-initialization, or if it is - // copy-initialization where the cv-unqualified version of the - // source type is the same class as, or a derived class of, the + // - If the initialization is direct-initialization, or if it is + // copy-initialization where the cv-unqualified version of the + // source type is the same class as, or a derived class of, the // class of the destination, constructors are considered. [...] if (Kind.getKind() == InitializationKind::IK_Direct || (Kind.getKind() == InitializationKind::IK_Copy && (Context.hasSameUnqualifiedType(SourceType, DestType) || S.IsDerivedFrom(SourceType, DestType)))) - TryConstructorInitialization(S, Entity, Kind, Args, NumArgs, + TryConstructorInitialization(S, Entity, Kind, Args, NumArgs, Entity.getType(), *this); - // - Otherwise (i.e., for the remaining copy-initialization cases), + // - Otherwise (i.e., for the remaining copy-initialization cases), // user-defined conversion sequences that can convert from the source - // type to the destination type or (when a conversion function is + // type to the destination type or (when a conversion function is // used) to a derived class thereof are enumerated as described in // 13.3.1.4, and the best one is chosen through overload resolution // (13.3). @@ -3164,24 +3164,24 @@ InitializationSequence::InitializationSequence(Sema &S, TryUserDefinedConversion(S, Entity, Kind, Initializer, *this); return; } - + if (NumArgs > 1) { SetFailed(FK_TooManyInitsForScalar); return; } assert(NumArgs == 1 && "Zero-argument case handled above"); - - // - Otherwise, if the source type is a (possibly cv-qualified) class + + // - Otherwise, if the source type is a (possibly cv-qualified) class // type, conversion functions are considered. if (!SourceType.isNull() && SourceType->isRecordType()) { TryUserDefinedConversion(S, Entity, Kind, Initializer, *this); return; } - + // - Otherwise, the initial value of the object being initialized is the // (possibly converted) value of the initializer expression. Standard // conversions (Clause 4) will be used, if necessary, to convert the - // initializer expression to the cv-unqualified version of the + // initializer expression to the cv-unqualified version of the // destination type; no user-defined conversions are considered. if (S.TryImplicitConversion(*this, Entity, Initializer, /*SuppressUserConversions*/ true, @@ -3208,7 +3208,7 @@ InitializationSequence::~InitializationSequence() { //===----------------------------------------------------------------------===// // Perform initialization //===----------------------------------------------------------------------===// -static Sema::AssignmentAction +static Sema::AssignmentAction getAssignmentAction(const InitializedEntity &Entity) { switch(Entity.getKind()) { case InitializedEntity::EK_Variable: @@ -3218,7 +3218,7 @@ getAssignmentAction(const InitializedEntity &Entity) { return Sema::AA_Initializing; case InitializedEntity::EK_Parameter: - if (Entity.getDecl() && + if (Entity.getDecl() && isa(Entity.getDecl()->getDeclContext())) return Sema::AA_Sending; @@ -3230,7 +3230,7 @@ getAssignmentAction(const InitializedEntity &Entity) { case InitializedEntity::EK_Temporary: // FIXME: Can we tell apart casting vs. converting? return Sema::AA_Casting; - + case InitializedEntity::EK_Member: case InitializedEntity::EK_ArrayElement: case InitializedEntity::EK_VectorElement: @@ -3255,12 +3255,12 @@ static bool shouldBindAsTemporary(const InitializedEntity &Entity) { case InitializedEntity::EK_Exception: case InitializedEntity::EK_BlockElement: return false; - + case InitializedEntity::EK_Parameter: case InitializedEntity::EK_Temporary: return true; } - + llvm_unreachable("missed an InitializedEntity kind?"); } @@ -3275,7 +3275,7 @@ static bool shouldDestroyTemporary(const InitializedEntity &Entity) { case InitializedEntity::EK_VectorElement: case InitializedEntity::EK_BlockElement: return false; - + case InitializedEntity::EK_Variable: case InitializedEntity::EK_Parameter: case InitializedEntity::EK_Temporary: @@ -3283,8 +3283,8 @@ static bool shouldDestroyTemporary(const InitializedEntity &Entity) { case InitializedEntity::EK_Exception: return true; } - - llvm_unreachable("missed an InitializedEntity kind?"); + + llvm_unreachable("missed an InitializedEntity kind?"); } /// \brief Make a (potentially elidable) temporary copy of the object @@ -3314,7 +3314,7 @@ static ExprResult CopyObject(Sema &S, bool IsExtraneousCopy) { // Determine which class type we're copying to. Expr *CurInitExpr = (Expr *)CurInit.get(); - CXXRecordDecl *Class = 0; + CXXRecordDecl *Class = 0; if (const RecordType *Record = T->getAs()) Class = cast(Record->getDecl()); if (!Class) @@ -3330,10 +3330,10 @@ static ExprResult CopyObject(Sema &S, // with the same cv-unqualified type, the copy/move operation // can be omitted by constructing the temporary object // directly into the target of the omitted copy/move - // + // // Note that the other three bullets are handled elsewhere. Copy // elision for return statements and throw expressions are handled as part - // of constructor initialization, while copy elision for exception handlers + // of constructor initialization, while copy elision for exception handlers // is handled by the run-time. bool Elidable = CurInitExpr->isTemporaryObject(S.Context, Class); SourceLocation Loc; @@ -3341,11 +3341,11 @@ static ExprResult CopyObject(Sema &S, case InitializedEntity::EK_Result: Loc = Entity.getReturnLoc(); break; - + case InitializedEntity::EK_Exception: Loc = Entity.getThrowLoc(); break; - + case InitializedEntity::EK_Variable: Loc = Entity.getDecl()->getLocation(); break; @@ -3362,7 +3362,7 @@ static ExprResult CopyObject(Sema &S, break; } - // Make sure that the type we are copying is complete. + // Make sure that the type we are copying is complete. if (S.RequireCompleteType(Loc, T, S.PDiag(diag::err_temp_copy_incomplete))) return move(CurInit); @@ -3388,7 +3388,7 @@ static ExprResult CopyObject(Sema &S, S.AddOverloadCandidate(Constructor, FoundDecl, &CurInitExpr, 1, CandidateSet); continue; - } + } // Handle constructor templates. FunctionTemplateDecl *ConstructorTmpl = cast(*Con); @@ -3407,12 +3407,12 @@ static ExprResult CopyObject(Sema &S, S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, 0, &CurInitExpr, 1, CandidateSet, true); } - + OverloadCandidateSet::iterator Best; switch (CandidateSet.BestViableFunction(S, Loc, Best)) { case OR_Success: break; - + case OR_No_Viable_Function: S.Diag(Loc, IsExtraneousCopy && !S.isSFINAEContext() ? diag::ext_rvalue_to_reference_temp_copy_no_viable @@ -3423,14 +3423,14 @@ static ExprResult CopyObject(Sema &S, if (!IsExtraneousCopy || S.isSFINAEContext()) return ExprError(); return move(CurInit); - + case OR_Ambiguous: S.Diag(Loc, diag::err_temp_copy_ambiguous) << (int)Entity.getKind() << CurInitExpr->getType() << CurInitExpr->getSourceRange(); CandidateSet.NoteCandidates(S, OCD_ViableCandidates, &CurInitExpr, 1); return ExprError(); - + case OR_Deleted: S.Diag(Loc, diag::err_temp_copy_deleted) << (int)Entity.getKind() << CurInitExpr->getType() @@ -3472,7 +3472,7 @@ static ExprResult CopyObject(Sema &S, return S.Owned(CurInitExpr); } - + // Determine the arguments required to actually perform the // constructor call (we might have derived-to-base conversions, or // the copy constructor may have default arguments). @@ -3486,7 +3486,7 @@ static ExprResult CopyObject(Sema &S, /*ZeroInit*/ false, CXXConstructExpr::CK_Complete, SourceRange()); - + // If we're supposed to bind temporaries, do so. if (!CurInit.isInvalid() && shouldBindAsTemporary(Entity)) CurInit = S.MaybeBindToTemporary(CurInit.takeAs()); @@ -3507,7 +3507,7 @@ void InitializationSequence::PrintInitLocationNote(Sema &S, } } -ExprResult +ExprResult InitializationSequence::Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, @@ -3518,7 +3518,7 @@ InitializationSequence::Perform(Sema &S, Diagnose(S, Entity, Kind, (Expr **)Args.release(), NumArgs); return ExprError(); } - + if (SequenceKind == DependentSequence) { // If the declaration is a non-dependent, incomplete array type // that has an initializer, then its type will be completed once @@ -3568,14 +3568,14 @@ InitializationSequence::Perform(Sema &S, unsigned NumArgs = Args.size(); return S.Owned(new (S.Context) ParenListExpr(S.Context, SourceLocation(), - (Expr **)Args.release(), + (Expr **)Args.release(), NumArgs, SourceLocation())); } if (SequenceKind == NoInitialization) return S.Owned((Expr *)0); - + QualType DestType = Entity.getType().getNonReferenceType(); // FIXME: Ugly hack around the fact that Entity.getType() is not // the same as Entity.getDecl()->getType() in cases involving type merging, @@ -3585,10 +3585,10 @@ InitializationSequence::Perform(Sema &S, Entity.getType(); ExprResult CurInit = S.Owned((Expr *)0); - + assert(!Steps.empty() && "Cannot have an empty initialization sequence"); - - // For initialization steps that start with a single initializer, + + // For initialization steps that start with a single initializer, // grab the only argument out the Args and place it into the "current" // initializer. switch (Steps.front().Kind) { @@ -3619,26 +3619,26 @@ InitializationSequence::Perform(Sema &S, CurInit = ExprResult(CurInitExpr); break; } - + case SK_ConstructorInitialization: case SK_ZeroInitialization: break; } - - // Walk through the computed steps for the initialization sequence, + + // Walk through the computed steps for the initialization sequence, // performing the specified conversions along the way. bool ConstructorInitRequiresZeroInit = false; for (step_iterator Step = step_begin(), StepEnd = step_end(); Step != StepEnd; ++Step) { if (CurInit.isInvalid()) return ExprError(); - + Expr *CurInitExpr = CurInit.get(); QualType SourceType = CurInitExpr? CurInitExpr->getType() : QualType(); - + switch (Step->Kind) { case SK_ResolveAddressOfOverloadedFunction: - // Overload resolution determined which function invoke; update the + // Overload resolution determined which function invoke; update the // initializer to reflect that choice. S.CheckAddressOfMemberAccess(CurInitExpr, Step->Function.FoundDecl); S.DiagnoseUseOfDecl(Step->Function.FoundDecl, Kind.getLocation()); @@ -3646,29 +3646,29 @@ InitializationSequence::Perform(Sema &S, Step->Function.FoundDecl, Step->Function.Function); break; - + case SK_CastDerivedToBaseRValue: case SK_CastDerivedToBaseXValue: case SK_CastDerivedToBaseLValue: { // We have a derived-to-base cast that produces either an rvalue or an // lvalue. Perform that cast. - + CXXCastPath BasePath; // Casts to inaccessible base classes are allowed with C-style casts. bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast(); if (S.CheckDerivedToBaseConversion(SourceType, Step->Type, CurInitExpr->getLocStart(), - CurInitExpr->getSourceRange(), + CurInitExpr->getSourceRange(), &BasePath, IgnoreBaseAccess)) return ExprError(); - + if (S.BasePathInvolvesVirtualBase(BasePath)) { QualType T = SourceType; if (const PointerType *Pointer = T->getAs()) T = Pointer->getPointeeType(); if (const RecordType *RecordTy = T->getAs()) - S.MarkVTableUsed(CurInitExpr->getLocStart(), + S.MarkVTableUsed(CurInitExpr->getLocStart(), cast(RecordTy->getDecl())); } @@ -3685,7 +3685,7 @@ InitializationSequence::Perform(Sema &S, &BasePath, VK)); break; } - + case SK_BindReference: if (FieldDecl *BitField = CurInitExpr->getBitField()) { // References cannot bind to bit fields (C++ [dcl.init.ref]p5). @@ -3705,7 +3705,7 @@ InitializationSequence::Perform(Sema &S, PrintInitLocationNote(S, Entity); return ExprError(); } - + // Reference binding does not have any corresponding ASTs. // Check exception specifications @@ -3722,9 +3722,9 @@ InitializationSequence::Perform(Sema &S, return ExprError(); break; - + case SK_ExtraneousCopyToTemporary: - CurInit = CopyObject(S, Step->Type, Entity, move(CurInit), + CurInit = CopyObject(S, Step->Type, Entity, move(CurInit), /*IsExtraneousCopy=*/true); break; @@ -3749,9 +3749,9 @@ InitializationSequence::Perform(Sema &S, MultiExprArg(&CurInitExpr, 1), Loc, ConstructorArgs)) return ExprError(); - + // Build the an expression that constructs a temporary. - CurInit = S.BuildCXXConstructExpr(Loc, Step->Type, Constructor, + CurInit = S.BuildCXXConstructExpr(Loc, Step->Type, Constructor, move_arg(ConstructorArgs), /*ZeroInit*/ false, CXXConstructExpr::CK_Complete, @@ -3762,13 +3762,13 @@ InitializationSequence::Perform(Sema &S, S.CheckConstructorAccess(Kind.getLocation(), Constructor, Entity, FoundFn.getAccess()); S.DiagnoseUseOfDecl(FoundFn, Kind.getLocation()); - + CastKind = CK_ConstructorConversion; QualType Class = S.Context.getTypeDeclType(Constructor->getParent()); if (S.Context.hasSameUnqualifiedType(SourceType, Class) || S.IsDerivedFrom(SourceType, Class)) IsCopy = true; - + CreatedObject = true; } else { // Build a call to the conversion function. @@ -3777,8 +3777,8 @@ InitializationSequence::Perform(Sema &S, S.CheckMemberOperatorAccess(Kind.getLocation(), CurInitExpr, 0, FoundFn); S.DiagnoseUseOfDecl(FoundFn, Kind.getLocation()); - - // FIXME: Should we move this initialization into a separate + + // FIXME: Should we move this initialization into a separate // derived-to-base conversion? I believe the answer is "no", because // we don't want to turn off access control here for c-style casts. if (S.PerformObjectArgumentInitialization(CurInitExpr, /*Qualifier=*/0, @@ -3788,18 +3788,18 @@ InitializationSequence::Perform(Sema &S, // Do a little dance to make sure that CurInit has the proper // pointer. CurInit.release(); - + // Build the actual call to the conversion function. CurInit = S.BuildCXXMemberCallExpr(CurInitExpr, FoundFn, Conversion); if (CurInit.isInvalid() || !CurInit.get()) return ExprError(); - + CastKind = CK_UserDefinedConversion; - + CreatedObject = Conversion->getResultType()->isRecordType(); } - - bool RequiresCopy = !IsCopy && + + bool RequiresCopy = !IsCopy && getKind() != InitializationSequence::ReferenceBinding; if (RequiresCopy || shouldBindAsTemporary(Entity)) CurInit = S.MaybeBindToTemporary(CurInit.takeAs()); @@ -3807,22 +3807,22 @@ InitializationSequence::Perform(Sema &S, CurInitExpr = static_cast(CurInit.get()); QualType T = CurInitExpr->getType(); if (const RecordType *Record = T->getAs()) { - CXXDestructorDecl *Destructor + CXXDestructorDecl *Destructor = S.LookupDestructor(cast(Record->getDecl())); - S.CheckDestructorAccess(CurInitExpr->getLocStart(), Destructor, + S.CheckDestructorAccess(CurInitExpr->getLocStart(), Destructor, S.PDiag(diag::err_access_dtor_temp) << T); S.MarkDeclarationReferenced(CurInitExpr->getLocStart(), Destructor); S.DiagnoseUseOfDecl(Destructor, CurInitExpr->getLocStart()); } } - + CurInitExpr = CurInit.takeAs(); // FIXME: xvalues CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, CurInitExpr->getType(), CastKind, CurInitExpr, 0, IsLvalue ? VK_LValue : VK_RValue)); - + if (RequiresCopy) CurInit = CopyObject(S, Entity.getType().getNonReferenceType(), Entity, move(CurInit), /*IsExtraneousCopy=*/false); @@ -3851,12 +3851,12 @@ InitializationSequence::Perform(Sema &S, getAssignmentAction(Entity), Kind.isCStyleOrFunctionalCast())) return ExprError(); - + CurInit.release(); CurInit = S.Owned(CurInitExpr); break; } - + case SK_ListInitialization: { InitListExpr *InitList = cast(CurInitExpr); QualType Ty = Step->Type; @@ -3872,7 +3872,7 @@ InitializationSequence::Perform(Sema &S, unsigned NumArgs = Args.size(); CXXConstructorDecl *Constructor = cast(Step->Function.Function); - + // Build a call to the selected constructor. ASTOwningVector ConstructorArgs(S); SourceLocation Loc = (Kind.isCopyInit() && Kind.getEqualLoc().isValid()) @@ -3892,11 +3892,11 @@ InitializationSequence::Perform(Sema &S, // Determine the arguments required to actually perform the constructor // call. - if (S.CompleteConstructorCall(Constructor, move(Args), + if (S.CompleteConstructorCall(Constructor, move(Args), Loc, ConstructorArgs)) return ExprError(); - - + + if (Entity.getKind() == InitializedEntity::EK_Temporary && NumArgs != 1 && // FIXME: Hack to work around cast weirdness (Kind.getKind() == InitializationKind::IK_Direct || @@ -3906,28 +3906,28 @@ InitializationSequence::Perform(Sema &S, Expr **Exprs = (Expr **)ConstructorArgs.take(); S.MarkDeclarationReferenced(Loc, Constructor); S.DiagnoseUseOfDecl(Constructor, Loc); - + TypeSourceInfo *TSInfo = Entity.getTypeSourceInfo(); if (!TSInfo) TSInfo = S.Context.getTrivialTypeSourceInfo(Entity.getType(), Loc); - + CurInit = S.Owned(new (S.Context) CXXTemporaryObjectExpr(S.Context, Constructor, TSInfo, - Exprs, + Exprs, NumExprs, Kind.getParenRange(), ConstructorInitRequiresZeroInit)); } else { CXXConstructExpr::ConstructionKind ConstructKind = CXXConstructExpr::CK_Complete; - + if (Entity.getKind() == InitializedEntity::EK_Base) { ConstructKind = Entity.getBaseSpecifier()->isVirtual() ? - CXXConstructExpr::CK_VirtualBase : + CXXConstructExpr::CK_VirtualBase : CXXConstructExpr::CK_NonVirtualBase; - } - + } + // Only get the parenthesis range if it is a direct construction. SourceRange parenRange = Kind.getKind() == InitializationKind::IK_Direct ? @@ -3944,7 +3944,7 @@ InitializationSequence::Perform(Sema &S, parenRange); else CurInit = S.BuildCXXConstructExpr(Loc, Entity.getType(), - Constructor, + Constructor, move_arg(ConstructorArgs), ConstructorInitRequiresZeroInit, ConstructKind, @@ -3957,17 +3957,17 @@ InitializationSequence::Perform(Sema &S, S.CheckConstructorAccess(Loc, Constructor, Entity, Step->Function.FoundDecl.getAccess()); S.DiagnoseUseOfDecl(Step->Function.FoundDecl, Loc); - + if (shouldBindAsTemporary(Entity)) CurInit = S.MaybeBindToTemporary(CurInit.takeAs()); - + break; } - + case SK_ZeroInitialization: { step_iterator NextStep = Step; ++NextStep; - if (NextStep != StepEnd && + if (NextStep != StepEnd && NextStep->Kind == SK_ConstructorInitialization) { // The need for zero-initialization is recorded directly into // the call to the object's constructor within the next step. @@ -3977,7 +3977,7 @@ InitializationSequence::Perform(Sema &S, !Kind.isImplicitValueInit()) { TypeSourceInfo *TSInfo = Entity.getTypeSourceInfo(); if (!TSInfo) - TSInfo = S.Context.getTrivialTypeSourceInfo(Step->Type, + TSInfo = S.Context.getTrivialTypeSourceInfo(Step->Type, Kind.getRange().getBegin()); CurInit = S.Owned(new (S.Context) CXXScalarValueInitExpr( @@ -4005,7 +4005,7 @@ InitializationSequence::Perform(Sema &S, bool Complained; if (S.DiagnoseAssignmentResult(ConvTy, Kind.getLocation(), Step->Type, SourceType, - CurInitExpr, + CurInitExpr, getAssignmentAction(Entity), &Complained)) { PrintInitLocationNote(S, Entity); @@ -4025,7 +4025,7 @@ InitializationSequence::Perform(Sema &S, } case SK_ObjCObjectConversion: - S.ImpCastExprToType(CurInitExpr, Step->Type, + S.ImpCastExprToType(CurInitExpr, Step->Type, CK_ObjCObjectLValueCast, S.CastCategory(CurInitExpr)); CurInit.release(); @@ -4040,20 +4040,20 @@ InitializationSequence::Perform(Sema &S, S.CheckBitFieldInitialization(Kind.getLocation(), cast(Entity.getDecl()), CurInit.get()); - + return move(CurInit); } //===----------------------------------------------------------------------===// // Diagnose initialization failures //===----------------------------------------------------------------------===// -bool InitializationSequence::Diagnose(Sema &S, +bool InitializationSequence::Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, Expr **Args, unsigned NumArgs) { if (SequenceKind != FailedSequence) return false; - + QualType DestType = Entity.getType(); switch (Failure) { case FK_TooManyInitsForReference: @@ -4065,22 +4065,22 @@ bool InitializationSequence::Diagnose(Sema &S, S.Diag(Kind.getLocation(), diag::err_reference_has_multiple_inits) << SourceRange(Args[0]->getLocStart(), Args[NumArgs - 1]->getLocEnd()); break; - + case FK_ArrayNeedsInitList: case FK_ArrayNeedsInitListOrStringLiteral: S.Diag(Kind.getLocation(), diag::err_array_init_not_init_list) << (Failure == FK_ArrayNeedsInitListOrStringLiteral); break; - + case FK_AddressOfOverloadFailed: { DeclAccessPair Found; - S.ResolveAddressOfOverloadedFunction(Args[0], + S.ResolveAddressOfOverloadedFunction(Args[0], DestType.getNonReferenceType(), true, Found); break; } - + case FK_ReferenceInitOverloadFailed: case FK_UserConversionOverloadFailed: switch (FailedOverloadResult) { @@ -4096,14 +4096,14 @@ bool InitializationSequence::Diagnose(Sema &S, FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates, Args, NumArgs); break; - + case OR_No_Viable_Function: S.Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition) << Args[0]->getType() << DestType.getNonReferenceType() << Args[0]->getSourceRange(); FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args, NumArgs); break; - + case OR_Deleted: { S.Diag(Kind.getLocation(), diag::err_typecheck_deleted_function) << Args[0]->getType() << DestType.getNonReferenceType() @@ -4120,16 +4120,16 @@ bool InitializationSequence::Diagnose(Sema &S, } break; } - + case OR_Success: llvm_unreachable("Conversion did not fail!"); break; } break; - + case FK_NonConstLValueReferenceBindingToTemporary: case FK_NonConstLValueReferenceBindingToUnrelated: - S.Diag(Kind.getLocation(), + S.Diag(Kind.getLocation(), Failure == FK_NonConstLValueReferenceBindingToTemporary ? diag::err_lvalue_reference_bind_to_temporary : diag::err_lvalue_reference_bind_to_unrelated) @@ -4138,20 +4138,20 @@ bool InitializationSequence::Diagnose(Sema &S, << Args[0]->getType() << Args[0]->getSourceRange(); break; - + case FK_RValueReferenceBindingToLValue: S.Diag(Kind.getLocation(), diag::err_lvalue_to_rvalue_ref) << DestType.getNonReferenceType() << Args[0]->getType() << Args[0]->getSourceRange(); break; - + case FK_ReferenceInitDropsQualifiers: S.Diag(Kind.getLocation(), diag::err_reference_bind_drops_quals) << DestType.getNonReferenceType() << Args[0]->getType() << Args[0]->getSourceRange(); break; - + case FK_ReferenceInitFailed: S.Diag(Kind.getLocation(), diag::err_reference_bind_failed) << DestType.getNonReferenceType() @@ -4159,7 +4159,7 @@ bool InitializationSequence::Diagnose(Sema &S, << Args[0]->getType() << Args[0]->getSourceRange(); break; - + case FK_ConversionFailed: S.Diag(Kind.getLocation(), diag::err_init_conversion_failed) << (int)Entity.getKind() @@ -4175,7 +4175,7 @@ bool InitializationSequence::Diagnose(Sema &S, if (InitListExpr *InitList = dyn_cast(Args[0])) R = SourceRange(InitList->getInit(0)->getLocEnd(), InitList->getLocEnd()); - else + else R = SourceRange(Args[0]->getLocEnd(), Args[NumArgs - 1]->getLocEnd()); R.setBegin(S.PP.getLocForEndOfToken(R.getBegin())); @@ -4197,13 +4197,13 @@ bool InitializationSequence::Diagnose(Sema &S, S.Diag(Kind.getLocation(), diag::err_init_list_bad_dest_type) << (DestType->isRecordType()) << DestType << Args[0]->getSourceRange(); break; - + case FK_ConstructorOverloadFailed: { SourceRange ArgsRange; if (NumArgs) - ArgsRange = SourceRange(Args[0]->getLocStart(), + ArgsRange = SourceRange(Args[0]->getLocStart(), Args[NumArgs - 1]->getLocEnd()); - + // FIXME: Using "DestType" for the entity we're printing is probably // bad. switch (FailedOverloadResult) { @@ -4213,7 +4213,7 @@ bool InitializationSequence::Diagnose(Sema &S, FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates, Args, NumArgs); break; - + case OR_No_Viable_Function: if (Kind.getKind() == InitializationKind::IK_Default && (Entity.getKind() == InitializedEntity::EK_Base || @@ -4247,7 +4247,7 @@ bool InitializationSequence::Diagnose(Sema &S, if (const RecordType *Record = Entity.getType()->getAs()) - S.Diag(Record->getDecl()->getLocation(), + S.Diag(Record->getDecl()->getLocation(), diag::note_previous_decl) << S.Context.getTagDeclType(Record->getDecl()); } @@ -4258,7 +4258,7 @@ bool InitializationSequence::Diagnose(Sema &S, << DestType << ArgsRange; FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args, NumArgs); break; - + case OR_Deleted: { S.Diag(Kind.getLocation(), diag::err_ovl_deleted_init) << true << DestType << ArgsRange; @@ -4273,14 +4273,14 @@ bool InitializationSequence::Diagnose(Sema &S, } break; } - + case OR_Success: llvm_unreachable("Conversion did not fail!"); break; } break; } - + case FK_DefaultInitOfConst: if (Entity.getKind() == InitializedEntity::EK_Member && isa(S.CurContext)) { @@ -4300,13 +4300,13 @@ bool InitializationSequence::Diagnose(Sema &S, << DestType << (bool)DestType->getAs(); } break; - + case FK_Incomplete: - S.RequireCompleteType(Kind.getLocation(), DestType, + S.RequireCompleteType(Kind.getLocation(), DestType, diag::err_init_incomplete_type); - break; + break; } - + PrintInitLocationNote(S, Entity); return true; } @@ -4319,95 +4319,95 @@ void InitializationSequence::dump(llvm::raw_ostream &OS) const { case FK_TooManyInitsForReference: OS << "too many initializers for reference"; break; - + case FK_ArrayNeedsInitList: OS << "array requires initializer list"; break; - + case FK_ArrayNeedsInitListOrStringLiteral: OS << "array requires initializer list or string literal"; break; - + case FK_AddressOfOverloadFailed: OS << "address of overloaded function failed"; break; - + case FK_ReferenceInitOverloadFailed: OS << "overload resolution for reference initialization failed"; break; - + case FK_NonConstLValueReferenceBindingToTemporary: OS << "non-const lvalue reference bound to temporary"; break; - + case FK_NonConstLValueReferenceBindingToUnrelated: OS << "non-const lvalue reference bound to unrelated type"; break; - + case FK_RValueReferenceBindingToLValue: OS << "rvalue reference bound to an lvalue"; break; - + case FK_ReferenceInitDropsQualifiers: OS << "reference initialization drops qualifiers"; break; - + case FK_ReferenceInitFailed: OS << "reference initialization failed"; break; - + case FK_ConversionFailed: OS << "conversion failed"; break; - + case FK_TooManyInitsForScalar: OS << "too many initializers for scalar"; break; - + case FK_ReferenceBindingToInitList: OS << "referencing binding to initializer list"; break; - + case FK_InitListBadDestinationType: OS << "initializer list for non-aggregate, non-scalar type"; break; - + case FK_UserConversionOverloadFailed: OS << "overloading failed for user-defined conversion"; break; - + case FK_ConstructorOverloadFailed: OS << "constructor overloading failed"; break; - + case FK_DefaultInitOfConst: OS << "default initialization of a const variable"; break; - + case FK_Incomplete: OS << "initialization of incomplete type"; break; - } + } OS << '\n'; return; } - + case DependentSequence: OS << "Dependent sequence: "; return; - + case UserDefinedConversion: OS << "User-defined conversion sequence: "; break; - + case ConstructorInitialization: OS << "Constructor initialization sequence: "; break; - + case ReferenceBinding: OS << "Reference binding: "; break; - + case ListInitialization: OS << "List initialization: "; break; @@ -4415,54 +4415,54 @@ void InitializationSequence::dump(llvm::raw_ostream &OS) const { case ZeroInitialization: OS << "Zero initialization\n"; return; - + case NoInitialization: OS << "No initialization\n"; return; - + case StandardConversion: OS << "Standard conversion: "; break; - + case CAssignment: OS << "C assignment: "; break; - + case StringInit: OS << "String initialization: "; break; } - + for (step_iterator S = step_begin(), SEnd = step_end(); S != SEnd; ++S) { if (S != step_begin()) { OS << " -> "; } - + switch (S->Kind) { case SK_ResolveAddressOfOverloadedFunction: OS << "resolve address of overloaded function"; break; - + case SK_CastDerivedToBaseRValue: OS << "derived-to-base case (rvalue" << S->Type.getAsString() << ")"; break; - + case SK_CastDerivedToBaseXValue: OS << "derived-to-base case (xvalue" << S->Type.getAsString() << ")"; break; - + case SK_CastDerivedToBaseLValue: OS << "derived-to-base case (lvalue" << S->Type.getAsString() << ")"; break; - + case SK_BindReference: OS << "bind reference to lvalue"; break; - + case SK_BindReferenceToTemporary: OS << "bind reference to a temporary"; break; - + case SK_ExtraneousCopyToTemporary: OS << "extraneous C++03 copy to temporary"; break; @@ -4480,29 +4480,29 @@ void InitializationSequence::dump(llvm::raw_ostream &OS) const { case SK_QualificationConversionLValue: OS << "qualification conversion (lvalue)"; break; - + case SK_ConversionSequence: OS << "implicit conversion sequence ("; S->ICS->DebugPrint(); // FIXME: use OS OS << ")"; break; - + case SK_ListInitialization: OS << "list initialization"; break; - + case SK_ConstructorInitialization: OS << "constructor initialization"; break; - + case SK_ZeroInitialization: OS << "zero initialization"; break; - + case SK_CAssignment: OS << "C assignment"; break; - + case SK_StringInit: OS << "string initialization"; break; @@ -4521,7 +4521,7 @@ void InitializationSequence::dump() const { //===----------------------------------------------------------------------===// // Initialization helper functions //===----------------------------------------------------------------------===// -ExprResult +ExprResult Sema::PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init) { diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 3b7fa0a3ac..ec633d177c 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -91,7 +91,7 @@ namespace { UnqualUsingDirectiveSet() {} void visitScopeChain(Scope *S, Scope *InnermostFileScope) { - // C++ [namespace.udir]p1: + // C++ [namespace.udir]p1: // During unqualified name lookup, the names appear as if they // were declared in the nearest enclosing namespace which contains // both the using-directive and the nominated namespace. @@ -106,7 +106,7 @@ namespace { } else { Scope::udir_iterator I = S->using_directives_begin(), End = S->using_directives_end(); - + for (; I != End; ++I) visit(*I, InnermostFileDC); } @@ -177,7 +177,7 @@ namespace { while (!Common->Encloses(EffectiveDC)) Common = Common->getParent(); Common = Common->getPrimaryContext(); - + list.push_back(UnqualUsingEntry(UD->getNominatedNamespace(), Common)); } @@ -186,7 +186,7 @@ namespace { } typedef ListTy::const_iterator const_iterator; - + const_iterator begin() const { return list.begin(); } const_iterator end() const { return list.end(); } @@ -259,9 +259,9 @@ static inline unsigned getIDNS(Sema::LookupNameKind NameKind, case Sema::LookupObjCProtocolName: IDNS = Decl::IDNS_ObjCProtocol; break; - + case Sema::LookupAnyName: - IDNS = Decl::IDNS_Ordinary | Decl::IDNS_Tag | Decl::IDNS_Member + IDNS = Decl::IDNS_Ordinary | Decl::IDNS_Tag | Decl::IDNS_Member | Decl::IDNS_Using | Decl::IDNS_Namespace | Decl::IDNS_ObjCProtocol | Decl::IDNS_Type; break; @@ -315,7 +315,7 @@ void LookupResult::deletePaths(CXXBasePaths *Paths) { /// Resolves the result kind of this lookup. void LookupResult::resolveKind() { unsigned N = Decls.size(); - + // Fast case: no possible ambiguity. if (N == 0) { assert(ResultKind == NotFound || ResultKind == NotFoundInCurrentInstantiation); @@ -338,13 +338,13 @@ void LookupResult::resolveKind() { llvm::SmallPtrSet Unique; llvm::SmallPtrSet UniqueTypes; - + bool Ambiguous = false; bool HasTag = false, HasFunction = false, HasNonFunction = false; bool HasFunctionTemplate = false, HasUnresolved = false; unsigned UniqueTagIndex = 0; - + unsigned I = 0; while (I < N) { NamedDecl *D = Decls[I]->getUnderlyingDecl(); @@ -365,14 +365,14 @@ void LookupResult::resolveKind() { } } } - + if (!Unique.insert(D)) { // If it's not unique, pull something off the back (and // continue at this index). Decls[I] = Decls[--N]; continue; - } - + } + // Otherwise, do some decl type analysis and then continue. if (isa(D)) { @@ -456,7 +456,7 @@ void LookupResult::print(llvm::raw_ostream &Out) { Out << Decls.size() << " result(s)"; if (isAmbiguous()) Out << ", ambiguous"; if (Paths) Out << ", base paths present"; - + for (iterator I = begin(), E = end(); I != E; ++I) { Out << "\n"; (*I)->print(Out, 2); @@ -482,9 +482,9 @@ static bool LookupBuiltin(Sema &S, LookupResult &R) { if (S.getLangOptions().CPlusPlus && S.Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) return false; - - if (NamedDecl *D = S.LazilyCreateBuiltin((IdentifierInfo *)II, - BuiltinID, S.TUScope, + + if (NamedDecl *D = S.LazilyCreateBuiltin((IdentifierInfo *)II, + BuiltinID, S.TUScope, R.isForRedeclaration(), R.getNameLoc())) { R.addDecl(D); @@ -512,16 +512,16 @@ static bool CanDeclareSpecialMemberFunction(ASTContext &Context, // Don't do it if the class is invalid. if (Class->isInvalidDecl()) return false; - + // We need to have a definition for the class. if (!Class->getDefinition() || Class->isDependentContext()) return false; - + // We can't be in the middle of defining the class. if (const RecordType *RecordTy = Context.getTypeDeclType(Class)->getAs()) return !RecordTy->isBeingDefined(); - + return false; } @@ -532,46 +532,46 @@ void Sema::ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class) { // If the default constructor has not yet been declared, do so now. if (!Class->hasDeclaredDefaultConstructor()) DeclareImplicitDefaultConstructor(Class); - + // If the copy constructor has not yet been declared, do so now. if (!Class->hasDeclaredCopyConstructor()) DeclareImplicitCopyConstructor(Class); - + // If the copy assignment operator has not yet been declared, do so now. if (!Class->hasDeclaredCopyAssignment()) DeclareImplicitCopyAssignment(Class); // If the destructor has not yet been declared, do so now. if (!Class->hasDeclaredDestructor()) - DeclareImplicitDestructor(Class); + DeclareImplicitDestructor(Class); } -/// \brief Determine whether this is the name of an implicitly-declared +/// \brief Determine whether this is the name of an implicitly-declared /// special member function. static bool isImplicitlyDeclaredMemberFunctionName(DeclarationName Name) { switch (Name.getNameKind()) { case DeclarationName::CXXConstructorName: case DeclarationName::CXXDestructorName: return true; - + case DeclarationName::CXXOperatorName: return Name.getCXXOverloadedOperator() == OO_Equal; - + default: - break; + break; } - + return false; } /// \brief If there are any implicit member functions with the given name /// that need to be declared in the given declaration context, do so. -static void DeclareImplicitMemberFunctionsWithName(Sema &S, +static void DeclareImplicitMemberFunctionsWithName(Sema &S, DeclarationName Name, const DeclContext *DC) { if (!DC) return; - + switch (Name.getNameKind()) { case DeclarationName::CXXConstructorName: if (const CXXRecordDecl *Record = dyn_cast(DC)) @@ -584,26 +584,26 @@ static void DeclareImplicitMemberFunctionsWithName(Sema &S, S.DeclareImplicitCopyConstructor(const_cast(Record)); } break; - + case DeclarationName::CXXDestructorName: if (const CXXRecordDecl *Record = dyn_cast(DC)) if (Record->getDefinition() && !Record->hasDeclaredDestructor() && CanDeclareSpecialMemberFunction(S.Context, Record)) S.DeclareImplicitDestructor(const_cast(Record)); break; - + case DeclarationName::CXXOperatorName: if (Name.getCXXOverloadedOperator() != OO_Equal) break; - + if (const CXXRecordDecl *Record = dyn_cast(DC)) if (Record->getDefinition() && !Record->hasDeclaredCopyAssignment() && CanDeclareSpecialMemberFunction(S.Context, Record)) S.DeclareImplicitCopyAssignment(const_cast(Record)); break; - + default: - break; + break; } } @@ -615,7 +615,7 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { // Lazily declare C++ special member functions. if (S.getLangOptions().CPlusPlus) DeclareImplicitMemberFunctionsWithName(S, R.getLookupName(), DC); - + // Perform lookup into this declaration context. DeclContext::lookup_const_iterator I, E; for (llvm::tie(I, E) = DC->lookup(R.getLookupName()); I != E; ++I) { @@ -636,7 +636,7 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { return Found; // C++ [temp.mem]p6: - // A specialization of a conversion function template is not found by + // A specialization of a conversion function template is not found by // name lookup. Instead, any conversion function templates visible in the // context of the use are considered. [...] const CXXRecordDecl *Record = cast(DC); @@ -644,36 +644,36 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { return Found; const UnresolvedSetImpl *Unresolved = Record->getConversionFunctions(); - for (UnresolvedSetImpl::iterator U = Unresolved->begin(), + for (UnresolvedSetImpl::iterator U = Unresolved->begin(), UEnd = Unresolved->end(); U != UEnd; ++U) { FunctionTemplateDecl *ConvTemplate = dyn_cast(*U); if (!ConvTemplate) continue; - + // When we're performing lookup for the purposes of redeclaration, just - // add the conversion function template. When we deduce template - // arguments for specializations, we'll end up unifying the return + // add the conversion function template. When we deduce template + // arguments for specializations, we'll end up unifying the return // type of the new declaration with the type of the function template. if (R.isForRedeclaration()) { R.addDecl(ConvTemplate); Found = true; continue; } - + // C++ [temp.mem]p6: - // [...] For each such operator, if argument deduction succeeds - // (14.9.2.3), the resulting specialization is used as if found by + // [...] For each such operator, if argument deduction succeeds + // (14.9.2.3), the resulting specialization is used as if found by // name lookup. // // When referencing a conversion function for any purpose other than // a redeclaration (such that we'll be building an expression with the - // result), perform template argument deduction and place the + // result), perform template argument deduction and place the // specialization into the result set. We do this to avoid forcing all // callers to perform special deduction for conversion functions. TemplateDeductionInfo Info(R.getSema().Context, R.getNameLoc()); FunctionDecl *Specialization = 0; - - const FunctionProtoType *ConvProto + + const FunctionProtoType *ConvProto = ConvTemplate->getTemplatedDecl()->getType()->getAs(); assert(ConvProto && "Nonsensical conversion function template type"); @@ -688,7 +688,7 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { QualType ExpectedType = R.getSema().Context.getFunctionType(R.getLookupName().getCXXNameType(), 0, 0, EPI); - + // Perform template argument deduction against the type that we would // expect the function to have. if (R.getSema().DeduceTemplateArguments(ConvTemplate, 0, ExpectedType, @@ -704,7 +704,7 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { // Performs C++ unqualified lookup into the given file context. static bool -CppNamespaceLookup(Sema &S, LookupResult &R, ASTContext &Context, +CppNamespaceLookup(Sema &S, LookupResult &R, ASTContext &Context, DeclContext *NS, UnqualUsingDirectiveSet &UDirs) { assert(NS && NS->isFileContext() && "CppNamespaceLookup() requires namespace!"); @@ -742,7 +742,7 @@ static bool isNamespaceOrTranslationUnitScope(Scope *S) { static std::pair findOuterContext(Scope *S) { DeclContext *DC = static_cast(S->getEntity()); DeclContext *Lexical = 0; - for (Scope *OuterS = S->getParent(); OuterS; + for (Scope *OuterS = S->getParent(); OuterS; OuterS = OuterS->getParent()) { if (OuterS->getEntity()) { Lexical = static_cast(OuterS->getEntity()); @@ -758,12 +758,12 @@ static std::pair findOuterContext(Scope *S) { // // Example: // - // namespace N { - // class C { }; + // namespace N { + // class C { }; // // template class B { // void f(T); - // }; + // }; // } // // template void N::B::f(C) { @@ -772,24 +772,24 @@ static std::pair findOuterContext(Scope *S) { // // In this example, the lexical context we return is the // TranslationUnit, while the semantic context is the namespace N. - if (!Lexical || !DC || !S->getParent() || + if (!Lexical || !DC || !S->getParent() || !S->getParent()->isTemplateParamScope()) return std::make_pair(Lexical, false); - // Find the outermost template parameter scope. + // Find the outermost template parameter scope. // For the example, this is the scope for the template parameters of // template. Scope *OutermostTemplateScope = S->getParent(); while (OutermostTemplateScope->getParent() && OutermostTemplateScope->getParent()->isTemplateParamScope()) OutermostTemplateScope = OutermostTemplateScope->getParent(); - + // Find the namespace context in which the original scope occurs. In // the example, this is namespace N. DeclContext *Semantic = DC; while (!Semantic->isFileContext()) Semantic = Semantic->getParent(); - + // Find the declaration context just outside of the template // parameter scope. This is the context in which the template is // being lexically declaration (a namespace context). In the @@ -813,7 +813,7 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { if (DeclContext *DC = static_cast(PreS->getEntity())) DeclareImplicitMemberFunctionsWithName(*this, Name, DC); } - + // Implicitly declare member functions with the name we're looking for, if in // fact we are in a scope where it matters. @@ -896,7 +896,7 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { if (ObjCInterfaceDecl *Class = Method->getClassInterface()) { ObjCInterfaceDecl *ClassDeclared; if (ObjCIvarDecl *Ivar = Class->lookupInstanceVariable( - Name.getAsIdentifierInfo(), + Name.getAsIdentifierInfo(), ClassDeclared)) { if (R.isAcceptableDecl(Ivar)) { R.addDecl(Ivar); @@ -975,7 +975,7 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { Ctx = OutsideOfTemplateParamDC; OutsideOfTemplateParamDC = 0; } - + if (Ctx) { DeclContext *OuterCtx; bool SearchAfterTemplateScope; @@ -989,24 +989,24 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) { // non-transparent context. if (Ctx->isTransparentContext()) continue; - + // If we have a context, and it's not a context stashed in the // template parameter scope for an out-of-line definition, also // look into that context. if (!(Found && S && S->isTemplateParamScope())) { assert(Ctx->isFileContext() && "We should have been looking only at file context here already."); - + // Look into context considering using-directives. if (CppNamespaceLookup(*this, R, Context, Ctx, UDirs)) Found = true; } - + if (Found) { R.resolveKind(); return true; } - + if (R.isForRedeclaration() && !Ctx->isTransparentContext()) return false; } @@ -1245,41 +1245,41 @@ static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R, } /// \brief Callback that looks for any member of a class with the given name. -static bool LookupAnyMember(const CXXBaseSpecifier *Specifier, +static bool LookupAnyMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, void *Name) { RecordDecl *BaseRecord = Specifier->getType()->getAs()->getDecl(); - + DeclarationName N = DeclarationName::getFromOpaquePtr(Name); Path.Decls = BaseRecord->lookup(N); return Path.Decls.first != Path.Decls.second; } -/// \brief Determine whether the given set of member declarations contains only +/// \brief Determine whether the given set of member declarations contains only /// static members, nested types, and enumerators. template static bool HasOnlyStaticMembers(InputIterator First, InputIterator Last) { Decl *D = (*First)->getUnderlyingDecl(); if (isa(D) || isa(D) || isa(D)) return true; - + if (isa(D)) { // Determine whether all of the methods are static. bool AllMethodsAreStatic = true; for(; First != Last; ++First) { D = (*First)->getUnderlyingDecl(); - + if (!isa(D)) { assert(isa(D) && "Non-function must be a tag decl"); break; } - + if (!cast(D)->isStatic()) { AllMethodsAreStatic = false; break; } } - + if (AllMethodsAreStatic) return true; } @@ -1305,7 +1305,7 @@ static bool HasOnlyStaticMembers(InputIterator First, InputIterator Last) { /// search. If the lookup criteria permits, name lookup may also search /// in the parent contexts or (for C++ classes) base classes. /// -/// \param InUnqualifiedLookup true if this is qualified name lookup that +/// \param InUnqualifiedLookup true if this is qualified name lookup that /// occurs as part of unqualified name lookup. /// /// \returns true if lookup succeeded, false if it failed. @@ -1356,7 +1356,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, // If we're performing qualified name lookup into a dependent class, // then we are actually looking into a current instantiation. If we have any - // dependent base classes, then we either have to delay lookup until + // dependent base classes, then we either have to delay lookup until // template instantiation time (at which point all bases will be available) // or we have to fail. if (!InUnqualifiedLookup && LookupRec->isDependentContext() && @@ -1364,7 +1364,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, R.setNotFoundInCurrentInstantiation(); return false; } - + // Perform lookup into our base classes. CXXBasePaths Paths; Paths.setOrigin(LookupRec); @@ -1377,7 +1377,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, case LookupRedeclarationWithLinkage: BaseCallback = &CXXRecordDecl::FindOrdinaryMember; break; - + case LookupTagName: BaseCallback = &CXXRecordDecl::FindTagMember; break; @@ -1385,21 +1385,21 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, case LookupAnyName: BaseCallback = &LookupAnyMember; break; - + case LookupUsingDeclName: // This lookup is for redeclarations only. - + case LookupOperatorName: case LookupNamespaceName: case LookupObjCProtocolName: // These lookups will never find a member in a C++ class (or base class). return false; - + case LookupNestedNameSpecifierName: BaseCallback = &CXXRecordDecl::FindNestedNameSpecifierMember; break; } - + if (!LookupRec->lookupInBases(BaseCallback, R.getLookupName().getAsOpaquePtr(), Paths)) return false; @@ -1415,7 +1415,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, QualType SubobjectType; int SubobjectNumber = 0; AccessSpecifier SubobjectAccess = AS_none; - + for (CXXBasePaths::paths_iterator Path = Paths.begin(), PathEnd = Paths.end(); Path != PathEnd; ++Path) { const CXXBasePathElement &PathElement = Path->back(); @@ -1423,15 +1423,15 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, // Pick the best (i.e. most permissive i.e. numerically lowest) access // across all paths. SubobjectAccess = std::min(SubobjectAccess, Path->Access); - + // Determine whether we're looking at a distinct sub-object or not. if (SubobjectType.isNull()) { // This is the first subobject we've looked at. Record its type. SubobjectType = Context.getCanonicalType(PathElement.Base->getType()); SubobjectNumber = PathElement.SubobjectNumber; continue; - } - + } + if (SubobjectType != Context.getCanonicalType(PathElement.Base->getType())) { // We found members of the given name in two subobjects of @@ -1441,26 +1441,26 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, CXXBasePaths::paths_iterator FirstPath = Paths.begin(); DeclContext::lookup_iterator FirstD = FirstPath->Decls.first; DeclContext::lookup_iterator CurrentD = Path->Decls.first; - + while (FirstD != FirstPath->Decls.second && CurrentD != Path->Decls.second) { if ((*FirstD)->getUnderlyingDecl()->getCanonicalDecl() != (*CurrentD)->getUnderlyingDecl()->getCanonicalDecl()) break; - + ++FirstD; ++CurrentD; } - + if (FirstD == FirstPath->Decls.second && CurrentD == Path->Decls.second) continue; } - + R.setAmbiguousBaseSubobjectTypes(Paths); return true; - } - + } + if (SubobjectNumber != PathElement.SubobjectNumber) { // We have a different subobject of the same type. @@ -1470,7 +1470,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, // has more than one base class subobject of type T. if (HasOnlyStaticMembers(Path->Decls.first, Path->Decls.second)) continue; - + // We have found a nonstatic member name in multiple, distinct // subobjects. Name lookup is ambiguous. R.setAmbiguousBaseSubobjects(Paths); @@ -1570,21 +1570,21 @@ bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result) { Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects) << Name << SubobjectType << getAmbiguousPathsDisplayString(*Paths) << LookupRange; - + DeclContext::lookup_iterator Found = Paths->front().Decls.first; while (isa(*Found) && cast(*Found)->isStatic()) ++Found; - + Diag((*Found)->getLocation(), diag::note_ambiguous_member_found); - + return true; } case LookupResult::AmbiguousBaseSubobjectTypes: { Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types) << Name << LookupRange; - + CXXBasePaths *Paths = Result.getBasePaths(); std::set DeclsPrinted; for (CXXBasePaths::paths_iterator Path = Paths->begin(), @@ -1627,7 +1627,7 @@ bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result) { case LookupResult::AmbiguousReference: { Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange; - + LookupResult::iterator DI = Result.begin(), DE = Result.end(); for (; DI != DE; ++DI) Diag((*DI)->getLocation(), diag::note_ambiguous_candidate) << *DI; @@ -1693,7 +1693,7 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, addAssociatedClassesAndNamespaces(Result, Arg.getAsType()); break; - case TemplateArgument::Template: + case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: { // [...] the namespaces in which any template template arguments are // defined; and the classes in which any member templates used as @@ -1709,7 +1709,7 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, } break; } - + case TemplateArgument::Declaration: case TemplateArgument::Integral: case TemplateArgument::Expression: @@ -2078,7 +2078,7 @@ NamedDecl *Sema::LookupSingleName(Scope *S, DeclarationName Name, } /// \brief Find the protocol with the given name, if any. -ObjCProtocolDecl *Sema::LookupProtocol(IdentifierInfo *II, +ObjCProtocolDecl *Sema::LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc) { Decl *D = LookupSingleName(TUScope, II, IdLoc, LookupObjCProtocolName); @@ -2135,7 +2135,7 @@ DeclContext::lookup_result Sema::LookupConstructors(CXXRecordDecl *Class) { if (!Class->hasDeclaredCopyConstructor()) DeclareImplicitCopyConstructor(Class); } - + CanQualType T = Context.getCanonicalType(Context.getTypeDeclType(Class)); DeclarationName Name = Context.DeclarationNames.getCXXConstructorName(T); return Class->lookup(Name); @@ -2143,7 +2143,7 @@ DeclContext::lookup_result Sema::LookupConstructors(CXXRecordDecl *Class) { /// \brief Look for the destructor of the given class. /// -/// During semantic analysis, this routine should be used in lieu of +/// During semantic analysis, this routine should be used in lieu of /// CXXRecordDecl::getDestructor(). /// /// \returns The destructor for this class. @@ -2279,7 +2279,7 @@ public: /// of declarations. class ShadowMapEntry { typedef llvm::SmallVector DeclVector; - + /// \brief Contains either the solitary NamedDecl * or a vector /// of declarations. llvm::PointerUnion DeclOrVector; @@ -2361,7 +2361,7 @@ void VisibleDeclsRecord::ShadowMapEntry::Add(NamedDecl *ND) { DeclOrVector = ND; return; } - + if (NamedDecl *PrevND = DeclOrVector.dyn_cast()) { // 1 -> 2 elements: create the vector of results and push in the // existing declaration. @@ -2381,7 +2381,7 @@ void VisibleDeclsRecord::ShadowMapEntry::Destroy() { } } -VisibleDeclsRecord::ShadowMapEntry::iterator +VisibleDeclsRecord::ShadowMapEntry::iterator VisibleDeclsRecord::ShadowMapEntry::begin() { if (DeclOrVector.isNull()) return 0; @@ -2392,7 +2392,7 @@ VisibleDeclsRecord::ShadowMapEntry::begin() { return DeclOrVector.get()->begin(); } -VisibleDeclsRecord::ShadowMapEntry::iterator +VisibleDeclsRecord::ShadowMapEntry::iterator VisibleDeclsRecord::ShadowMapEntry::end() { if (DeclOrVector.isNull()) return 0; @@ -2406,7 +2406,7 @@ VisibleDeclsRecord::ShadowMapEntry::end() { NamedDecl *VisibleDeclsRecord::checkHidden(NamedDecl *ND) { // Look through using declarations. ND = ND->getUnderlyingDecl(); - + unsigned IDNS = ND->getIdentifierNamespace(); std::list::reverse_iterator SM = ShadowMaps.rbegin(); for (std::list::reverse_iterator SMEnd = ShadowMaps.rend(); @@ -2415,12 +2415,12 @@ NamedDecl *VisibleDeclsRecord::checkHidden(NamedDecl *ND) { if (Pos == SM->end()) continue; - for (ShadowMapEntry::iterator I = Pos->second.begin(), + for (ShadowMapEntry::iterator I = Pos->second.begin(), IEnd = Pos->second.end(); I != IEnd; ++I) { // A tag declaration does not hide a non-tag declaration. if ((*I)->hasTagIdentifierNamespace() && - (IDNS & (Decl::IDNS_Member | Decl::IDNS_Ordinary | + (IDNS & (Decl::IDNS_Member | Decl::IDNS_Ordinary | Decl::IDNS_ObjCProtocol))) continue; @@ -2437,7 +2437,7 @@ NamedDecl *VisibleDeclsRecord::checkHidden(NamedDecl *ND) { ND->isFunctionOrFunctionTemplate() && SM == ShadowMaps.rbegin()) continue; - + // We've found a declaration that hides this one. return *I; } @@ -2457,14 +2457,14 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, // Make sure we don't visit the same context twice. if (Visited.visitedContext(Ctx->getPrimaryContext())) return; - + if (CXXRecordDecl *Class = dyn_cast(Ctx)) Result.getSema().ForceDeclarationOfImplicitMembers(Class); // Enumerate all of the results in this context. - for (DeclContext *CurCtx = Ctx->getPrimaryContext(); CurCtx; + for (DeclContext *CurCtx = Ctx->getPrimaryContext(); CurCtx; CurCtx = CurCtx->getNextContext()) { - for (DeclContext::decl_iterator D = CurCtx->decls_begin(), + for (DeclContext::decl_iterator D = CurCtx->decls_begin(), DEnd = CurCtx->decls_end(); D != DEnd; ++D) { if (NamedDecl *ND = dyn_cast(*D)) { @@ -2499,7 +2499,7 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, ShadowContextRAII Shadow(Visited); DeclContext::udir_iterator I, E; for (llvm::tie(I, E) = Ctx->getUsingDirectives(); I != E; ++I) { - LookupVisibleDecls((*I)->getNominatedNamespace(), Result, + LookupVisibleDecls((*I)->getNominatedNamespace(), Result, QualifiedNameLookup, InBaseClass, Consumer, Visited); } } @@ -2513,16 +2513,16 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, BEnd = Record->bases_end(); B != BEnd; ++B) { QualType BaseType = B->getType(); - + // Don't look into dependent bases, because name lookup can't look // there anyway. if (BaseType->isDependentType()) continue; - + const RecordType *Record = BaseType->getAs(); if (!Record) continue; - + // FIXME: It would be nice to be able to determine whether referencing // a particular member would be ambiguous. For example, given // @@ -2541,21 +2541,21 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, // or // // c->A::member - + // Find results in this base class (and its bases). ShadowContextRAII Shadow(Visited); LookupVisibleDecls(Record->getDecl(), Result, QualifiedNameLookup, true, Consumer, Visited); } } - + // Traverse the contexts of Objective-C classes. if (ObjCInterfaceDecl *IFace = dyn_cast(Ctx)) { // Traverse categories. for (ObjCCategoryDecl *Category = IFace->getCategoryList(); Category; Category = Category->getNextClassCategory()) { ShadowContextRAII Shadow(Visited); - LookupVisibleDecls(Category, Result, QualifiedNameLookup, false, + LookupVisibleDecls(Category, Result, QualifiedNameLookup, false, Consumer, Visited); } @@ -2564,7 +2564,7 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, I = IFace->all_referenced_protocol_begin(), E = IFace->all_referenced_protocol_end(); I != E; ++I) { ShadowContextRAII Shadow(Visited); - LookupVisibleDecls(*I, Result, QualifiedNameLookup, false, Consumer, + LookupVisibleDecls(*I, Result, QualifiedNameLookup, false, Consumer, Visited); } @@ -2574,35 +2574,35 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, LookupVisibleDecls(IFace->getSuperClass(), Result, QualifiedNameLookup, true, Consumer, Visited); } - + // If there is an implementation, traverse it. We do this to find // synthesized ivars. if (IFace->getImplementation()) { ShadowContextRAII Shadow(Visited); - LookupVisibleDecls(IFace->getImplementation(), Result, + LookupVisibleDecls(IFace->getImplementation(), Result, QualifiedNameLookup, true, Consumer, Visited); } } else if (ObjCProtocolDecl *Protocol = dyn_cast(Ctx)) { for (ObjCProtocolDecl::protocol_iterator I = Protocol->protocol_begin(), E = Protocol->protocol_end(); I != E; ++I) { ShadowContextRAII Shadow(Visited); - LookupVisibleDecls(*I, Result, QualifiedNameLookup, false, Consumer, + LookupVisibleDecls(*I, Result, QualifiedNameLookup, false, Consumer, Visited); } } else if (ObjCCategoryDecl *Category = dyn_cast(Ctx)) { for (ObjCCategoryDecl::protocol_iterator I = Category->protocol_begin(), E = Category->protocol_end(); I != E; ++I) { ShadowContextRAII Shadow(Visited); - LookupVisibleDecls(*I, Result, QualifiedNameLookup, false, Consumer, + LookupVisibleDecls(*I, Result, QualifiedNameLookup, false, Consumer, Visited); } - + // If there is an implementation, traverse it. if (Category->getImplementation()) { ShadowContextRAII Shadow(Visited); - LookupVisibleDecls(Category->getImplementation(), Result, + LookupVisibleDecls(Category->getImplementation(), Result, QualifiedNameLookup, true, Consumer, Visited); - } + } } } @@ -2613,8 +2613,8 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, if (!S) return; - if (!S->getEntity() || - (!S->getParent() && + if (!S->getEntity() || + (!S->getParent() && !Visited.alreadyVisitedContext((DeclContext *)S->getEntity())) || ((DeclContext *)S->getEntity())->isFunctionOrMethod()) { // Walk through the declarations in this Scope. @@ -2627,7 +2627,7 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, } } } - + // FIXME: C++ [temp.local]p8 DeclContext *Entity = 0; if (S->getEntity()) { @@ -2636,7 +2636,7 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, // where we hit the context stored in the next outer scope. Entity = (DeclContext *)S->getEntity(); DeclContext *OuterCtx = findOuterContext(S).first; // FIXME - + for (DeclContext *Ctx = Entity; Ctx && !Ctx->Equals(OuterCtx); Ctx = Ctx->getLookupParent()) { if (ObjCMethodDecl *Method = dyn_cast(Ctx)) { @@ -2645,15 +2645,15 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, LookupResult IvarResult(Result.getSema(), Result.getLookupName(), Result.getNameLoc(), Sema::LookupMemberName); if (ObjCInterfaceDecl *IFace = Method->getClassInterface()) { - LookupVisibleDecls(IFace, IvarResult, /*QualifiedNameLookup=*/false, + LookupVisibleDecls(IFace, IvarResult, /*QualifiedNameLookup=*/false, /*InBaseClass=*/false, Consumer, Visited); - + // Look for properties from which we can synthesize ivars, if // permitted. if (Result.getSema().getLangOptions().ObjCNonFragileABI2 && IFace->getImplementation() && Result.getLookupKind() == Sema::LookupOrdinaryName) { - for (ObjCInterfaceDecl::prop_iterator + for (ObjCInterfaceDecl::prop_iterator P = IFace->prop_begin(), PEnd = IFace->prop_end(); P != PEnd; ++P) { @@ -2662,8 +2662,8 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, Consumer.FoundDecl(*P, Visited.checkHidden(*P), false); Visited.add(*P); } - } - } + } + } } } @@ -2675,8 +2675,8 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, if (Ctx->isFunctionOrMethod()) continue; - - LookupVisibleDecls(Ctx, Result, /*QualifiedNameLookup=*/false, + + LookupVisibleDecls(Ctx, Result, /*QualifiedNameLookup=*/false, /*InBaseClass=*/false, Consumer, Visited); } } else if (!S->getParent()) { @@ -2686,14 +2686,14 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, // FIXME: We would like the translation unit's Scope object to point to the // translation unit, so we don't need this special "if" branch. However, // doing so would force the normal C++ name-lookup code to look into the - // translation unit decl when the IdentifierInfo chains would suffice. + // translation unit decl when the IdentifierInfo chains would suffice. // Once we fix that problem (which is part of a more general "don't look // in DeclContexts unless we have to" optimization), we can eliminate this. Entity = Result.getSema().Context.getTranslationUnitDecl(); - LookupVisibleDecls(Entity, Result, /*QualifiedNameLookup=*/false, + LookupVisibleDecls(Entity, Result, /*QualifiedNameLookup=*/false, /*InBaseClass=*/false, Consumer, Visited); - } - + } + if (Entity) { // Lookup visible declarations in any namespaces found by using // directives. @@ -2701,7 +2701,7 @@ static void LookupVisibleDecls(Scope *S, LookupResult &Result, llvm::tie(UI, UEnd) = UDirs.getNamespacesFor(Entity); for (; UI != UEnd; ++UI) LookupVisibleDecls(const_cast(UI->getNominatedNamespace()), - Result, /*QualifiedNameLookup=*/false, + Result, /*QualifiedNameLookup=*/false, /*InBaseClass=*/false, Consumer, Visited); } @@ -2743,7 +2743,7 @@ void Sema::LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind, if (!IncludeGlobalScope) Visited.visitedContext(Context.getTranslationUnitDecl()); ShadowContextRAII Shadow(Visited); - ::LookupVisibleDecls(Ctx, Result, /*QualifiedNameLookup=*/true, + ::LookupVisibleDecls(Ctx, Result, /*QualifiedNameLookup=*/true, /*InBaseClass=*/false, Consumer, Visited); } @@ -2764,10 +2764,10 @@ class TypoCorrectionConsumer : public VisibleDeclConsumer { /// \brief The best edit distance found so far. unsigned BestEditDistance; - + public: explicit TypoCorrectionConsumer(IdentifierInfo *Typo) - : Typo(Typo->getName()), + : Typo(Typo->getName()), BestEditDistance((std::numeric_limits::max)()) { } virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, bool InBaseClass); @@ -2785,17 +2785,17 @@ public: return BestResults[Name]; } - unsigned getBestEditDistance() const { return BestEditDistance; } + unsigned getBestEditDistance() const { return BestEditDistance; } }; } -void TypoCorrectionConsumer::FoundDecl(NamedDecl *ND, NamedDecl *Hiding, +void TypoCorrectionConsumer::FoundDecl(NamedDecl *ND, NamedDecl *Hiding, bool InBaseClass) { // Don't consider hidden names for typo correction. if (Hiding) return; - + // Only consider entities with identifiers for names, ignoring // special names (constructors, overloaded operators, selectors, // etc.). @@ -2808,24 +2808,24 @@ void TypoCorrectionConsumer::FoundDecl(NamedDecl *ND, NamedDecl *Hiding, void TypoCorrectionConsumer::FoundName(llvm::StringRef Name) { using namespace std; - + // Use a simple length-based heuristic to determine the minimum possible // edit distance. If the minimum isn't good enough, bail out early. unsigned MinED = abs((int)Name.size() - (int)Typo.size()); if (MinED > BestEditDistance || (MinED && Typo.size() / MinED < 3)) return; - + // Compute an upper bound on the allowable edit distance, so that the // edit-distance algorithm can short-circuit. unsigned UpperBound = min(unsigned((Typo.size() + 2) / 3), BestEditDistance); - + // Compute the edit distance between the typo and the name of this // entity. If this edit distance is not worse than the best edit // distance we've seen so far, add it to the list of results. unsigned ED = Typo.edit_distance(Name, true, UpperBound); if (ED == 0) return; - + if (ED < BestEditDistance) { // This result is better than any we've seen before; clear out // the previous results. @@ -2836,15 +2836,15 @@ void TypoCorrectionConsumer::FoundName(llvm::StringRef Name) { // ignore it. return; } - + // Add this name to the list of results. By not assigning a value, we // keep the current value if we've seen this name before (either as a // keyword or as a declaration), or get the default value (not a keyword) // if we haven't seen it before. - (void)BestResults[Name]; + (void)BestResults[Name]; } -void TypoCorrectionConsumer::addKeywordResult(ASTContext &Context, +void TypoCorrectionConsumer::addKeywordResult(ASTContext &Context, llvm::StringRef Keyword) { // Compute the edit distance between the typo and this keyword. // If this edit distance is not worse than the best edit @@ -2858,7 +2858,7 @@ void TypoCorrectionConsumer::addKeywordResult(ASTContext &Context, // ignore it. return; } - + BestResults[Keyword] = true; } @@ -2873,7 +2873,7 @@ static void LookupPotentialTypoResult(Sema &SemaRef, Res.suppressDiagnostics(); Res.clear(); Res.setLookupName(Name); - if (MemberContext) { + if (MemberContext) { if (ObjCInterfaceDecl *Class = dyn_cast(MemberContext)) { if (CTC == Sema::CTC_ObjCIvarLookup) { if (ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) { @@ -2882,29 +2882,29 @@ static void LookupPotentialTypoResult(Sema &SemaRef, return; } } - + if (ObjCPropertyDecl *Prop = Class->FindPropertyDeclaration(Name)) { Res.addDecl(Prop); Res.resolveKind(); return; } } - + SemaRef.LookupQualifiedName(Res, MemberContext); return; } - - SemaRef.LookupParsedName(Res, S, SS, /*AllowBuiltinCreation=*/false, + + SemaRef.LookupParsedName(Res, S, SS, /*AllowBuiltinCreation=*/false, EnteringContext); - + // Fake ivar lookup; this should really be part of // LookupParsedName. if (ObjCMethodDecl *Method = SemaRef.getCurMethodDecl()) { if (Method->isInstanceMethod() && Method->getClassInterface() && - (Res.empty() || + (Res.empty() || (Res.isSingleResult() && Res.getFoundDecl()->isDefinedOutsideFunctionOrMethod()))) { - if (ObjCIvarDecl *IV + if (ObjCIvarDecl *IV = Method->getClassInterface()->lookupInstanceVariable(Name)) { Res.addDecl(IV); Res.resolveKind(); @@ -2930,7 +2930,7 @@ static void LookupPotentialTypoResult(Sema &SemaRef, /// \param MemberContext if non-NULL, the context in which to look for /// a member access expression. /// -/// \param EnteringContext whether we're entering the context described by +/// \param EnteringContext whether we're entering the context described by /// the nested-name-specifier SS. /// /// \param CTC The context in which typo correction occurs, which impacts the @@ -2944,13 +2944,13 @@ static void LookupPotentialTypoResult(Sema &SemaRef, /// may contain the results of name lookup for the correct name or it may be /// empty. DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, - DeclContext *MemberContext, + DeclContext *MemberContext, bool EnteringContext, CorrectTypoContext CTC, const ObjCObjectPointerType *OPT) { if (Diags.hasFatalErrorOccurred() || !getLangOptions().SpellChecking) return DeclarationName(); - + // We only attempt to correct typos for identifiers. IdentifierInfo *Typo = Res.getLookupName().getAsIdentifierInfo(); if (!Typo) @@ -2965,9 +2965,9 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, // instantiation. if (!ActiveTemplateInstantiations.empty()) return DeclarationName(); - + TypoCorrectionConsumer Consumer(Typo); - + // Perform name lookup to find visible, similarly-named entities. bool IsUnqualifiedLookup = false; if (MemberContext) { @@ -2975,8 +2975,8 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, // Look in qualified interfaces. if (OPT) { - for (ObjCObjectPointerType::qual_iterator - I = OPT->qual_begin(), E = OPT->qual_end(); + for (ObjCObjectPointerType::qual_iterator + I = OPT->qual_begin(), E = OPT->qual_end(); I != E; ++I) LookupVisibleDecls(*I, Res.getLookupKind(), Consumer); } @@ -2984,7 +2984,7 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, DeclContext *DC = computeDeclContext(*SS, EnteringContext); if (!DC) return DeclarationName(); - + // Provide a stop gap for files that are just seriously broken. Trying // to correct all typos can turn into a HUGE performance penalty, causing // some files to take minutes to get rejected by the parser. @@ -3003,14 +3003,14 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, // some files to take minutes to get rejected by the parser. if (TyposCorrected + UnqualifiedTyposCorrected.size() >= 20) return DeclarationName(); - + // For unqualified lookup, look through all of the names that we have // seen in this translation unit. - for (IdentifierTable::iterator I = Context.Idents.begin(), + for (IdentifierTable::iterator I = Context.Idents.begin(), IEnd = Context.Idents.end(); I != IEnd; ++I) Consumer.FoundName(I->getKey()); - + // Walk through identifiers in external identifier sources. if (IdentifierInfoLookup *External = Context.Idents.getExternalIdentifierLookup()) { @@ -3028,7 +3028,7 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, // end up adding the keyword below. if (Cached->second.first.empty()) return DeclarationName(); - + if (!Cached->second.second) Consumer.FoundName(Cached->second.first); } @@ -3045,44 +3045,44 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, WantExpressionKeywords = true; WantCXXNamedCasts = true; WantRemainingKeywords = true; - + if (ObjCMethodDecl *Method = getCurMethodDecl()) if (Method->getClassInterface() && Method->getClassInterface()->getSuperClass()) Consumer.addKeywordResult(Context, "super"); - + break; - + case CTC_NoKeywords: break; - + case CTC_Type: WantTypeSpecifiers = true; break; - + case CTC_ObjCMessageReceiver: Consumer.addKeywordResult(Context, "super"); // Fall through to handle message receivers like expressions. - + case CTC_Expression: if (getLangOptions().CPlusPlus) WantTypeSpecifiers = true; WantExpressionKeywords = true; // Fall through to get C++ named casts. - + case CTC_CXXCasts: WantCXXNamedCasts = true; break; - + case CTC_ObjCPropertyLookup: // FIXME: Add "isa"? break; - + case CTC_MemberLookup: if (getLangOptions().CPlusPlus) Consumer.addKeywordResult(Context, "template"); break; - + case CTC_ObjCIvarLookup: break; } @@ -3096,67 +3096,67 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, // storage-specifiers as well "extern", "inline", "static", "typedef" }; - + const unsigned NumCTypeSpecs = sizeof(CTypeSpecs) / sizeof(CTypeSpecs[0]); for (unsigned I = 0; I != NumCTypeSpecs; ++I) Consumer.addKeywordResult(Context, CTypeSpecs[I]); - + if (getLangOptions().C99) Consumer.addKeywordResult(Context, "restrict"); if (getLangOptions().Bool || getLangOptions().CPlusPlus) Consumer.addKeywordResult(Context, "bool"); - + if (getLangOptions().CPlusPlus) { Consumer.addKeywordResult(Context, "class"); Consumer.addKeywordResult(Context, "typename"); Consumer.addKeywordResult(Context, "wchar_t"); - + if (getLangOptions().CPlusPlus0x) { Consumer.addKeywordResult(Context, "char16_t"); Consumer.addKeywordResult(Context, "char32_t"); Consumer.addKeywordResult(Context, "constexpr"); Consumer.addKeywordResult(Context, "decltype"); Consumer.addKeywordResult(Context, "thread_local"); - } + } } - + if (getLangOptions().GNUMode) Consumer.addKeywordResult(Context, "typeof"); } - + if (WantCXXNamedCasts && getLangOptions().CPlusPlus) { Consumer.addKeywordResult(Context, "const_cast"); Consumer.addKeywordResult(Context, "dynamic_cast"); Consumer.addKeywordResult(Context, "reinterpret_cast"); Consumer.addKeywordResult(Context, "static_cast"); } - + if (WantExpressionKeywords) { Consumer.addKeywordResult(Context, "sizeof"); if (getLangOptions().Bool || getLangOptions().CPlusPlus) { Consumer.addKeywordResult(Context, "false"); Consumer.addKeywordResult(Context, "true"); } - + if (getLangOptions().CPlusPlus) { - const char *CXXExprs[] = { - "delete", "new", "operator", "throw", "typeid" + const char *CXXExprs[] = { + "delete", "new", "operator", "throw", "typeid" }; const unsigned NumCXXExprs = sizeof(CXXExprs) / sizeof(CXXExprs[0]); for (unsigned I = 0; I != NumCXXExprs; ++I) Consumer.addKeywordResult(Context, CXXExprs[I]); - + if (isa(CurContext) && cast(CurContext)->isInstance()) Consumer.addKeywordResult(Context, "this"); - + if (getLangOptions().CPlusPlus0x) { Consumer.addKeywordResult(Context, "alignof"); Consumer.addKeywordResult(Context, "nullptr"); } } } - + if (WantRemainingKeywords) { if (getCurFunctionOrMethodDecl() || getCurBlock()) { // Statements. @@ -3165,18 +3165,18 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, const unsigned NumCStmts = sizeof(CStmts) / sizeof(CStmts[0]); for (unsigned I = 0; I != NumCStmts; ++I) Consumer.addKeywordResult(Context, CStmts[I]); - + if (getLangOptions().CPlusPlus) { Consumer.addKeywordResult(Context, "catch"); Consumer.addKeywordResult(Context, "try"); } - + if (S && S->getBreakParent()) Consumer.addKeywordResult(Context, "break"); - + if (S && S->getContinueParent()) Consumer.addKeywordResult(Context, "continue"); - + if (!getCurFunction()->SwitchStack.empty()) { Consumer.addKeywordResult(Context, "case"); Consumer.addKeywordResult(Context, "default"); @@ -3197,7 +3197,7 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, Consumer.addKeywordResult(Context, "virtual"); } } - + if (getLangOptions().CPlusPlus) { Consumer.addKeywordResult(Context, "using"); @@ -3205,17 +3205,17 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, Consumer.addKeywordResult(Context, "static_assert"); } } - + // If we haven't found anything, we're done. if (Consumer.empty()) { // If this was an unqualified lookup, note that no correction was found. if (IsUnqualifiedLookup) (void)UnqualifiedTyposCorrected[Typo]; - + return DeclarationName(); } - // Make sure that the user typed at least 3 characters for each correction + // Make sure that the user typed at least 3 characters for each correction // made. Otherwise, we don't even both looking at the results. // We also suppress exact matches; those should be handled by a @@ -3232,7 +3232,7 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, // Weed out any names that could not be found by name lookup. bool LastLookupWasAccepted = false; - for (TypoCorrectionConsumer::iterator I = Consumer.begin(), + for (TypoCorrectionConsumer::iterator I = Consumer.begin(), IEnd = Consumer.end(); I != IEnd; /* Increment in loop. */) { // Keywords are always found. @@ -3240,17 +3240,17 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, ++I; continue; } - + // Perform name lookup on this name. IdentifierInfo *Name = &Context.Idents.get(I->getKey()); - LookupPotentialTypoResult(*this, Res, Name, S, SS, MemberContext, + LookupPotentialTypoResult(*this, Res, Name, S, SS, MemberContext, EnteringContext, CTC); - + switch (Res.getResultKind()) { case LookupResult::NotFound: case LookupResult::NotFoundInCurrentInstantiation: case LookupResult::Ambiguous: - // We didn't find this name in our scope, or didn't like what we found; + // We didn't find this name in our scope, or didn't like what we found; // ignore it. Res.suppressDiagnostics(); { @@ -3260,8 +3260,8 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, I = Next; } LastLookupWasAccepted = false; - break; - + break; + case LookupResult::Found: case LookupResult::FoundOverloaded: case LookupResult::FoundUnresolvedValue: @@ -3269,13 +3269,13 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, LastLookupWasAccepted = true; break; } - + if (Res.isAmbiguous()) { // We don't deal with ambiguities. Res.suppressDiagnostics(); Res.clear(); - return DeclarationName(); - } + return DeclarationName(); + } } // If only a single name remains, return that result. @@ -3284,49 +3284,49 @@ DeclarationName Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS, if (Consumer.begin()->second) { Res.suppressDiagnostics(); Res.clear(); - + // Don't correct to a keyword that's the same as the typo; the keyword // wasn't actually in scope. if (ED == 0) { Res.setLookupName(Typo); return DeclarationName(); } - + } else if (!LastLookupWasAccepted) { // Perform name lookup on this name. - LookupPotentialTypoResult(*this, Res, Name, S, SS, MemberContext, + LookupPotentialTypoResult(*this, Res, Name, S, SS, MemberContext, EnteringContext, CTC); } // Record the correction for unqualified lookup. if (IsUnqualifiedLookup) - UnqualifiedTyposCorrected[Typo] + UnqualifiedTyposCorrected[Typo] = std::make_pair(Name->getName(), Consumer.begin()->second); - - return &Context.Idents.get(Consumer.begin()->getKey()); + + return &Context.Idents.get(Consumer.begin()->getKey()); } - else if (Consumer.size() > 1 && CTC == CTC_ObjCMessageReceiver + else if (Consumer.size() > 1 && CTC == CTC_ObjCMessageReceiver && Consumer["super"]) { // Prefix 'super' when we're completing in a message-receiver // context. Res.suppressDiagnostics(); Res.clear(); - + // Don't correct to a keyword that's the same as the typo; the keyword // wasn't actually in scope. if (ED == 0) { Res.setLookupName(Typo); return DeclarationName(); } - + // Record the correction for unqualified lookup. if (IsUnqualifiedLookup) UnqualifiedTyposCorrected[Typo] = std::make_pair("super", Consumer.begin()->second); - + return &Context.Idents.get("super"); } - + Res.suppressDiagnostics(); Res.setLookupName(Typo); Res.clear(); diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 1e8f315c95..e8a04bbd74 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -340,7 +340,7 @@ namespace { TemplateArgument SecondArg; }; } - + /// \brief Convert from Sema's representation of template deduction information /// to the form used in overload-candidate information. OverloadCandidate::DeductionFailureInfo @@ -356,12 +356,12 @@ static MakeDeductionFailureInfo(ASTContext &Context, case Sema::TDK_TooManyArguments: case Sema::TDK_TooFewArguments: break; - + case Sema::TDK_Incomplete: case Sema::TDK_InvalidExplicitArguments: Result.Data = Info.Param.getOpaqueValue(); break; - + case Sema::TDK_Inconsistent: case Sema::TDK_Underqualified: { // FIXME: Should allocate from normal heap so that we can free this later. @@ -372,16 +372,16 @@ static MakeDeductionFailureInfo(ASTContext &Context, Result.Data = Saved; break; } - + case Sema::TDK_SubstitutionFailure: Result.Data = Info.take(); break; - + case Sema::TDK_NonDeducedMismatch: case Sema::TDK_FailedOverloadResolution: - break; + break; } - + return Result; } @@ -394,7 +394,7 @@ void OverloadCandidate::DeductionFailureInfo::Destroy() { case Sema::TDK_TooFewArguments: case Sema::TDK_InvalidExplicitArguments: break; - + case Sema::TDK_Inconsistent: case Sema::TDK_Underqualified: // FIXME: Destroy the data? @@ -405,15 +405,15 @@ void OverloadCandidate::DeductionFailureInfo::Destroy() { // FIXME: Destroy the template arugment list? Data = 0; break; - + // Unhandled case Sema::TDK_NonDeducedMismatch: case Sema::TDK_FailedOverloadResolution: break; } } - -TemplateParameter + +TemplateParameter OverloadCandidate::DeductionFailureInfo::getTemplateParameter() { switch (static_cast(Result)) { case Sema::TDK_Success: @@ -422,24 +422,24 @@ OverloadCandidate::DeductionFailureInfo::getTemplateParameter() { case Sema::TDK_TooFewArguments: case Sema::TDK_SubstitutionFailure: return TemplateParameter(); - + case Sema::TDK_Incomplete: case Sema::TDK_InvalidExplicitArguments: - return TemplateParameter::getFromOpaqueValue(Data); + return TemplateParameter::getFromOpaqueValue(Data); case Sema::TDK_Inconsistent: case Sema::TDK_Underqualified: return static_cast(Data)->Param; - + // Unhandled case Sema::TDK_NonDeducedMismatch: case Sema::TDK_FailedOverloadResolution: break; } - + return TemplateParameter(); } - + TemplateArgumentList * OverloadCandidate::DeductionFailureInfo::getTemplateArgumentList() { switch (static_cast(Result)) { @@ -455,7 +455,7 @@ OverloadCandidate::DeductionFailureInfo::getTemplateArgumentList() { case Sema::TDK_SubstitutionFailure: return static_cast(Data); - + // Unhandled case Sema::TDK_NonDeducedMismatch: case Sema::TDK_FailedOverloadResolution: @@ -478,16 +478,16 @@ const TemplateArgument *OverloadCandidate::DeductionFailureInfo::getFirstArg() { case Sema::TDK_Inconsistent: case Sema::TDK_Underqualified: - return &static_cast(Data)->FirstArg; + return &static_cast(Data)->FirstArg; // Unhandled case Sema::TDK_NonDeducedMismatch: case Sema::TDK_FailedOverloadResolution: break; } - + return 0; -} +} const TemplateArgument * OverloadCandidate::DeductionFailureInfo::getSecondArg() { @@ -510,7 +510,7 @@ OverloadCandidate::DeductionFailureInfo::getSecondArg() { case Sema::TDK_FailedOverloadResolution: break; } - + return 0; } @@ -518,7 +518,7 @@ void OverloadCandidateSet::clear() { inherited::clear(); Functions.clear(); } - + // IsOverload - Determine whether the given New declaration is an // overload of the declarations in Old. This routine returns false if // New and Old cannot be overloaded, e.g., if New has the same @@ -701,19 +701,19 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old, (OldMethod->getRefQualifier() == RQ_None || NewMethod->getRefQualifier() == RQ_None)) { // C++0x [over.load]p2: - // - Member function declarations with the same name and the same - // parameter-type-list as well as member function template - // declarations with the same name, the same parameter-type-list, and - // the same template parameter lists cannot be overloaded if any of + // - Member function declarations with the same name and the same + // parameter-type-list as well as member function template + // declarations with the same name, the same parameter-type-list, and + // the same template parameter lists cannot be overloaded if any of // them, but not all, have a ref-qualifier (8.3.5). Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload) << NewMethod->getRefQualifier() << OldMethod->getRefQualifier(); Diag(OldMethod->getLocation(), diag::note_previous_declaration); } - + return true; } - + // The signatures match; this is not an overload. return false; } @@ -744,7 +744,7 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old, static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, - bool AllowExplicit, + bool AllowExplicit, bool InOverloadResolution, bool CStyle) { ImplicitConversionSequence ICS; @@ -774,20 +774,20 @@ TryImplicitConversion(Sema &S, Expr *From, QualType ToType, ICS.Standard.setAsIdentityConversion(); ICS.Standard.setFromType(FromType); ICS.Standard.setAllToTypes(ToType); - + // We don't actually check at this point whether there is a valid // copy/move constructor, since overloading just assumes that it // exists. When we actually perform initialization, we'll find the // appropriate constructor to copy the returned object, if needed. ICS.Standard.CopyConstructor = 0; - + // Determine whether this is considered a derived-to-base conversion. if (!S.Context.hasSameUnqualifiedType(FromType, ToType)) ICS.Standard.Second = ICK_Derived_To_Base; - + return ICS; } - + if (SuppressUserConversions) { // We're not in the case above, so there is no conversion that // we can perform. @@ -865,7 +865,7 @@ bool Sema::TryImplicitConversion(InitializationSequence &Sequence, ImplicitConversionSequence ICS = clang::TryImplicitConversion(*this, Initializer, Entity.getType(), SuppressUserConversions, - AllowExplicitConversions, + AllowExplicitConversions, InOverloadResolution, CStyle); if (ICS.isBad()) return true; @@ -899,14 +899,14 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, /*CStyle=*/false); return PerformImplicitConversion(From, ToType, ICS, Action); } - -/// \brief Determine whether the conversion from FromType to ToType is a valid + +/// \brief Determine whether the conversion from FromType to ToType is a valid /// conversion that strips "noreturn" off the nested function type. -static bool IsNoReturnConversion(ASTContext &Context, QualType FromType, +static bool IsNoReturnConversion(ASTContext &Context, QualType FromType, QualType ToType, QualType &ResultTy) { if (Context.hasSameUnqualifiedType(FromType, ToType)) return false; - + // Permit the conversion F(t __attribute__((noreturn))) -> F(t) // where F adds one of the following at most once: // - a pointer @@ -947,14 +947,14 @@ static bool IsNoReturnConversion(ASTContext &Context, QualType FromType, ResultTy = ToType; return true; } - + /// \brief Determine whether the conversion from FromType to ToType is a valid /// vector conversion. /// /// \param ICK Will be set to the vector conversion kind, if this is a vector /// conversion. -static bool IsVectorConversion(ASTContext &Context, QualType FromType, - QualType ToType, ImplicitConversionKind &ICK) { +static bool IsVectorConversion(ASTContext &Context, QualType FromType, + QualType ToType, ImplicitConversionKind &ICK) { // We need at least one of these types to be a vector type to have a vector // conversion. if (!ToType->isVectorType() && !FromType->isVectorType()) @@ -970,7 +970,7 @@ static bool IsVectorConversion(ASTContext &Context, QualType FromType, // identity conversion. if (FromType->isExtVectorType()) return false; - + // Vector splat from any arithmetic type to a vector. if (FromType->isArithmeticType()) { ICK = ICK_Vector_Splat; @@ -993,7 +993,7 @@ static bool IsVectorConversion(ASTContext &Context, QualType FromType, return false; } - + /// IsStandardConversion - Determines whether there is a standard /// conversion sequence (C++ [conv], C++ [over.ics.scs]) from the /// expression From to the type ToType. Standard conversion sequences @@ -1007,7 +1007,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, StandardConversionSequence &SCS, bool CStyle) { QualType FromType = From->getType(); - + // Standard conversions (C++ [conv]) SCS.setAsIdentityConversion(); SCS.DeprecatedStringLiteralToCharPtr = false; @@ -1031,26 +1031,26 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, if (FromType == S.Context.OverloadTy) { DeclAccessPair AccessPair; if (FunctionDecl *Fn - = S.ResolveAddressOfOverloadedFunction(From, ToType, false, + = S.ResolveAddressOfOverloadedFunction(From, ToType, false, AccessPair)) { // We were able to resolve the address of the overloaded function, // so we can convert to the type of that function. FromType = Fn->getType(); if (CXXMethodDecl *Method = dyn_cast(Fn)) { if (!Method->isStatic()) { - const Type *ClassType + const Type *ClassType = S.Context.getTypeDeclType(Method->getParent()).getTypePtr(); FromType = S.Context.getMemberPointerType(FromType, ClassType); } } - + // If the "from" expression takes the address of the overloaded // function, update the type of the resulting expression accordingly. if (FromType->getAs()) if (UnaryOperator *UnOp = dyn_cast(From->IgnoreParens())) if (UnOp->getOpcode() == UO_AddrOf) FromType = S.Context.getPointerType(FromType); - + // Check that we've computed the proper type after overload resolution. assert(S.Context.hasSameType(FromType, S.FixOverloadedFunctionReference(From, AccessPair, Fn)->getType())); @@ -1159,7 +1159,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, // Floating point conversions (C++ 4.8). SCS.Second = ICK_Floating_Conversion; FromType = ToType.getUnqualifiedType(); - } else if ((FromType->isRealFloatingType() && + } else if ((FromType->isRealFloatingType() && ToType->isIntegralType(S.Context)) || (FromType->isIntegralOrUnscopedEnumerationType() && ToType->isRealFloatingType())) { @@ -1171,7 +1171,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, // Pointer conversions (C++ 4.10). SCS.Second = ICK_Pointer_Conversion; SCS.IncompatibleObjC = IncompatibleObjC; - } else if (S.IsMemberPointerConversion(From, FromType, ToType, + } else if (S.IsMemberPointerConversion(From, FromType, ToType, InOverloadResolution, FromType)) { // Pointer to member conversions (4.11). SCS.Second = ICK_Pointer_Member; @@ -1210,7 +1210,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, // a conversion. [...] CanonFrom = S.Context.getCanonicalType(FromType); CanonTo = S.Context.getCanonicalType(ToType); - if (CanonFrom.getLocalUnqualifiedType() + if (CanonFrom.getLocalUnqualifiedType() == CanonTo.getLocalUnqualifiedType() && (CanonFrom.getLocalCVRQualifiers() != CanonTo.getLocalCVRQualifiers() || CanonFrom.getObjCGCAttr() != CanonTo.getObjCGCAttr())) { @@ -1258,17 +1258,17 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) { return To->getKind() == BuiltinType::UInt; } - // C++0x [conv.prom]p3: - // A prvalue of an unscoped enumeration type whose underlying type is not - // fixed (7.2) can be converted to an rvalue a prvalue of the first of the - // following types that can represent all the values of the enumeration - // (i.e., the values in the range bmin to bmax as described in 7.2): int, - // unsigned int, long int, unsigned long int, long long int, or unsigned + // C++0x [conv.prom]p3: + // A prvalue of an unscoped enumeration type whose underlying type is not + // fixed (7.2) can be converted to an rvalue a prvalue of the first of the + // following types that can represent all the values of the enumeration + // (i.e., the values in the range bmin to bmax as described in 7.2): int, + // unsigned int, long int, unsigned long int, long long int, or unsigned // long long int. If none of the types in that list can represent all the - // values of the enumeration, an rvalue a prvalue of an unscoped enumeration + // values of the enumeration, an rvalue a prvalue of an unscoped enumeration // type can be converted to an rvalue a prvalue of the extended integer type - // with lowest integer conversion rank (4.13) greater than the rank of long - // long in which all the values of the enumeration can be represented. If + // with lowest integer conversion rank (4.13) greater than the rank of long + // long in which all the values of the enumeration can be represented. If // there are two such extended types, the signed one is chosen. if (const EnumType *FromEnumType = FromType->getAs()) { // C++0x 7.2p9: Note that this implicit enum to int conversion is not @@ -1277,28 +1277,28 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) { return false; // We have already pre-calculated the promotion type, so this is trivial. - if (ToType->isIntegerType() && + if (ToType->isIntegerType() && !RequireCompleteType(From->getLocStart(), FromType, PDiag())) return Context.hasSameUnqualifiedType(ToType, FromEnumType->getDecl()->getPromotionType()); } // C++0x [conv.prom]p2: - // A prvalue of type char16_t, char32_t, or wchar_t (3.9.1) can be converted - // to an rvalue a prvalue of the first of the following types that can - // represent all the values of its underlying type: int, unsigned int, + // A prvalue of type char16_t, char32_t, or wchar_t (3.9.1) can be converted + // to an rvalue a prvalue of the first of the following types that can + // represent all the values of its underlying type: int, unsigned int, // long int, unsigned long int, long long int, or unsigned long long int. - // If none of the types in that list can represent all the values of its + // If none of the types in that list can represent all the values of its // underlying type, an rvalue a prvalue of type char16_t, char32_t, - // or wchar_t can be converted to an rvalue a prvalue of its underlying + // or wchar_t can be converted to an rvalue a prvalue of its underlying // type. - if (FromType->isAnyCharacterType() && !FromType->isCharType() && + if (FromType->isAnyCharacterType() && !FromType->isCharType() && ToType->isIntegerType()) { // Determine whether the type we're converting from is signed or // unsigned. bool FromIsSigned; uint64_t FromSize = Context.getTypeSize(FromType); - + // FIXME: Is wchar_t signed or unsigned? We assume it's signed for now. FromIsSigned = true; @@ -1422,12 +1422,12 @@ BuildSimilarlyQualifiedPointerType(const Type *FromPtr, assert((FromPtr->getTypeClass() == Type::Pointer || FromPtr->getTypeClass() == Type::ObjCObjectPointer) && "Invalid similarly-qualified pointer type"); - + /// \brief Conversions to 'id' subsume cv-qualifier conversions. if (ToType->isObjCIdType() || ToType->isObjCQualifiedIdType()) return ToType.getUnqualifiedType(); - - QualType CanonFromPointee + + QualType CanonFromPointee = Context.getCanonicalType(FromPtr->getPointeeType()); QualType CanonToPointee = Context.getCanonicalType(ToPointee); Qualifiers Quals = CanonFromPointee.getQualifiers(); @@ -1448,12 +1448,12 @@ BuildSimilarlyQualifiedPointerType(const Type *FromPtr, // Just build a canonical type that has the right qualifiers. QualType QualifiedCanonToPointee = Context.getQualifiedType(CanonToPointee.getLocalUnqualifiedType(), Quals); - + if (isa(ToType)) return Context.getObjCObjectPointerType(QualifiedCanonToPointee); return Context.getPointerType(QualifiedCanonToPointee); } - + static bool isNullPointerConstantForConversion(Expr *Expr, bool InOverloadResolution, ASTContext &Context) { @@ -1532,7 +1532,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType, return true; } - // Beyond this point, both types need to be pointers + // Beyond this point, both types need to be pointers // , including objective-c pointers. QualType ToPointeeType = ToTypePtr->getPointeeType(); if (FromType->isObjCObjectPointerType() && ToPointeeType->isVoidType()) { @@ -1548,7 +1548,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType, QualType FromPointeeType = FromTypePtr->getPointeeType(); - // If the unqualified pointee types are the same, this can't be a + // If the unqualified pointee types are the same, this can't be a // pointer conversion, so don't do all of the work below. if (Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) return false; @@ -1609,7 +1609,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType, bool &IncompatibleObjC) { if (!getLangOptions().ObjC1) return false; - + // First, we handle all conversions on ObjC object pointer types. const ObjCObjectPointerType* ToObjCPtr = ToType->getAs(); @@ -1646,7 +1646,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType, !ToObjCPtr->getPointeeType().isAtLeastAsQualifiedAs( FromObjCPtr->getPointeeType())) return false; - ConvertedType = BuildSimilarlyQualifiedPointerType(FromObjCPtr, + ConvertedType = BuildSimilarlyQualifiedPointerType(FromObjCPtr, ToObjCPtr->getPointeeType(), ToType, Context); return true; @@ -1657,7 +1657,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType, // interfaces, which is permitted. However, we're going to // complain about it. IncompatibleObjC = true; - ConvertedType = BuildSimilarlyQualifiedPointerType(FromObjCPtr, + ConvertedType = BuildSimilarlyQualifiedPointerType(FromObjCPtr, ToObjCPtr->getPointeeType(), ToType, Context); return true; @@ -1667,7 +1667,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType, QualType ToPointeeType; if (const PointerType *ToCPtr = ToType->getAs()) ToPointeeType = ToCPtr->getPointeeType(); - else if (const BlockPointerType *ToBlockPtr = + else if (const BlockPointerType *ToBlockPtr = ToType->getAs()) { // Objective C++: We're able to convert from a pointer to any object // to a block pointer type. @@ -1677,9 +1677,9 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType, } ToPointeeType = ToBlockPtr->getPointeeType(); } - else if (FromType->getAs() && + else if (FromType->getAs() && ToObjCPtr && ToObjCPtr->isObjCBuiltinType()) { - // Objective C++: We're able to convert from a block pointer type to a + // Objective C++: We're able to convert from a block pointer type to a // pointer to any object. ConvertedType = ToType; return true; @@ -1715,7 +1715,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType, ConvertedType = Context.getPointerType(ConvertedType); return true; } - + // If we have pointers to functions or blocks, check whether the only // differences in the argument and result types are in Objective-C // pointer conversions. If so, we permit the conversion (but @@ -1781,17 +1781,17 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType, return false; } - + /// FunctionArgTypesAreEqual - This routine checks two function proto types /// for equlity of their argument types. Caller has already checked that /// they have same number of arguments. This routine assumes that Objective-C /// pointer types which only differ in their protocol qualifiers are equal. -bool Sema::FunctionArgTypesAreEqual(const FunctionProtoType *OldType, +bool Sema::FunctionArgTypesAreEqual(const FunctionProtoType *OldType, const FunctionProtoType *NewType) { if (!getLangOptions().ObjC1) return std::equal(OldType->arg_type_begin(), OldType->arg_type_end(), NewType->arg_type_begin()); - + for (FunctionProtoType::arg_type_iterator O = OldType->arg_type_begin(), N = NewType->arg_type_begin(), E = OldType->arg_type_end(); O && (O != E); ++O, ++N) { @@ -1808,12 +1808,12 @@ bool Sema::FunctionArgTypesAreEqual(const FunctionProtoType *OldType, } else if (const ObjCObjectPointerType *PTTo = ToType->getAs()) { - if (const ObjCObjectPointerType *PTFr = + if (const ObjCObjectPointerType *PTFr = FromType->getAs()) if (PTTo->getInterfaceDecl() == PTFr->getInterfaceDecl()) continue; } - return false; + return false; } } return true; @@ -1854,7 +1854,7 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType, From->getSourceRange(), &BasePath, IgnoreBaseAccess)) return true; - + // The conversion was successful. Kind = CK_DerivedToBase; } @@ -1885,7 +1885,7 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType, /// If so, returns true and places the converted type (that might differ from /// ToType in its cv-qualifiers at some level) into ConvertedType. bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType, - QualType ToType, + QualType ToType, bool InOverloadResolution, QualType &ConvertedType) { const MemberPointerType *ToTypePtr = ToType->getAs(); @@ -1920,7 +1920,7 @@ bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType, return false; } - + /// CheckMemberPointerConversion - Check the member pointer conversion from the /// expression From to the type ToType. This routine checks for ambiguous or /// virtual or inaccessible base-to-derived member pointer conversions @@ -1935,7 +1935,7 @@ bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType, const MemberPointerType *FromPtrType = FromType->getAs(); if (!FromPtrType) { // This must be a null pointer to member pointer conversion - assert(From->isNullPointerConstant(Context, + assert(From->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull) && "Expr must be null pointer constant!"); Kind = CK_NullToMemberPointer; @@ -1990,7 +1990,7 @@ bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType, /// an rvalue of type FromType to ToType is a qualification conversion /// (C++ 4.4). bool -Sema::IsQualificationConversion(QualType FromType, QualType ToType, +Sema::IsQualificationConversion(QualType FromType, QualType ToType, bool CStyle) { FromType = Context.getCanonicalType(FromType); ToType = Context.getCanonicalType(ToType); @@ -2092,13 +2092,13 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, = cast(ConstructorTmpl->getTemplatedDecl()); else Constructor = cast(D); - + if (!Constructor->isInvalidDecl() && Constructor->isConvertingConstructor(AllowExplicit)) { if (ConstructorTmpl) S.AddTemplateOverloadCandidate(ConstructorTmpl, FoundDecl, /*ExplicitArgs*/ 0, - &From, 1, CandidateSet, + &From, 1, CandidateSet, /*SuppressUserConversions=*/ !ConstructorsOnly); else @@ -2212,19 +2212,19 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType, case OR_Deleted: // No conversion here! We're done. return OR_Deleted; - + case OR_Ambiguous: return OR_Ambiguous; } return OR_No_Viable_Function; } - + bool Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) { ImplicitConversionSequence ICS; OverloadCandidateSet CandidateSet(From->getExprLoc()); - OverloadingResult OvResult = + OverloadingResult OvResult = IsUserDefinedConversion(*this, From, ToType, ICS.UserDefined, CandidateSet, false); if (OvResult == OR_Ambiguous) @@ -2238,7 +2238,7 @@ Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) { else return false; CandidateSet.NoteCandidates(*this, OCD_AllCandidates, &From, 1); - return true; + return true; } /// CompareImplicitConversionSequences - Compare two implicit @@ -2299,12 +2299,12 @@ static bool hasSimilarType(ASTContext &Context, QualType T1, QualType T2) { while (Context.UnwrapSimilarPointerTypes(T1, T2)) { Qualifiers Quals; T1 = Context.getUnqualifiedArrayType(T1, Quals); - T2 = Context.getUnqualifiedArrayType(T2, Quals); + T2 = Context.getUnqualifiedArrayType(T2, Quals); } - + return Context.hasSameUnqualifiedType(T1, T2); } - + // Per 13.3.3.2p3, compare the given standard conversion sequences to // determine if one is a proper subset of the other. static ImplicitConversionSequence::CompareKind @@ -2314,7 +2314,7 @@ compareStandardConversionSubsets(ASTContext &Context, ImplicitConversionSequence::CompareKind Result = ImplicitConversionSequence::Indistinguishable; - // the identity conversion sequence is considered to be a subsequence of + // the identity conversion sequence is considered to be a subsequence of // any non-identity conversion sequence if (SCS1.ReferenceBinding == SCS2.ReferenceBinding) { if (SCS1.isIdentityConversion() && !SCS2.isIdentityConversion()) @@ -2322,7 +2322,7 @@ compareStandardConversionSubsets(ASTContext &Context, else if (!SCS1.isIdentityConversion() && SCS2.isIdentityConversion()) return ImplicitConversionSequence::Worse; } - + if (SCS1.Second != SCS2.Second) { if (SCS1.Second == ICK_Identity) Result = ImplicitConversionSequence::Better; @@ -2347,7 +2347,7 @@ compareStandardConversionSubsets(ASTContext &Context, return Result == ImplicitConversionSequence::Better ? ImplicitConversionSequence::Indistinguishable : ImplicitConversionSequence::Worse; - + return ImplicitConversionSequence::Indistinguishable; } @@ -2358,9 +2358,9 @@ static bool isBetterReferenceBindingKind(const StandardConversionSequence &SCS1, // C++0x [over.ics.rank]p3b4: // -- S1 and S2 are reference bindings (8.5.3) and neither refers to an // implicit object parameter of a non-static member function declared - // without a ref-qualifier, and *either* S1 binds an rvalue reference + // without a ref-qualifier, and *either* S1 binds an rvalue reference // to an rvalue and S2 binds an lvalue reference *or S1 binds an - // lvalue reference to a function lvalue and S2 binds an rvalue + // lvalue reference to a function lvalue and S2 binds an rvalue // reference*. // // FIXME: Rvalue references. We're going rogue with the above edits, @@ -2371,13 +2371,13 @@ static bool isBetterReferenceBindingKind(const StandardConversionSequence &SCS1, if (SCS1.BindsImplicitObjectArgumentWithoutRefQualifier || SCS2.BindsImplicitObjectArgumentWithoutRefQualifier) return false; - + return (!SCS1.IsLvalueReference && SCS1.BindsToRvalue && SCS2.IsLvalueReference) || (SCS1.IsLvalueReference && SCS1.BindsToFunctionLvalue && !SCS2.IsLvalueReference); } - + /// CompareStandardConversionSequences - Compare two standard /// conversion sequences to determine whether one is better than the /// other or if they are indistinguishable (C++ 13.3.3.2p3). @@ -2488,7 +2488,7 @@ CompareStandardConversionSequences(Sema &S, return ImplicitConversionSequence::Better; else if (isBetterReferenceBindingKind(SCS2, SCS1)) return ImplicitConversionSequence::Worse; - + // C++ [over.ics.rank]p3b4: // -- S1 and S2 are reference bindings (8.5.3), and the types to // which the references refer are the same type except for @@ -2709,13 +2709,13 @@ CompareDerivedToBaseConversions(Sema &S, if (SCS1.Second == ICK_Pointer_Member && SCS2.Second == ICK_Pointer_Member && FromType1->isMemberPointerType() && FromType2->isMemberPointerType() && ToType1->isMemberPointerType() && ToType2->isMemberPointerType()) { - const MemberPointerType * FromMemPointer1 = + const MemberPointerType * FromMemPointer1 = FromType1->getAs(); - const MemberPointerType * ToMemPointer1 = + const MemberPointerType * ToMemPointer1 = ToType1->getAs(); - const MemberPointerType * FromMemPointer2 = + const MemberPointerType * FromMemPointer2 = FromType2->getAs(); - const MemberPointerType * ToMemPointer2 = + const MemberPointerType * ToMemPointer2 = ToType2->getAs(); const Type *FromPointeeType1 = FromMemPointer1->getClass(); const Type *ToPointeeType1 = ToMemPointer1->getClass(); @@ -2740,7 +2740,7 @@ CompareDerivedToBaseConversions(Sema &S, return ImplicitConversionSequence::Worse; } } - + if (SCS1.Second == ICK_Derived_To_Base) { // -- conversion of C to B is better than conversion of C to A, // -- binding of an expression of type C to a reference of type @@ -2864,11 +2864,11 @@ FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, else Conv = cast(D); - // If this is an explicit conversion, and we're not allowed to consider + // If this is an explicit conversion, and we're not allowed to consider // explicit conversions, skip it. if (!AllowExplicit && Conv->isExplicit()) continue; - + if (AllowRvalues) { bool DerivedToBase = false; bool ObjCConversion = false; @@ -2893,7 +2893,7 @@ FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, !RefType->getPointeeType()->isFunctionType())) continue; } - + if (ConvTemplate) S.AddTemplateConversionCandidate(ConvTemplate, I.getPair(), ActingDC, Init, DeclType, CandidateSet); @@ -2943,7 +2943,7 @@ FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS, // conversion; continue with other checks. return false; } - + return false; } @@ -3035,7 +3035,7 @@ TryReferenceInit(Sema &S, Expr *&Init, QualType DeclType, // conversion functions (13.3.1.6) and choosing the best // one through overload resolution (13.3)), if (!SuppressUserConversions && T2->isRecordType() && - !S.RequireCompleteType(DeclLoc, T2, 0) && + !S.RequireCompleteType(DeclLoc, T2, 0) && RefRelationship == Sema::Ref_Incompatible) { if (FindConversionForRefInit(S, ICS, DeclType, DeclLoc, Init, T2, /*AllowRvalues=*/false, @@ -3047,7 +3047,7 @@ TryReferenceInit(Sema &S, Expr *&Init, QualType DeclType, // -- Otherwise, the reference shall be an lvalue reference to a // non-volatile const type (i.e., cv1 shall be const), or the reference // shall be an rvalue reference. - // + // // We actually handle one oddity of C++ [over.ics.ref] at this // point, which is that, due to p2 (which short-circuits reference // binding by only attempting a simple conversion for non-direct @@ -3070,7 +3070,7 @@ TryReferenceInit(Sema &S, Expr *&Init, QualType DeclType, (InitCategory.isLValue() && T2->isFunctionType()))) { ICS.setStandard(); ICS.Standard.First = ICK_Identity; - ICS.Standard.Second = DerivedToBase? ICK_Derived_To_Base + ICS.Standard.Second = DerivedToBase? ICK_Derived_To_Base : ObjCConversion? ICK_Compatible_Conversion : ICK_Identity; ICS.Standard.Third = ICK_Identity; @@ -3084,29 +3084,29 @@ TryReferenceInit(Sema &S, Expr *&Init, QualType DeclType, // Note: Although xvalues wouldn't normally show up in C++98/03 code, we // allow the use of rvalue references in C++98/03 for the benefit of // standard library implementors; therefore, we need the xvalue check here. - ICS.Standard.DirectBinding = - S.getLangOptions().CPlusPlus0x || + ICS.Standard.DirectBinding = + S.getLangOptions().CPlusPlus0x || (InitCategory.isPRValue() && !T2->isRecordType()); ICS.Standard.IsLvalueReference = !isRValRef; ICS.Standard.BindsToFunctionLvalue = T2->isFunctionType(); - ICS.Standard.BindsToRvalue = InitCategory.isRValue(); + ICS.Standard.BindsToRvalue = InitCategory.isRValue(); ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier = false; ICS.Standard.CopyConstructor = 0; - return ICS; + return ICS; } - + // -- has a class type (i.e., T2 is a class type), where T1 is not // reference-related to T2, and can be implicitly converted to - // an xvalue, class prvalue, or function lvalue of type - // "cv3 T3", where "cv1 T1" is reference-compatible with + // an xvalue, class prvalue, or function lvalue of type + // "cv3 T3", where "cv1 T1" is reference-compatible with // "cv3 T3", // - // then the reference is bound to the value of the initializer + // then the reference is bound to the value of the initializer // expression in the first case and to the result of the conversion - // in the second case (or, in either case, to an appropriate base + // in the second case (or, in either case, to an appropriate base // class subobject). if (!SuppressUserConversions && RefRelationship == Sema::Ref_Incompatible && - T2->isRecordType() && !S.RequireCompleteType(DeclLoc, T2, 0) && + T2->isRecordType() && !S.RequireCompleteType(DeclLoc, T2, 0) && FindConversionForRefInit(S, ICS, DeclType, DeclLoc, Init, T2, /*AllowRvalues=*/true, AllowExplicit)) { @@ -3114,13 +3114,13 @@ TryReferenceInit(Sema &S, Expr *&Init, QualType DeclType, // and the second standard conversion sequence of the // user-defined conversion sequence includes an lvalue-to-rvalue // conversion, the program is ill-formed. - if (ICS.isUserDefined() && isRValRef && + if (ICS.isUserDefined() && isRValRef && ICS.UserDefined.After.First == ICK_Lvalue_To_Rvalue) ICS.setBad(BadConversionSequence::no_conversion, Init, DeclType); return ICS; } - + // -- Otherwise, a temporary of type "cv1 T1" is created and // initialized from the initializer expression using the // rules for a non-reference copy initialization (8.5). The @@ -3192,7 +3192,7 @@ TryReferenceInit(Sema &S, Expr *&Init, QualType DeclType, /// do not permit any user-defined conversion sequences. static ImplicitConversionSequence TryCopyInitialization(Sema &S, Expr *From, QualType ToType, - bool SuppressUserConversions, + bool SuppressUserConversions, bool InOverloadResolution) { if (ToType->isReferenceType()) return TryReferenceInit(S, From, ToType, @@ -3239,7 +3239,7 @@ TryObjectArgumentInitialization(Sema &S, QualType OrigFromType, assert(FromType->isRecordType()); // C++0x [over.match.funcs]p4: - // For non-static member functions, the type of the implicit object + // For non-static member functions, the type of the implicit object // parameter is // // - "lvalue reference to cv X" for functions declared without a @@ -3247,10 +3247,10 @@ TryObjectArgumentInitialization(Sema &S, QualType OrigFromType, // - "rvalue reference to cv X" for functions declared with the && // ref-qualifier // - // where X is the class of which the function is a member and cv is the + // where X is the class of which the function is a member and cv is the // cv-qualification on the member function declaration. // - // However, when finding an implicit conversion sequence for the argument, we + // However, when finding an implicit conversion sequence for the argument, we // are not allowed to create temporaries or perform user-defined conversions // (C++ [over.match.funcs]p5). We perform a simplified version of // reference binding here, that allows class rvalues to bind to @@ -3258,7 +3258,7 @@ TryObjectArgumentInitialization(Sema &S, QualType OrigFromType, // First check the qualifiers. QualType FromTypeCanon = S.Context.getCanonicalType(FromType); - if (ImplicitParamType.getCVRQualifiers() + if (ImplicitParamType.getCVRQualifiers() != FromTypeCanon.getLocalCVRQualifiers() && !ImplicitParamType.isAtLeastAsQualifiedAs(FromTypeCanon)) { ICS.setBad(BadConversionSequence::bad_qualifiers, @@ -3285,11 +3285,11 @@ TryObjectArgumentInitialization(Sema &S, QualType OrigFromType, case RQ_None: // Do nothing; we don't care about lvalueness or rvalueness. break; - + case RQ_LValue: if (!FromClassification.isLValue() && Quals != Qualifiers::Const) { // non-const lvalue reference cannot bind to an rvalue - ICS.setBad(BadConversionSequence::lvalue_ref_to_rvalue, FromType, + ICS.setBad(BadConversionSequence::lvalue_ref_to_rvalue, FromType, ImplicitParamType); return ICS; } @@ -3298,13 +3298,13 @@ TryObjectArgumentInitialization(Sema &S, QualType OrigFromType, case RQ_RValue: if (!FromClassification.isRValue()) { // rvalue reference cannot bind to an lvalue - ICS.setBad(BadConversionSequence::rvalue_ref_to_lvalue, FromType, + ICS.setBad(BadConversionSequence::rvalue_ref_to_lvalue, FromType, ImplicitParamType); return ICS; } break; } - + // Success. Mark this as a reference binding. ICS.setStandard(); ICS.Standard.setAsIdentityConversion(); @@ -3313,7 +3313,7 @@ TryObjectArgumentInitialization(Sema &S, QualType OrigFromType, ICS.Standard.setAllToTypes(ImplicitParamType); ICS.Standard.ReferenceBinding = true; ICS.Standard.DirectBinding = true; - ICS.Standard.IsLvalueReference = Method->getRefQualifier() != RQ_RValue; + ICS.Standard.IsLvalueReference = Method->getRefQualifier() != RQ_RValue; ICS.Standard.BindsToFunctionLvalue = false; ICS.Standard.BindsToRvalue = FromClassification.isRValue(); ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier @@ -3325,8 +3325,8 @@ TryObjectArgumentInitialization(Sema &S, QualType OrigFromType, /// the implicit object parameter for the given Method with the given /// expression. bool -Sema::PerformObjectArgumentInitialization(Expr *&From, - NestedNameSpecifier *Qualifier, +Sema::PerformObjectArgumentInitialization(Expr *&From, + NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method) { QualType FromRecordType, DestType; @@ -3398,14 +3398,14 @@ bool Sema::PerformContextuallyConvertToBool(Expr *&From) { ImplicitConversionSequence ICS = TryContextuallyConvertToBool(*this, From); if (!ICS.isBad()) return PerformImplicitConversion(From, Context.BoolTy, ICS, AA_Converting); - + if (!DiagnoseMultipleUserDefinedConversion(From, Context.BoolTy)) return Diag(From->getSourceRange().getBegin(), diag::err_typecheck_bool_condition) << From->getType() << From->getSourceRange(); return true; } - + /// TryContextuallyConvertToObjCId - Attempt to contextually convert the /// expression From to 'id'. static ImplicitConversionSequence @@ -3429,7 +3429,7 @@ bool Sema::PerformContextuallyConvertToObjCId(Expr *&From) { return true; } -/// \brief Attempt to convert the given expression to an integral or +/// \brief Attempt to convert the given expression to an integral or /// enumeration type. /// /// This routine will attempt to convert an expression of class type to an @@ -3457,7 +3457,7 @@ bool Sema::PerformContextuallyConvertToObjCId(Expr *&From) { /// \param AmbigDiag The diagnostic to be emitted if there is more than one /// conversion function that could convert to integral or enumeration type. /// -/// \param AmbigNote The note to be emitted with \p AmbigDiag for each +/// \param AmbigNote The note to be emitted with \p AmbigDiag for each /// usable conversion function. /// /// \param ConvDiag The diagnostic to be emitted if we are calling a conversion @@ -3465,7 +3465,7 @@ bool Sema::PerformContextuallyConvertToObjCId(Expr *&From) { /// /// \returns The expression, converted to an integral or enumeration type if /// successful. -ExprResult +ExprResult Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From, const PartialDiagnostic &NotIntDiag, const PartialDiagnostic &IncompleteDiag, @@ -3477,7 +3477,7 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From, // We can't perform any more checking for type-dependent expressions. if (From->isTypeDependent()) return Owned(From); - + // If the expression already has integral or enumeration type, we're golden. QualType T = From->getType(); if (T->isIntegralOrEnumerationType()) @@ -3485,7 +3485,7 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From, // FIXME: Check for missing '()' if T is a function type? - // If we don't have a class type in C++, there's no way we can get an + // If we don't have a class type in C++, there's no way we can get an // expression of integral or enumeration type. const RecordType *RecordTy = T->getAs(); if (!RecordTy || !getLangOptions().CPlusPlus) { @@ -3493,20 +3493,20 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From, << T << From->getSourceRange(); return Owned(From); } - + // We must have a complete class type. if (RequireCompleteType(Loc, T, IncompleteDiag)) return Owned(From); - + // Look for a conversion to an integral or enumeration type. UnresolvedSet<4> ViableConversions; UnresolvedSet<4> ExplicitConversions; const UnresolvedSetImpl *Conversions = cast(RecordTy->getDecl())->getVisibleConversionFunctions(); - + for (UnresolvedSetImpl::iterator I = Conversions->begin(), - E = Conversions->end(); - I != E; + E = Conversions->end(); + I != E; ++I) { if (CXXConversionDecl *Conversion = dyn_cast((*I)->getUnderlyingDecl())) @@ -3518,21 +3518,21 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From, ViableConversions.addDecl(I.getDecl(), I.getAccess()); } } - + switch (ViableConversions.size()) { case 0: if (ExplicitConversions.size() == 1) { DeclAccessPair Found = ExplicitConversions[0]; CXXConversionDecl *Conversion = cast(Found->getUnderlyingDecl()); - + // The user probably meant to invoke the given explicit // conversion; use it. QualType ConvTy = Conversion->getConversionType().getNonReferenceType(); std::string TypeStr; ConvTy.getAsStringInternal(TypeStr, Context.PrintingPolicy); - + Diag(Loc, ExplicitConvDiag) << T << ConvTy << FixItHint::CreateInsertion(From->getLocStart(), @@ -3541,49 +3541,49 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From, ")"); Diag(Conversion->getLocation(), ExplicitConvNote) << ConvTy->isEnumeralType() << ConvTy; - - // If we aren't in a SFINAE context, build a call to the + + // If we aren't in a SFINAE context, build a call to the // explicit conversion function. if (isSFINAEContext()) return ExprError(); - + CheckMemberOperatorAccess(From->getExprLoc(), From, 0, Found); ExprResult Result = BuildCXXMemberCallExpr(From, Found, Conversion); if (Result.isInvalid()) return ExprError(); - + From = Result.get(); } - + // We'll complain below about a non-integral condition type. break; - + case 1: { // Apply this conversion. DeclAccessPair Found = ViableConversions[0]; CheckMemberOperatorAccess(From->getExprLoc(), From, 0, Found); - + CXXConversionDecl *Conversion = cast(Found->getUnderlyingDecl()); QualType ConvTy - = Conversion->getConversionType().getNonReferenceType(); + = Conversion->getConversionType().getNonReferenceType(); if (ConvDiag.getDiagID()) { if (isSFINAEContext()) return ExprError(); - + Diag(Loc, ConvDiag) << T << ConvTy->isEnumeralType() << ConvTy << From->getSourceRange(); } - + ExprResult Result = BuildCXXMemberCallExpr(From, Found, cast(Found->getUnderlyingDecl())); if (Result.isInvalid()) return ExprError(); - + From = Result.get(); break; } - + default: Diag(Loc, AmbigDiag) << T << From->getSourceRange(); @@ -3596,7 +3596,7 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From, } return Owned(From); } - + if (!From->getType()->isIntegralOrEnumerationType()) Diag(Loc, NotIntDiag) << From->getType() << From->getSourceRange(); @@ -3635,7 +3635,7 @@ Sema::AddOverloadCandidate(FunctionDecl *Function, // object argument (C++ [over.call.func]p3), and the acting context // is irrelevant. AddMethodCandidate(Method, FoundDecl, Method->getParent(), - QualType(), Expr::Classification::makeSimpleLValue(), + QualType(), Expr::Classification::makeSimpleLValue(), Args, NumArgs, CandidateSet, SuppressUserConversions); return; @@ -3655,13 +3655,13 @@ Sema::AddOverloadCandidate(FunctionDecl *Function, // A member function template is never instantiated to perform the copy // of a class object to an object of its class type. QualType ClassType = Context.getTypeDeclType(Constructor->getParent()); - if (NumArgs == 1 && + if (NumArgs == 1 && Constructor->isSpecializationCopyingObject() && (Context.hasSameUnqualifiedType(ClassType, Args[0]->getType()) || IsDerivedFrom(Args[0]->getType(), ClassType))) return; } - + // Add this candidate CandidateSet.push_back(OverloadCandidate()); OverloadCandidate& Candidate = CandidateSet.back(); @@ -3671,13 +3671,13 @@ Sema::AddOverloadCandidate(FunctionDecl *Function, Candidate.IsSurrogate = false; Candidate.IgnoreObjectArgument = false; Candidate.ExplicitCallArguments = NumArgs; - + unsigned NumArgsInProto = Proto->getNumArgs(); // (C++ 13.3.2p2): A candidate function having fewer than m // parameters is viable only if it has an ellipsis in its parameter // list (8.3.5). - if ((NumArgs + (PartialOverloading && NumArgs)) > NumArgsInProto && + if ((NumArgs + (PartialOverloading && NumArgs)) > NumArgsInProto && !Proto->isVariadic()) { Candidate.Viable = false; Candidate.FailureKind = ovl_fail_too_many_arguments; @@ -3709,7 +3709,7 @@ Sema::AddOverloadCandidate(FunctionDecl *Function, QualType ParamType = Proto->getArgType(ArgIdx); Candidate.Conversions[ArgIdx] = TryCopyInitialization(*this, Args[ArgIdx], ParamType, - SuppressUserConversions, + SuppressUserConversions, /*InOverloadResolution=*/true); if (Candidate.Conversions[ArgIdx].isBad()) { Candidate.Viable = false; @@ -3738,7 +3738,7 @@ void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns, AddMethodCandidate(cast(FD), F.getPair(), cast(FD)->getParent(), Args[0]->getType(), Args[0]->Classify(Context), - Args + 1, NumArgs - 1, + Args + 1, NumArgs - 1, CandidateSet, SuppressUserConversions); else AddOverloadCandidate(FD, F.getPair(), Args, NumArgs, CandidateSet, @@ -3750,7 +3750,7 @@ void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns, AddMethodTemplateCandidate(FunTmpl, F.getPair(), cast(FunTmpl->getDeclContext()), /*FIXME: explicit args */ 0, - Args[0]->getType(), + Args[0]->getType(), Args[0]->Classify(Context), Args + 1, NumArgs - 1, CandidateSet, @@ -3777,7 +3777,7 @@ void Sema::AddMethodCandidate(DeclAccessPair FoundDecl, if (isa(Decl)) Decl = cast(Decl)->getTargetDecl(); - + if (FunctionTemplateDecl *TD = dyn_cast(Decl)) { assert(isa(TD->getTemplatedDecl()) && "Expected a member function template"); @@ -3882,7 +3882,7 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl, QualType ParamType = Proto->getArgType(ArgIdx); Candidate.Conversions[ArgIdx + 1] = TryCopyInitialization(*this, Args[ArgIdx], ParamType, - SuppressUserConversions, + SuppressUserConversions, /*InOverloadResolution=*/true); if (Candidate.Conversions[ArgIdx + 1].isBad()) { Candidate.Viable = false; @@ -3897,7 +3897,7 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl, } } } - + /// \brief Add a C++ member function template as a candidate to the candidate /// set, using template argument deduction to produce an appropriate member /// function template specialization. @@ -3937,7 +3937,7 @@ Sema::AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, Candidate.IsSurrogate = false; Candidate.IgnoreObjectArgument = false; Candidate.ExplicitCallArguments = NumArgs; - Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result, + Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result, Info); return; } @@ -3988,7 +3988,7 @@ Sema::AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, Candidate.IsSurrogate = false; Candidate.IgnoreObjectArgument = false; Candidate.ExplicitCallArguments = NumArgs; - Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result, + Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result, Info); return; } @@ -4036,8 +4036,8 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, Candidate.ExplicitCallArguments = 1; // C++ [over.match.funcs]p4: - // For conversion functions, the function is considered to be a member of - // the class of the implicit implied object argument for the purpose of + // For conversion functions, the function is considered to be a member of + // the class of the implicit implied object argument for the purpose of // defining the type of the implicit object parameter. // // Determine the implicit conversion sequence for the implicit @@ -4047,19 +4047,19 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, ImplicitParamType = FromPtrType->getPointeeType(); CXXRecordDecl *ConversionContext = cast(ImplicitParamType->getAs()->getDecl()); - + Candidate.Conversions[0] - = TryObjectArgumentInitialization(*this, From->getType(), - From->Classify(Context), + = TryObjectArgumentInitialization(*this, From->getType(), + From->Classify(Context), Conversion, ConversionContext); - + if (Candidate.Conversions[0].isBad()) { Candidate.Viable = false; Candidate.FailureKind = ovl_fail_bad_conversion; return; } - // We won't go through a user-define type conversion function to convert a + // We won't go through a user-define type conversion function to convert a // derived to base as such conversions are given Conversion Rank. They only // go through a copy constructor. 13.3.3.1.2-p4 [over.ics.user] QualType FromCanon @@ -4070,7 +4070,7 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, Candidate.FailureKind = ovl_fail_trivial_conversion; return; } - + // To determine what the conversion from the result of calling the // conversion function to the type we're eventually trying to // convert to (ToType), we need to synthesize a call to the @@ -4109,23 +4109,23 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, switch (ICS.getKind()) { case ImplicitConversionSequence::StandardConversion: Candidate.FinalConversion = ICS.Standard; - + // C++ [over.ics.user]p3: // If the user-defined conversion is specified by a specialization of a - // conversion function template, the second standard conversion sequence + // conversion function template, the second standard conversion sequence // shall have exact match rank. if (Conversion->getPrimaryTemplate() && GetConversionRank(ICS.Standard.Second) != ICR_Exact_Match) { Candidate.Viable = false; Candidate.FailureKind = ovl_fail_final_conversion_not_exact; } - + // C++0x [dcl.init.ref]p5: // In the second case, if the reference is an rvalue reference and // the second standard conversion sequence of the user-defined // conversion sequence includes an lvalue-to-rvalue conversion, the // program is ill-formed. - if (ToType->isRValueReferenceType() && + if (ToType->isRValueReferenceType() && ICS.Standard.First == ICK_Lvalue_To_Rvalue) { Candidate.Viable = false; Candidate.FailureKind = ovl_fail_bad_final_conversion; @@ -4174,7 +4174,7 @@ Sema::AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, Candidate.IsSurrogate = false; Candidate.IgnoreObjectArgument = false; Candidate.ExplicitCallArguments = 1; - Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result, + Candidate.DeductionFailure = MakeDeductionFailureInfo(Context, Result, Info); return; } @@ -4218,7 +4218,7 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion, // Determine the implicit conversion sequence for the implicit // object parameter. ImplicitConversionSequence ObjectInit - = TryObjectArgumentInitialization(*this, Object->getType(), + = TryObjectArgumentInitialization(*this, Object->getType(), Object->Classify(Context), Conversion, ActingContext); if (ObjectInit.isBad()) { @@ -4235,7 +4235,7 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion, Candidate.Conversions[0].UserDefined.Before = ObjectInit.Standard; Candidate.Conversions[0].UserDefined.EllipsisConversion = false; Candidate.Conversions[0].UserDefined.ConversionFunction = Conversion; - Candidate.Conversions[0].UserDefined.FoundConversionFunction + Candidate.Conversions[0].UserDefined.FoundConversionFunction = FoundDecl.getDecl(); Candidate.Conversions[0].UserDefined.After = Candidate.Conversions[0].UserDefined.Before; @@ -4332,7 +4332,7 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op, Oper != OperEnd; ++Oper) AddMethodCandidate(Oper.getPair(), Args[0]->getType(), - Args[0]->Classify(Context), Args + 1, NumArgs - 1, + Args[0]->Classify(Context), Args + 1, NumArgs - 1, CandidateSet, /* SuppressUserConversions = */ false); } @@ -4422,7 +4422,7 @@ class BuiltinCandidateTypeSet { /// used in the built-in candidates. TypeSet EnumerationTypes; - /// \brief The set of vector types that will be used in the built-in + /// \brief The set of vector types that will be used in the built-in /// candidates. TypeSet VectorTypes; @@ -4454,7 +4454,7 @@ public: SemaRef(SemaRef), Context(SemaRef.Context) { } - void AddTypesConvertedFrom(QualType Ty, + void AddTypesConvertedFrom(QualType Ty, SourceLocation Loc, bool AllowUserConversions, bool AllowExplicitConversions, @@ -4477,7 +4477,7 @@ public: /// enumeration_end - Past the last enumeration type found; iterator enumeration_end() { return EnumerationTypes.end(); } - + iterator vector_begin() { return VectorTypes.begin(); } iterator vector_end() { return VectorTypes.end(); } @@ -4501,7 +4501,7 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty, // Insert this type. if (!PointerTypes.insert(Ty)) return false; - + QualType PointeeTy; const PointerType *PointerTy = Ty->getAs(); bool buildObjCPtr = false; @@ -4515,7 +4515,7 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty, } else PointeeTy = PointerTy->getPointeeType(); - + // Don't add qualified variants of arrays. For one, they're not allowed // (the qualifier would sink to the element type), and for another, the // only overload situation where it matters is subscript or pointer +- int, @@ -4527,7 +4527,7 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty, BaseCVR = Array->getElementType().getCVRQualifiers(); bool hasVolatile = VisibleQuals.hasVolatile(); bool hasRestrict = VisibleQuals.hasRestrict(); - + // Iterate through all strict supersets of BaseCVR. for (unsigned CVR = BaseCVR+1; CVR <= Qualifiers::CVRMask; ++CVR) { if ((CVR | BaseCVR) != CVR) continue; @@ -4578,7 +4578,7 @@ BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants( unsigned BaseCVR = PointeeTy.getCVRQualifiers(); for (unsigned CVR = BaseCVR+1; CVR <= Qualifiers::CVRMask; ++CVR) { if ((CVR | BaseCVR) != CVR) continue; - + QualType QPointeeTy = Context.getCVRQualifiedType(PointeeTy, CVR); MemberPointerTypes.insert( Context.getMemberPointerType(QPointeeTy, ClassTy)); @@ -4713,14 +4713,14 @@ static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr* ArgExpr) { VRQuals.addRestrict(); return VRQuals; } - + CXXRecordDecl *ClassDecl = cast(TyRec->getDecl()); if (!ClassDecl->hasDefinition()) return VRQuals; const UnresolvedSetImpl *Conversions = ClassDecl->getVisibleConversionFunctions(); - + for (UnresolvedSetImpl::iterator I = Conversions->begin(), E = Conversions->end(); I != E; ++I) { NamedDecl *D = I.getDecl(); @@ -4736,7 +4736,7 @@ static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr* ArgExpr) { while (!done) { if (const PointerType *ResTypePtr = CanTy->getAs()) CanTy = ResTypePtr->getPointeeType(); - else if (const MemberPointerType *ResTypeMPtr = + else if (const MemberPointerType *ResTypeMPtr = CanTy->getAs()) CanTy = ResTypeMPtr->getPointeeType(); else @@ -4985,7 +4985,7 @@ public: // T& operator*(T*); // // C++ [over.built]p7: - // For every function type T that does not have cv-qualifiers or a + // For every function type T that does not have cv-qualifiers or a // ref-qualifier, there exist candidate operator functions of the form // T& operator*(T*); void addUnaryStarPointerOverloads() { @@ -4997,11 +4997,11 @@ public: QualType PointeeTy = ParamTy->getPointeeType(); if (!PointeeTy->isObjectType() && !PointeeTy->isFunctionType()) continue; - + if (const FunctionProtoType *Proto =PointeeTy->getAs()) if (Proto->getTypeQuals() || Proto->getRefQualifier()) continue; - + S.AddBuiltinCandidate(S.Context.getLValueReferenceType(PointeeTy), &ParamTy, Args, 1, CandidateSet); } @@ -5606,7 +5606,7 @@ public: QualType PointeeType = (*Ptr)->getPointeeType(); if (!PointeeType->isObjectType()) continue; - + QualType ResultTy = S.Context.getLValueReferenceType(PointeeType); // T& operator[](T*, ptrdiff_t) @@ -5966,7 +5966,7 @@ Sema::AddArgumentDependentLookupCandidates(DeclarationName Name, if (FunctionDecl *FD = dyn_cast(*I)) { if (ExplicitTemplateArgs) continue; - + AddOverloadCandidate(FD, FoundDecl, Args, NumArgs, CandidateSet, false, PartialOverloading); } else @@ -6048,12 +6048,12 @@ isBetterOverloadCandidate(Sema &S, = S.getMoreSpecializedTemplate(Cand1.Function->getPrimaryTemplate(), Cand2.Function->getPrimaryTemplate(), Loc, - isa(Cand1.Function)? TPOC_Conversion + isa(Cand1.Function)? TPOC_Conversion : TPOC_Call, Cand1.ExplicitCallArguments)) return BetterTemplate == Cand1.Function->getPrimaryTemplate(); } - + // -- the context is an initialization by user-defined conversion // (see 8.5, 13.3.1.5) and the standard conversion sequence // from the return type of F1 to the destination type (i.e., @@ -6103,7 +6103,7 @@ OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc, Best = end(); for (iterator Cand = begin(); Cand != end(); ++Cand) { if (Cand->Viable) - if (Best == end() || isBetterOverloadCandidate(S, *Cand, *Best, Loc, + if (Best == end() || isBetterOverloadCandidate(S, *Cand, *Best, Loc, UserDefinedConversion)) Best = Cand; } @@ -6117,7 +6117,7 @@ OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc, for (iterator Cand = begin(); Cand != end(); ++Cand) { if (Cand->Viable && Cand != Best && - !isBetterOverloadCandidate(S, *Best, *Cand, Loc, + !isBetterOverloadCandidate(S, *Best, *Cand, Loc, UserDefinedConversion)) { Best = end(); return OR_Ambiguous; @@ -6138,7 +6138,7 @@ OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc, // placement new (5.3.4), as well as non-default initialization (8.5). if (Best->Function) S.MarkDeclarationReferenced(Loc, Best->Function); - + return OR_Success; } @@ -6327,7 +6327,7 @@ void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I) { FromPtrTy->getPointeeType()) && !FromPtrTy->getPointeeType()->isIncompleteType() && !ToPtrTy->getPointeeType()->isIncompleteType() && - S.IsDerivedFrom(ToPtrTy->getPointeeType(), + S.IsDerivedFrom(ToPtrTy->getPointeeType(), FromPtrTy->getPointeeType())) BaseToDerivedConversion = 1; } @@ -6348,17 +6348,17 @@ void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I) { S.IsDerivedFrom(ToRefTy->getPointeeType(), FromTy)) BaseToDerivedConversion = 3; } - + if (BaseToDerivedConversion) { - S.Diag(Fn->getLocation(), + S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_base_to_derived_conv) << (unsigned) FnKind << FnDesc << (FromExpr ? FromExpr->getSourceRange() : SourceRange()) << (BaseToDerivedConversion - 1) - << FromTy << ToTy << I+1; + << FromTy << ToTy << I+1; return; } - + // TODO: specialize more based on the kind of mismatch S.Diag(Fn->getLocation(), diag::note_ovl_candidate_bad_conv) << (unsigned) FnKind << FnDesc @@ -6374,14 +6374,14 @@ void DiagnoseArityMismatch(Sema &S, OverloadCandidate *Cand, const FunctionProtoType *FnTy = Fn->getType()->getAs(); unsigned MinParams = Fn->getMinRequiredArguments(); - + // at least / at most / exactly unsigned mode, modeCount; if (NumFormalArgs < MinParams) { assert((Cand->FailureKind == ovl_fail_too_few_arguments) || (Cand->FailureKind == ovl_fail_bad_deduction && Cand->DeductionFailure.Result == Sema::TDK_TooFewArguments)); - if (MinParams != FnTy->getNumArgs() || + if (MinParams != FnTy->getNumArgs() || FnTy->isVariadic() || FnTy->isTemplateVariadic()) mode = 0; // "at least" else @@ -6402,7 +6402,7 @@ void DiagnoseArityMismatch(Sema &S, OverloadCandidate *Cand, OverloadCandidateKind FnKind = ClassifyOverloadCandidate(S, Fn, Description); S.Diag(Fn->getLocation(), diag::note_ovl_candidate_arity) - << (unsigned) FnKind << (Fn->getDescribedFunctionTemplate() != 0) << mode + << (unsigned) FnKind << (Fn->getDescribedFunctionTemplate() != 0) << mode << modeCount << NumFormalArgs; } @@ -6461,18 +6461,18 @@ void DiagnoseBadDeduction(Sema &S, OverloadCandidate *Cand, else { which = 2; } - + S.Diag(Fn->getLocation(), diag::note_ovl_candidate_inconsistent_deduction) - << which << ParamD->getDeclName() + << which << ParamD->getDeclName() << *Cand->DeductionFailure.getFirstArg() << *Cand->DeductionFailure.getSecondArg(); return; } case Sema::TDK_InvalidExplicitArguments: - assert(ParamD && "no parameter found for invalid explicit arguments"); + assert(ParamD && "no parameter found for invalid explicit arguments"); if (ParamD->getDeclName()) - S.Diag(Fn->getLocation(), + S.Diag(Fn->getLocation(), diag::note_ovl_candidate_explicit_arg_mismatch_named) << ParamD->getDeclName(); else { @@ -6484,12 +6484,12 @@ void DiagnoseBadDeduction(Sema &S, OverloadCandidate *Cand, index = NTTP->getIndex(); else index = cast(ParamD)->getIndex(); - S.Diag(Fn->getLocation(), + S.Diag(Fn->getLocation(), diag::note_ovl_candidate_explicit_arg_mismatch_unnamed) << (index + 1); } return; - + case Sema::TDK_TooManyArguments: case Sema::TDK_TooFewArguments: DiagnoseArityMismatch(S, Cand, NumArgs); @@ -6510,7 +6510,7 @@ void DiagnoseBadDeduction(Sema &S, OverloadCandidate *Cand, << ArgString; return; } - + // TODO: diagnose these individually, then kill off // note_ovl_candidate_bad_deduction, which is uselessly vague. case Sema::TDK_NonDeducedMismatch: @@ -6571,7 +6571,7 @@ void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand, for (unsigned N = Cand->Conversions.size(); I != N; ++I) if (Cand->Conversions[I].isBad()) return DiagnoseBadConversion(S, Cand, I); - + // FIXME: this currently happens when we're called from SemaInit // when user-conversion overload fails. Figure out how to handle // those conditions and diagnose them well. @@ -6786,7 +6786,7 @@ void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, Cand->Conversions[ConvIdx] = TryCopyInitialization(S, Args[ConvIdx], Cand->BuiltinTypes.ParamTypes[ConvIdx], - SuppressUserConversions, + SuppressUserConversions, /*InOverloadResolution*/ true); return; } @@ -6797,7 +6797,7 @@ void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand, if (ArgIdx < NumArgsInProto) Cand->Conversions[ConvIdx] = TryCopyInitialization(S, Args[ArgIdx], Proto->getArgType(ArgIdx), - SuppressUserConversions, + SuppressUserConversions, /*InOverloadResolution=*/true); else Cand->Conversions[ConvIdx].setEllipsis(); @@ -6832,7 +6832,7 @@ void OverloadCandidateSet::NoteCandidates(Sema &S, std::sort(Cands.begin(), Cands.end(), CompareOverloadCandidatesForDisplay(S)); - + bool ReportedAmbiguousConversions = false; llvm::SmallVectorImpl::iterator I, E; @@ -6927,14 +6927,14 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, // parentheses. OverloadExpr::FindResult Ovl = OverloadExpr::find(From); OverloadExpr *OvlExpr = Ovl.Expression; - + // We expect a pointer or reference to function, or a function pointer. FunctionType = Context.getCanonicalType(FunctionType).getUnqualifiedType(); if (!FunctionType->isFunctionType()) { if (Complain) Diag(From->getLocStart(), diag::err_addr_ovl_not_func_ptrref) << OvlExpr->getName() << ToType; - + return 0; } @@ -6963,7 +6963,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, // whose type matches exactly. llvm::SmallVector, 4> Matches; llvm::SmallVector NonMatches; - + bool FoundNonTemplateFunction = false; for (UnresolvedSetIterator I = OvlExpr->decls_begin(), E = OvlExpr->decls_end(); I != E; ++I) { @@ -7018,7 +7018,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, // when converting to member pointer. if (Method->isStatic() == IsMember) continue; - + // If we have explicit template arguments, skip non-templates. if (OvlExpr->hasExplicitTemplateArgs()) continue; @@ -7028,7 +7028,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, if (FunctionDecl *FunDecl = dyn_cast(Fn)) { QualType ResultTy; if (Context.hasSameUnqualifiedType(FunctionType, FunDecl->getType()) || - IsNoReturnConversion(Context, FunDecl->getType(), FunctionType, + IsNoReturnConversion(Context, FunDecl->getType(), FunctionType, ResultTy)) { Matches.push_back(std::make_pair(I.getPair(), cast(FunDecl->getCanonicalDecl()))); @@ -7043,16 +7043,16 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, Diag(From->getLocStart(), diag::err_addr_ovl_no_viable) << OvlExpr->getName() << FunctionType; for (UnresolvedSetIterator I = OvlExpr->decls_begin(), - E = OvlExpr->decls_end(); + E = OvlExpr->decls_end(); I != E; ++I) if (FunctionDecl *F = dyn_cast((*I)->getUnderlyingDecl())) NoteOverloadCandidate(F); } - + return 0; } else if (Matches.size() == 1) { FunctionDecl *Result = Matches[0].second; - FoundResult = Matches[0].first; + FoundResult = Matches[0].first; MarkDeclarationReferenced(From->getLocStart(), Result); if (Complain) { CheckAddressOfMemberAccess(OvlExpr, Matches[0].first); @@ -7077,7 +7077,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, UnresolvedSet<4> MatchesCopy; // TODO: avoid! for (unsigned I = 0, E = Matches.size(); I != E; ++I) MatchesCopy.addDecl(Matches[I].second, Matches[I].first.getAccess()); - + UnresolvedSetIterator Result = getMostSpecialized(MatchesCopy.begin(), MatchesCopy.end(), TPOC_Other, 0, From->getLocStart(), @@ -7088,7 +7088,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, << (unsigned) oc_function_template); if (Result == MatchesCopy.end()) return 0; - + MarkDeclarationReferenced(From->getLocStart(), *Result); FoundResult = Matches[Result - MatchesCopy.begin()].first; if (Complain) @@ -7106,7 +7106,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, Matches.set_size(N); } } - + // [...] After such eliminations, if any, there shall remain exactly one // selected function. if (Matches.size() == 1) { @@ -7129,12 +7129,12 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, return 0; } -/// \brief Given an expression that refers to an overloaded function, try to +/// \brief Given an expression that refers to an overloaded function, try to /// resolve that overloaded function expression down to a single function. /// /// This routine can only resolve template-ids that refer to a single function /// template, where that template-id refers to a single template whose template -/// arguments are either provided by the template-id or have defaults, +/// arguments are either provided by the template-id or have defaults, /// as described in C++0x [temp.arg.explicit]p3. FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(Expr *From) { // C++ [over.over]p1: @@ -7148,14 +7148,14 @@ FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(Expr *From) { return 0; OverloadExpr *OvlExpr = OverloadExpr::find(From).Expression; - + // If we didn't actually find any template-ids, we're done. if (!OvlExpr->hasExplicitTemplateArgs()) return 0; TemplateArgumentListInfo ExplicitTemplateArgs; OvlExpr->getExplicitTemplateArgs().copyInto(ExplicitTemplateArgs); - + // Look through all of the overloaded functions, searching for one // whose type matches exactly. FunctionDecl *Matched = 0; @@ -7163,13 +7163,13 @@ FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(Expr *From) { E = OvlExpr->decls_end(); I != E; ++I) { // C++0x [temp.arg.explicit]p3: // [...] In contexts where deduction is done and fails, or in contexts - // where deduction is not done, if a template argument list is - // specified and it, along with any default template arguments, - // identifies a single function template specialization, then the + // where deduction is not done, if a template argument list is + // specified and it, along with any default template arguments, + // identifies a single function template specialization, then the // template-id is an lvalue for the function template specialization. FunctionTemplateDecl *FunctionTemplate = cast((*I)->getUnderlyingDecl()); - + // C++ [over.over]p2: // If the name is a function template, template argument deduction is // done (14.8.2.2), and if the argument deduction succeeds, the @@ -7184,18 +7184,18 @@ FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(Expr *From) { // FIXME: make a note of the failed deduction for diagnostics. (void)Result; continue; - } - + } + // Multiple matches; we can't resolve to a single declaration. if (Matched) return 0; Matched = Specialization; } - + return Matched; } - + /// \brief Add a single candidate to the overload set. static void AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl, @@ -7226,7 +7226,7 @@ static void AddOverloadedCallCandidate(Sema &S, // do nothing? } - + /// \brief Add the overload candidates named by callee and/or found by argument /// dependent lookup to the given overload set. void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, @@ -7274,7 +7274,7 @@ void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, for (UnresolvedLookupExpr::decls_iterator I = ULE->decls_begin(), E = ULE->decls_end(); I != E; ++I) AddOverloadedCallCandidate(*this, I.getPair(), ExplicitTemplateArgs, - Args, NumArgs, CandidateSet, + Args, NumArgs, CandidateSet, PartialOverloading); if (ULE->requiresADL()) @@ -7282,7 +7282,7 @@ void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, Args, NumArgs, ExplicitTemplateArgs, CandidateSet, - PartialOverloading); + PartialOverloading); } /// Attempts to recover from a call where no functions were found. @@ -7360,7 +7360,7 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, (F = dyn_cast(*ULE->decls_begin())) && F->getBuiltinID() && F->isImplicit()) assert(0 && "performing ADL for builtin"); - + // We don't perform ADL in C. assert(getLangOptions().CPlusPlus && "ADL enabled in C"); } @@ -7469,11 +7469,11 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, if (Input->isTypeDependent()) { if (Fns.empty()) return Owned(new (Context) UnaryOperator(Input, - Opc, + Opc, Context.DependentTy, VK_RValue, OK_Ordinary, OpLoc)); - + CXXRecordDecl *NamingClass = 0; // because lookup ignores member operators UnresolvedLookupExpr *Fn = UnresolvedLookupExpr::Create(Context, NamingClass, @@ -7529,7 +7529,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, = PerformCopyInitialization(InitializedEntity::InitializeParameter( Context, FnDecl->getParamDecl(0)), - SourceLocation(), + SourceLocation(), Input); if (InputInit.isInvalid()) return ExprError(); @@ -7551,7 +7551,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, new (Context) CXXOperatorCallExpr(Context, Op, FnExpr, Args, NumArgs, ResultTy, VK, OpLoc); - if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall, + if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall, FnDecl)) return ExprError(); @@ -7631,14 +7631,14 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // expression. if (Args[0]->isTypeDependent() || Args[1]->isTypeDependent()) { if (Fns.empty()) { - // If there are no functions to store, just build a dependent + // If there are no functions to store, just build a dependent // BinaryOperator or CompoundAssignment. if (Opc <= BO_Assign || Opc > BO_OrAssign) return Owned(new (Context) BinaryOperator(Args[0], Args[1], Opc, Context.DependentTy, VK_RValue, OK_Ordinary, OpLoc)); - + return Owned(new (Context) CompoundAssignOperator(Args[0], Args[1], Opc, Context.DependentTy, VK_LValue, @@ -7653,7 +7653,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // TODO: provide better source location info in DNLoc component. DeclarationNameInfo OpNameInfo(OpName, OpLoc); UnresolvedLookupExpr *Fn - = UnresolvedLookupExpr::Create(Context, NamingClass, 0, SourceRange(), + = UnresolvedLookupExpr::Create(Context, NamingClass, 0, SourceRange(), OpNameInfo, /*ADL*/ true, IsOverloaded(Fns), Fns.begin(), Fns.end()); return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn, @@ -7752,7 +7752,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, if (Arg1.isInvalid()) return ExprError(); - if (PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/0, + if (PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/0, Best->FoundDecl, Method)) return ExprError(); @@ -7790,8 +7790,8 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, CXXOperatorCallExpr *TheCall = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr, Args, 2, ResultTy, VK, OpLoc); - - if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall, + + if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall, FnDecl)) return ExprError(); @@ -7822,7 +7822,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // operator do not fall through to handling in built-in, but report that // no overloaded assignment operator found ExprResult Result = ExprError(); - if (Args[0]->getType()->isRecordType() && + if (Args[0]->getType()->isRecordType() && Opc >= BO_Assign && Opc <= BO_OrAssign) { Diag(OpLoc, diag::err_ovl_no_viable_oper) << BinaryOperator::getOpcodeStr(Opc) @@ -7832,7 +7832,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // produce an error. Then, show the non-viable candidates. Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]); } - assert(Result.isInvalid() && + assert(Result.isInvalid() && "C++ binary operator overloading is missing candidates!"); if (Result.isInvalid()) CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, 2, @@ -7925,7 +7925,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, // Convert the arguments. CXXMethodDecl *Method = cast(FnDecl); - if (PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/0, + if (PerformObjectArgumentInitialization(Args[0], /*Qualifier=*/0, Best->FoundDecl, Method)) return ExprError(); @@ -7934,7 +7934,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, = PerformCopyInitialization(InitializedEntity::InitializeParameter( Context, FnDecl->getParamDecl(0)), - SourceLocation(), + SourceLocation(), Owned(Args[1])); if (InputInit.isInvalid()) return ExprError(); @@ -7989,7 +7989,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, case OR_Ambiguous: Diag(LLoc, diag::err_ovl_ambiguous_oper_binary) - << "[]" + << "[]" << Args[0]->getType() << Args[1]->getType() << Args[0]->getSourceRange() << Args[1]->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_ViableCandidates, Args, 2, @@ -8023,7 +8023,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, // Dig out the member expression. This holds both the object // argument and the member function we're referring to. Expr *NakedMemExpr = MemExprE->IgnoreParens(); - + MemberExpr *MemExpr; CXXMethodDecl *Method = 0; DeclAccessPair FoundDecl = DeclAccessPair::make(0, AS_public); @@ -8036,7 +8036,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, } else { UnresolvedMemberExpr *UnresExpr = cast(NakedMemExpr); Qualifier = UnresExpr->getQualifier(); - + QualType ObjectType = UnresExpr->getBaseType(); Expr::Classification ObjectClassification = UnresExpr->isArrow()? Expr::Classification::makeSimpleLValue() @@ -8070,15 +8070,15 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, // non-template member function. if (TemplateArgs) continue; - + AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType, - ObjectClassification, - Args, NumArgs, CandidateSet, + ObjectClassification, + Args, NumArgs, CandidateSet, /*SuppressUserConversions=*/false); } else { AddMethodTemplateCandidate(cast(Func), I.getPair(), ActingDC, TemplateArgs, - ObjectType, ObjectClassification, + ObjectType, ObjectClassification, Args, NumArgs, CandidateSet, /*SuppressUsedConversions=*/false); } @@ -8137,15 +8137,15 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, ResultType = ResultType.getNonLValueExprType(Context); assert(Method && "Member call to something that isn't a method?"); - CXXMemberCallExpr *TheCall = + CXXMemberCallExpr *TheCall = new (Context) CXXMemberCallExpr(Context, MemExprE, Args, NumArgs, ResultType, VK, RParenLoc); // Check for a valid return type. - if (CheckCallReturnType(Method->getResultType(), MemExpr->getMemberLoc(), + if (CheckCallReturnType(Method->getResultType(), MemExpr->getMemberLoc(), TheCall, Method)) return ExprError(); - + // Convert the object argument (for a non-static member function call). // We only need to do this if there was actually an overload; otherwise // it was done at lookup. @@ -8194,11 +8194,11 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, OverloadCandidateSet CandidateSet(LParenLoc); DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(OO_Call); - if (RequireCompleteType(LParenLoc, Object->getType(), + if (RequireCompleteType(LParenLoc, Object->getType(), PDiag(diag::err_incomplete_object_call) << Object->getSourceRange())) return true; - + LookupResult R(*this, OpName, LParenLoc, LookupOrdinaryName); LookupQualifiedName(R, Record->getDecl()); R.suppressDiagnostics(); @@ -8209,7 +8209,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, Object->Classify(Context), Args, NumArgs, CandidateSet, /*SuppressUserConversions=*/ false); } - + // C++ [over.call.object]p2: // In addition, for each conversion function declared in T of the // form @@ -8235,7 +8235,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, CXXRecordDecl *ActingContext = cast(D->getDeclContext()); if (isa(D)) D = cast(D)->getTargetDecl(); - + // Skip over templated conversion functions; they aren't // surrogates. if (isa(D)) @@ -8307,13 +8307,13 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, // We selected one of the surrogate functions that converts the // object parameter to a function pointer. Perform the conversion // on the object argument, then let ActOnCallExpr finish the job. - + // Create an implicit member expr to refer to the conversion operator. // and then call it. ExprResult Call = BuildCXXMemberCallExpr(Object, Best->FoundDecl, Conv); if (Call.isInvalid()) return ExprError(); - + return ActOnCallExpr(S, Call.get(), LParenLoc, MultiExprArg(Args, NumArgs), RParenLoc); } @@ -8359,10 +8359,10 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, ResultTy, VK, RParenLoc); delete [] MethodArgs; - if (CheckCallReturnType(Method->getResultType(), LParenLoc, TheCall, + if (CheckCallReturnType(Method->getResultType(), LParenLoc, TheCall, Method)) return true; - + // We may have default arguments. If so, we need to allocate more // slots in the call for them. if (NumArgs < NumArgsInProto) @@ -8373,7 +8373,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, bool IsError = false; // Initialize the implicit object parameter. - IsError |= PerformObjectArgumentInitialization(Object, /*Qualifier=*/0, + IsError |= PerformObjectArgumentInitialization(Object, /*Qualifier=*/0, Best->FoundDecl, Method); TheCall->setArg(0, Object); @@ -8391,7 +8391,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, Context, Method->getParamDecl(i)), SourceLocation(), Arg); - + IsError |= InputInit.isInvalid(); Arg = InputInit.takeAs(); } else { @@ -8401,7 +8401,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, IsError = true; break; } - + Arg = DefArg.takeAs(); } @@ -8507,15 +8507,15 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc) { // Build the operator call. Expr *FnExpr = CreateFunctionRefExpr(*this, Method); - + QualType ResultTy = Method->getResultType(); ExprValueKind VK = Expr::getValueKindForType(ResultTy); ResultTy = ResultTy.getNonLValueExprType(Context); CXXOperatorCallExpr *TheCall = - new (Context) CXXOperatorCallExpr(Context, OO_Arrow, FnExpr, + new (Context) CXXOperatorCallExpr(Context, OO_Arrow, FnExpr, &Base, 1, ResultTy, VK, OpLoc); - if (CheckCallReturnType(Method->getResultType(), OpLoc, TheCall, + if (CheckCallReturnType(Method->getResultType(), OpLoc, TheCall, Method)) return ExprError(); return Owned(TheCall); @@ -8533,26 +8533,26 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, Found, Fn); if (SubExpr == PE->getSubExpr()) return PE; - + return new (Context) ParenExpr(PE->getLParen(), PE->getRParen(), SubExpr); - } - + } + if (ImplicitCastExpr *ICE = dyn_cast(E)) { Expr *SubExpr = FixOverloadedFunctionReference(ICE->getSubExpr(), Found, Fn); - assert(Context.hasSameType(ICE->getSubExpr()->getType(), + assert(Context.hasSameType(ICE->getSubExpr()->getType(), SubExpr->getType()) && "Implicit cast type cannot be determined from overload"); assert(ICE->path_empty() && "fixing up hierarchy conversion?"); if (SubExpr == ICE->getSubExpr()) return ICE; - - return ImplicitCastExpr::Create(Context, ICE->getType(), + + return ImplicitCastExpr::Create(Context, ICE->getType(), ICE->getCastKind(), SubExpr, 0, ICE->getValueKind()); - } - + } + if (UnaryOperator *UnOp = dyn_cast(E)) { assert(UnOp->getOpcode() == UO_AddrOf && "Can only take the address of an overloaded function"); @@ -8591,12 +8591,12 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, Found, Fn); if (SubExpr == UnOp->getSubExpr()) return UnOp; - + return new (Context) UnaryOperator(SubExpr, UO_AddrOf, Context.getPointerType(SubExpr->getType()), VK_RValue, OK_Ordinary, UnOp->getOperatorLoc()); - } + } if (UnresolvedLookupExpr *ULE = dyn_cast(E)) { // FIXME: avoid copy. @@ -8650,10 +8650,10 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, Base = MemExpr->getBase(); return MemberExpr::Create(Context, Base, - MemExpr->isArrow(), - MemExpr->getQualifier(), + MemExpr->isArrow(), + MemExpr->getQualifier(), MemExpr->getQualifierRange(), - Fn, + Fn, Found, MemExpr->getMemberNameInfo(), TemplateArgs, @@ -8662,12 +8662,12 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, ? VK_LValue : VK_RValue, OK_Ordinary); } - + llvm_unreachable("Invalid reference to overloaded function"); return E; } -ExprResult Sema::FixOverloadedFunctionReference(ExprResult E, +ExprResult Sema::FixOverloadedFunctionReference(ExprResult E, DeclAccessPair Found, FunctionDecl *Fn) { return Owned(FixOverloadedFunctionReference((Expr *)E.get(), Found, Fn)); diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index f4fe6479ab..e5fd01ab70 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -61,7 +61,7 @@ StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, void Sema::ActOnForEachDeclStmt(DeclGroupPtrTy dg) { DeclGroupRef DG = dg.getAsVal(); - + // If we have an invalid decl, just return. if (DG.isNull() || !DG.isSingleDecl()) return; // suppress any potential 'unused variable' warning. @@ -114,7 +114,7 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) { Diag(Loc, diag::warn_unused_call) << R1 << R2 << "const"; return; } - } + } } else if (const ObjCMessageExpr *ME = dyn_cast(E)) { const ObjCMethodDecl *MD = ME->getMethodDecl(); if (MD && MD->getAttr()) { @@ -296,7 +296,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar, Expr *ConditionExpr = CondResult.takeAs(); if (!ConditionExpr) return StmtError(); - + DiagnoseUnusedExprResult(thenStmt); // Warn if the if block has a null body without an else value. @@ -318,7 +318,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar, DiagnoseUnusedExprResult(elseStmt); - return Owned(new (Context) IfStmt(Context, IfLoc, ConditionVar, ConditionExpr, + return Owned(new (Context) IfStmt(Context, IfLoc, ConditionVar, ConditionExpr, thenStmt, ElseLoc, elseStmt)); } @@ -356,7 +356,7 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val, } else if (NewSign != Val.isSigned()) { // Convert the sign to match the sign of the condition. This can cause // overflow as well: unsigned(INTMIN) - // We don't diagnose this overflow, because it is implementation-defined + // We don't diagnose this overflow, because it is implementation-defined // behavior. // FIXME: Introduce a second, default-ignored warning for this case? llvm::APSInt OldVal(Val); @@ -425,7 +425,7 @@ static QualType GetTypeBeforeIntegralPromotion(const Expr* expr) { } StmtResult -Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, +Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, Decl *CondVar) { ExprResult CondResult; @@ -435,15 +435,15 @@ Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, CondResult = CheckConditionVariable(ConditionVar, SourceLocation(), false); if (CondResult.isInvalid()) return StmtError(); - + Cond = CondResult.release(); } - + if (!Cond) return StmtError(); - + CondResult - = ConvertToIntegralOrEnumerationType(SwitchLoc, Cond, + = ConvertToIntegralOrEnumerationType(SwitchLoc, Cond, PDiag(diag::err_typecheck_statement_requires_integer), PDiag(diag::err_switch_incomplete_class_type) << Cond->getSourceRange(), @@ -454,7 +454,7 @@ Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, PDiag(0)); if (CondResult.isInvalid()) return StmtError(); Cond = CondResult.take(); - + if (!CondVar) { CheckImplicitConversions(Cond, SwitchLoc); CondResult = MaybeCreateExprWithCleanups(Cond); @@ -464,7 +464,7 @@ Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, } getCurFunction()->setHasBranchIntoScope(); - + SwitchStmt *SS = new (Context) SwitchStmt(Context, ConditionVar, Cond); getCurFunction()->SwitchStack.push_back(SS); return Owned(SS); @@ -490,7 +490,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, if (SS->getCond() == 0) return StmtError(); - + Expr *CondExpr = SS->getCond(); Expr *CondExprBeforePromotion = CondExpr; QualType CondTypeBeforePromotion = @@ -510,7 +510,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, // the pre-promotion type of the switch condition. if (!CondExpr->isTypeDependent()) { // We have already converted the expression to an integral or enumeration - // type, when we started the switch statement. If we don't have an + // type, when we started the switch statement. If we don't have an // appropriate type now, just return an error. if (!CondType->isIntegralOrEnumerationType()) return StmtError(); @@ -787,7 +787,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, RI != CaseRanges.end() && EI != EIend; RI++) { while (EI != EIend && EI->first < RI->first) EI++; - + if (EI == EIend || EI->first != RI->first) { Diag(RI->second->getLHS()->getExprLoc(), diag::warn_not_in_enum) << ED->getDeclName(); @@ -802,20 +802,20 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, << ED->getDeclName(); } } - + // Check which enum vals aren't in switch CaseValsTy::const_iterator CI = CaseVals.begin(); CaseRangesTy::const_iterator RI = CaseRanges.begin(); bool hasCasesNotInSwitch = false; llvm::SmallVector UnhandledNames; - + for (EnumValsTy::const_iterator EI = EnumVals.begin(); EI != EIend; EI++){ // Drop unneeded case values llvm::APSInt CIVal; while (CI != CaseVals.end() && CI->first < EI->first) CI++; - + if (CI != CaseVals.end() && CI->first == EI->first) continue; @@ -833,7 +833,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, UnhandledNames.push_back(EI->second->getDeclName()); } } - + // Produce a nice diagnostic if multiple values aren't handled. switch (UnhandledNames.size()) { case 0: break; @@ -870,10 +870,10 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, } StmtResult -Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond, +Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond, Decl *CondVar, Stmt *Body) { ExprResult CondResult(Cond.release()); - + VarDecl *ConditionVar = 0; if (CondVar) { ConditionVar = cast(CondVar); @@ -884,7 +884,7 @@ Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond, Expr *ConditionExpr = CondResult.take(); if (!ConditionExpr) return StmtError(); - + DiagnoseUnusedExprResult(Body); return Owned(new (Context) WhileStmt(Context, ConditionVar, ConditionExpr, @@ -905,7 +905,7 @@ Sema::ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, if (CondResult.isInvalid()) return StmtError(); Cond = CondResult.take(); - + DiagnoseUnusedExprResult(Body); return Owned(new (Context) DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen)); @@ -941,16 +941,16 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, if (SecondResult.isInvalid()) return StmtError(); } - + Expr *Third = third.release().takeAs(); - + DiagnoseUnusedExprResult(First); DiagnoseUnusedExprResult(Third); DiagnoseUnusedExprResult(Body); - return Owned(new (Context) ForStmt(Context, First, - SecondResult.take(), ConditionVar, - Third, Body, ForLoc, LParenLoc, + return Owned(new (Context) ForStmt(Context, First, + SecondResult.take(), ConditionVar, + Third, Body, ForLoc, LParenLoc, RParenLoc)); } @@ -1010,7 +1010,7 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc, else if (const ObjCObjectPointerType *OPT = SecondType->getAsObjCInterfacePointerType()) { llvm::SmallVector KeyIdents; - IdentifierInfo* selIdent = + IdentifierInfo* selIdent = &Context.Idents.get("countByEnumeratingWithState"); KeyIdents.push_back(selIdent); selIdent = &Context.Idents.get("objects"); @@ -1019,7 +1019,7 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc, KeyIdents.push_back(selIdent); Selector CSelector = Context.Selectors.getSelector(3, &KeyIdents[0]); if (ObjCInterfaceDecl *IDecl = OPT->getInterfaceDecl()) { - if (!IDecl->isForwardDecl() && + if (!IDecl->isForwardDecl() && !IDecl->lookupInstanceMethod(CSelector)) { // Must further look into private implementation methods. if (!LookupPrivateInstanceMethod(CSelector, IDecl)) @@ -1089,7 +1089,7 @@ Sema::ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope) { return Owned(new (Context) BreakStmt(BreakLoc)); } -/// \brief Determine whether the given expression is a candidate for +/// \brief Determine whether the given expression is a candidate for /// copy elision in either a return statement or a throw expression. /// /// \param ReturnType If we're determining the copy elision candidate for @@ -1117,8 +1117,8 @@ const VarDecl *Sema::getCopyElisionCandidate(QualType ReturnType, if (!Context.hasSameUnqualifiedType(ReturnType, ExprType)) return 0; } - - // ... the expression is the name of a non-volatile automatic object + + // ... the expression is the name of a non-volatile automatic object // (other than a function or catch-clause parameter)) ... const DeclRefExpr *DR = dyn_cast(E->IgnoreParens()); if (!DR) @@ -1126,14 +1126,14 @@ const VarDecl *Sema::getCopyElisionCandidate(QualType ReturnType, const VarDecl *VD = dyn_cast(DR->getDecl()); if (!VD) return 0; - + if (VD->hasLocalStorage() && !VD->isExceptionVariable() && !VD->getType()->isReferenceType() && !VD->hasAttr() && !VD->getType().isVolatileQualified() && ((VD->getKind() == Decl::Var) || (AllowFunctionParameter && VD->getKind() == Decl::ParmVar))) return VD; - + return 0; } @@ -1143,30 +1143,30 @@ const VarDecl *Sema::getCopyElisionCandidate(QualType ReturnType, /// This routine implements C++0x [class.copy]p33, which attempts to treat /// returned lvalues as rvalues in certain cases (to prefer move construction), /// then falls back to treating them as lvalues if that failed. -ExprResult +ExprResult Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity, const VarDecl *NRVOCandidate, QualType ResultType, Expr *Value) { // C++0x [class.copy]p33: - // When the criteria for elision of a copy operation are met or would - // be met save for the fact that the source object is a function - // parameter, and the object to be copied is designated by an lvalue, + // When the criteria for elision of a copy operation are met or would + // be met save for the fact that the source object is a function + // parameter, and the object to be copied is designated by an lvalue, // overload resolution to select the constructor for the copy is first // performed as if the object were designated by an rvalue. ExprResult Res = ExprError(); if (NRVOCandidate || getCopyElisionCandidate(ResultType, Value, true)) { - ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack, + ImplicitCastExpr AsRvalue(ImplicitCastExpr::OnStack, Value->getType(), CK_LValueToRValue, Value, VK_XValue); - + Expr *InitExpr = &AsRvalue; - InitializationKind Kind + InitializationKind Kind = InitializationKind::CreateCopy(Value->getLocStart(), Value->getLocStart()); InitializationSequence Seq(*this, Entity, Kind, &InitExpr, 1); - - // [...] If overload resolution fails, or if the type of the first + + // [...] If overload resolution fails, or if the type of the first // parameter of the selected constructor is not an rvalue reference // to the object's type (possibly cv-qualified), overload resolution // is performed again, considering the object as an lvalue. @@ -1174,42 +1174,42 @@ Sema::PerformMoveOrCopyInitialization(const InitializedEntity &Entity, for (InitializationSequence::step_iterator Step = Seq.step_begin(), StepEnd = Seq.step_end(); Step != StepEnd; ++Step) { - if (Step->Kind + if (Step->Kind != InitializationSequence::SK_ConstructorInitialization) continue; - - CXXConstructorDecl *Constructor + + CXXConstructorDecl *Constructor = cast(Step->Function.Function); - + const RValueReferenceType *RRefType = Constructor->getParamDecl(0)->getType() ->getAs(); - + // If we don't meet the criteria, break out now. - if (!RRefType || + if (!RRefType || !Context.hasSameUnqualifiedType(RRefType->getPointeeType(), Context.getTypeDeclType(Constructor->getParent()))) break; - + // Promote "AsRvalue" to the heap, since we now need this // expression node to persist. Value = ImplicitCastExpr::Create(Context, Value->getType(), - CK_LValueToRValue, Value, 0, + CK_LValueToRValue, Value, 0, VK_XValue); - + // Complete type-checking the initialization of the return type // using the constructor we found. Res = Seq.Perform(*this, Entity, Kind, MultiExprArg(&Value, 1)); } } } - + // Either we didn't meet the criteria for treating an lvalue as an rvalue, - // above, or overload resolution failed. Either way, we need to try + // above, or overload resolution failed. Either way, we need to try // (again) now with the return value expression as written. if (Res.isInvalid()) Res = PerformCopyInitialization(Entity, SourceLocation(), Value); - + return Res; } @@ -1258,7 +1258,7 @@ Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { return StmtError(Diag(ReturnLoc, diag::err_block_return_missing_expr)); } else { const VarDecl *NRVOCandidate = 0; - + if (!FnRetType->isDependentType() && !RetValExp->isTypeDependent()) { // we have a non-void block with an expression, continue checking @@ -1269,35 +1269,35 @@ Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { // In C++ the return statement is handled via a copy initialization. // the C version of which boils down to CheckSingleAssignmentConstraints. NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp, false); - InitializedEntity Entity = InitializedEntity::InitializeResult(ReturnLoc, + InitializedEntity Entity = InitializedEntity::InitializeResult(ReturnLoc, FnRetType, NRVOCandidate != 0); - ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate, + ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate, FnRetType, RetValExp); if (Res.isInvalid()) { // FIXME: Cleanup temporaries here, anyway? return StmtError(); } - + if (RetValExp) { CheckImplicitConversions(RetValExp, ReturnLoc); RetValExp = MaybeCreateExprWithCleanups(RetValExp); } RetValExp = Res.takeAs(); - if (RetValExp) + if (RetValExp) CheckReturnStackAddr(RetValExp, FnRetType, ReturnLoc); } - + Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, NRVOCandidate); } - // If we need to check for the named return value optimization, save the + // If we need to check for the named return value optimization, save the // return statement in our scope for later processing. if (getLangOptions().CPlusPlus && FnRetType->isRecordType() && !CurContext->isDependentContext()) FunctionScopes.back()->Returns.push_back(Result); - + return Owned(Result); } @@ -1342,7 +1342,7 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { CheckImplicitConversions(RetValExp, ReturnLoc); RetValExp = MaybeCreateExprWithCleanups(RetValExp); } - + Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, 0); } else if (!RetValExp && !FnRetType->isDependentType()) { unsigned DiagID = diag::warn_return_missing_expr; // C90 6.6.6.4p4 @@ -1366,10 +1366,10 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { // In C++ the return statement is handled via a copy initialization. // the C version of which boils down to CheckSingleAssignmentConstraints. NRVOCandidate = getCopyElisionCandidate(FnRetType, RetValExp, false); - InitializedEntity Entity = InitializedEntity::InitializeResult(ReturnLoc, + InitializedEntity Entity = InitializedEntity::InitializeResult(ReturnLoc, FnRetType, NRVOCandidate != 0); - ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate, + ExprResult Res = PerformMoveOrCopyInitialization(Entity, NRVOCandidate, FnRetType, RetValExp); if (Res.isInvalid()) { // FIXME: Cleanup temporaries here, anyway? @@ -1377,23 +1377,23 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { } RetValExp = Res.takeAs(); - if (RetValExp) + if (RetValExp) CheckReturnStackAddr(RetValExp, FnRetType, ReturnLoc); } - + if (RetValExp) { CheckImplicitConversions(RetValExp, ReturnLoc); RetValExp = MaybeCreateExprWithCleanups(RetValExp); } Result = new (Context) ReturnStmt(ReturnLoc, RetValExp, NRVOCandidate); } - - // If we need to check for the named return value optimization, save the + + // If we need to check for the named return value optimization, save the // return statement in our scope for later processing. if (getLangOptions().CPlusPlus && FnRetType->isRecordType() && !CurContext->isDependentContext()) FunctionScopes.back()->Returns.push_back(Result); - + return Owned(Result); } @@ -1408,7 +1408,7 @@ static bool CheckAsmLValue(const Expr *E, Sema &S) { // Type dependent expressions will be checked during instantiation. if (E->isTypeDependent()) return false; - + if (E->isLValue()) return false; // Cool, this is an lvalue. @@ -1544,8 +1544,8 @@ StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, } AsmStmt *NS = - new (Context) AsmStmt(Context, AsmLoc, IsSimple, IsVolatile, MSAsm, - NumOutputs, NumInputs, Names, Constraints, Exprs, + new (Context) AsmStmt(Context, AsmLoc, IsSimple, IsVolatile, MSAsm, + NumOutputs, NumInputs, Names, Constraints, Exprs, AsmString, NumClobbers, Clobbers, RParenLoc); // Validate the asm string, ensuring it makes sense given the operands we // have. @@ -1579,7 +1579,7 @@ StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, enum AsmDomain { AD_Int, AD_FP, AD_Other } InputDomain, OutputDomain; - + if (InTy->isIntegerType() || InTy->isPointerType()) InputDomain = AD_Int; else if (InTy->isRealFloatingType()) @@ -1593,19 +1593,19 @@ StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, OutputDomain = AD_FP; else OutputDomain = AD_Other; - + // They are ok if they are the same size and in the same domain. This // allows tying things like: // void* to int* // void* to int if they are the same size. // double to long double if they are the same size. - // + // uint64_t OutSize = Context.getTypeSize(OutTy); uint64_t InSize = Context.getTypeSize(InTy); if (OutSize == InSize && InputDomain == OutputDomain && InputDomain != AD_Other) continue; - + // If the smaller input/output operand is not mentioned in the asm string, // then we can promote it and the asm string won't notice. Check this // case now. @@ -1657,7 +1657,7 @@ Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc, VarDecl *Var = cast_or_null(Parm); if (Var && Var->isInvalidDecl()) return StmtError(); - + return Owned(new (Context) ObjCAtCatchStmt(AtLoc, RParen, Var, Body)); } @@ -1667,7 +1667,7 @@ Sema::ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body) { } StmtResult -Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, +Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg CatchStmts, Stmt *Finally) { getCurFunction()->setHasBranchProtectedScope(); unsigned NumCatchStmts = CatchStmts.size(); @@ -1692,12 +1692,12 @@ StmtResult Sema::BuildObjCAtThrowStmt(SourceLocation AtLoc, << Throw->getType() << Throw->getSourceRange()); } } - + return Owned(new (Context) ObjCAtThrowStmt(AtLoc, Throw)); } StmtResult -Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, +Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope) { if (!Throw) { // @throw without an expression designates a rethrow (which much occur @@ -1707,8 +1707,8 @@ Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, AtCatchParent = AtCatchParent->getParent(); if (!AtCatchParent) return StmtError(Diag(AtLoc, diag::error_rethrow_used_outside_catch)); - } - + } + return BuildObjCAtThrowStmt(AtLoc, Throw); } diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 133b29bad0..00f490cfad 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -88,12 +88,12 @@ static void FilterAcceptableTemplateNames(ASTContext &C, LookupResult &R) { else if (Repl != Orig) { // C++ [temp.local]p3: - // A lookup that finds an injected-class-name (10.2) can result in an + // A lookup that finds an injected-class-name (10.2) can result in an // ambiguity in certain cases (for example, if it is found in more than - // one base class). If all of the injected-class-names that are found - // refer to specializations of the same class template, and if the name - // is followed by a template-argument-list, the reference refers to the - // class template itself and not a specialization thereof, and is not + // one base class). If all of the injected-class-names that are found + // refer to specializations of the same class template, and if the name + // is followed by a template-argument-list, the reference refers to the + // class template itself and not a specialization thereof, and is not // ambiguous. // // FIXME: Will we eventually have to do the same for alias templates? @@ -126,12 +126,12 @@ TemplateNameKind Sema::isTemplateName(Scope *S, DeclarationName TName; MemberOfUnknownSpecialization = false; - + switch (Name.getKind()) { case UnqualifiedId::IK_Identifier: TName = DeclarationName(Name.Identifier); break; - + case UnqualifiedId::IK_OperatorFunctionId: TName = Context.DeclarationNames.getCXXOperatorName( Name.OperatorFunctionId.Operator); @@ -147,7 +147,7 @@ TemplateNameKind Sema::isTemplateName(Scope *S, QualType ObjectType = ObjectTypePtr.get(); - LookupResult R(*this, TName, Name.getSourceRange().getBegin(), + LookupResult R(*this, TName, Name.getSourceRange().getBegin(), LookupOrdinaryName); LookupTemplateName(R, S, SS, ObjectType, EnteringContext, MemberOfUnknownSpecialization); @@ -200,7 +200,7 @@ TemplateNameKind Sema::isTemplateName(Scope *S, return TemplateKind; } -bool Sema::DiagnoseUnknownTemplateName(const IdentifierInfo &II, +bool Sema::DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, @@ -212,14 +212,14 @@ bool Sema::DiagnoseUnknownTemplateName(const IdentifierInfo &II, if (!SS || !SS->isSet() || !isDependentScopeSpecifier(*SS) || computeDeclContext(*SS)) return false; - + // The code is missing a 'template' keyword prior to the dependent template // name. NestedNameSpecifier *Qualifier = (NestedNameSpecifier*)SS->getScopeRep(); Diag(IILoc, diag::err_template_kw_missing) << Qualifier << II.getName() << FixItHint::CreateInsertion(IILoc, "template "); - SuggestedTemplate + SuggestedTemplate = TemplateTy::make(Context.getDependentTemplateName(Qualifier, &II)); SuggestedKind = TNK_Dependent_template_name; return true; @@ -240,14 +240,14 @@ void Sema::LookupTemplateName(LookupResult &Found, assert(!SS.isSet() && "ObjectType and scope specifier cannot coexist"); LookupCtx = computeDeclContext(ObjectType); isDependent = ObjectType->isDependentType(); - assert((isDependent || !ObjectType->isIncompleteType()) && + assert((isDependent || !ObjectType->isIncompleteType()) && "Caller should have completed object type"); } else if (SS.isSet()) { // This nested-name-specifier occurs after another nested-name-specifier, // so long into the context associated with the prior nested-name-specifier. LookupCtx = computeDeclContext(SS, EnteringContext); isDependent = isDependentScopeSpecifier(SS); - + // The declaration context must be complete. if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx)) return; @@ -287,7 +287,7 @@ void Sema::LookupTemplateName(LookupResult &Found, if (Found.empty() && !isDependent) { // If we did not find any names, attempt to correct any typos. DeclarationName Name = Found.getLookupName(); - if (DeclarationName Corrected = CorrectTypo(Found, S, &SS, LookupCtx, + if (DeclarationName Corrected = CorrectTypo(Found, S, &SS, LookupCtx, false, CTC_CXXCasts)) { FilterAcceptableTemplateNames(Context, Found); if (!Found.empty()) { @@ -328,7 +328,7 @@ void Sema::LookupTemplateName(LookupResult &Found, LookupOrdinaryName); LookupName(FoundOuter, S); FilterAcceptableTemplateNames(Context, FoundOuter); - + if (FoundOuter.empty()) { // - if the name is not found, the name found in the class of the // object expression is used, otherwise @@ -343,7 +343,7 @@ void Sema::LookupTemplateName(LookupResult &Found, if (!Found.isSingleResult() || Found.getFoundDecl()->getCanonicalDecl() != FoundOuter.getFoundDecl()->getCanonicalDecl()) { - Diag(Found.getNameLoc(), + Diag(Found.getNameLoc(), diag::ext_nested_name_member_ref_lookup_ambiguous) << Found.getLookupName() << ObjectType; @@ -372,12 +372,12 @@ Sema::ActOnDependentIdExpression(const CXXScopeSpec &SS, = static_cast(SS.getScopeRep()); DeclContext *DC = getFunctionLevelDeclContext(); - + if (!isAddressOfOperand && isa(DC) && cast(DC)->isInstance()) { QualType ThisType = cast(DC)->getThisType(Context); - + // Since the 'this' expression is synthesized, we don't need to // perform the double-lookup check. NamedDecl *FirstQualifierInScope = 0; @@ -439,7 +439,7 @@ TemplateDecl *Sema::AdjustDeclIfTemplate(Decl *&D) { ParsedTemplateArgument ParsedTemplateArgument::getTemplatePackExpansion( SourceLocation EllipsisLoc) const { - assert(Kind == Template && + assert(Kind == Template && "Only template template arguments can be pack expansions here"); assert(getAsTemplate().get().containsUnexpandedParameterPack() && "Template template argument pack expansion without packs"); @@ -450,21 +450,21 @@ ParsedTemplateArgument ParsedTemplateArgument::getTemplatePackExpansion( static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg) { - + switch (Arg.getKind()) { case ParsedTemplateArgument::Type: { TypeSourceInfo *DI; QualType T = SemaRef.GetTypeFromParser(Arg.getAsType(), &DI); - if (!DI) + if (!DI) DI = SemaRef.Context.getTrivialTypeSourceInfo(T, Arg.getLocation()); return TemplateArgumentLoc(TemplateArgument(T), DI); } - + case ParsedTemplateArgument::NonType: { Expr *E = static_cast(Arg.getAsExpr()); return TemplateArgumentLoc(TemplateArgument(E), E); } - + case ParsedTemplateArgument::Template: { TemplateName Template = Arg.getAsTemplate().get(); TemplateArgument TArg; @@ -478,11 +478,11 @@ static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef, Arg.getEllipsisLoc()); } } - + llvm_unreachable("Unhandled parsed template argument"); return TemplateArgumentLoc(); } - + /// \brief Translates template arguments as provided by the parser /// into template arguments used by semantic analysis. void Sema::translateTemplateArguments(const ASTTemplateArgsPtr &TemplateArgsIn, @@ -491,7 +491,7 @@ void Sema::translateTemplateArguments(const ASTTemplateArgsPtr &TemplateArgsIn, TemplateArgs.addArgument(translateTemplateArgument(*this, TemplateArgsIn[I])); } - + /// ActOnTypeParameter - Called when a C++ template type parameter /// (e.g., "typename T") has been parsed. Typename specifies whether /// the keyword "typename" was used to declare the type parameter @@ -551,23 +551,23 @@ Decl *Sema::ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis, if (DefaultArg) { TypeSourceInfo *DefaultTInfo; GetTypeFromParser(DefaultArg, &DefaultTInfo); - + assert(DefaultTInfo && "expected source information for type"); - + // Check for unexpanded parameter packs. - if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo, + if (DiagnoseUnexpandedParameterPack(Loc, DefaultTInfo, UPPC_DefaultArgument)) return Param; - + // Check the template argument itself. if (CheckTemplateArgument(Param, DefaultTInfo)) { Param->setInvalidDecl(); return Param; } - + Param->setDefaultArgument(DefaultTInfo, false); } - + return Param; } @@ -614,7 +614,7 @@ Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) { else if (T->isFunctionType()) // FIXME: Keep the type prior to promotion? return Context.getPointerType(T); - + Diag(Loc, diag::err_template_nontype_parm_bad_type) << T; @@ -648,12 +648,12 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, T = Context.IntTy; // Recover with an 'int' type. Invalid = true; } - + bool IsParameterPack = D.hasEllipsis(); NonTypeTemplateParmDecl *Param = NonTypeTemplateParmDecl::Create(Context, Context.getTranslationUnitDecl(), D.getIdentifierLoc(), - Depth, Position, ParamName, T, + Depth, Position, ParamName, T, IsParameterPack, TInfo); if (Invalid) Param->setInvalidDecl(); @@ -663,7 +663,7 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, S->AddDecl(Param); IdResolver.AddDecl(Param); } - + // C++0x [temp.param]p9: // A default template-argument may be specified for any kind of // template-parameter that is not a template parameter pack. @@ -683,10 +683,10 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, Param->setInvalidDecl(); return Param; } - + Param->setDefaultArgument(Default, false); } - + return Param; } @@ -711,11 +711,11 @@ Decl *Sema::ActOnTemplateTemplateParameter(Scope* S, // FIXME: Pack-ness is dropped TemplateTemplateParmDecl *Param = TemplateTemplateParmDecl::Create(Context, Context.getTranslationUnitDecl(), - NameLoc.isInvalid()? TmpLoc : NameLoc, - Depth, Position, IsParameterPack, + NameLoc.isInvalid()? TmpLoc : NameLoc, + Depth, Position, IsParameterPack, Name, Params); - // If the template template parameter has a name, then link the identifier + // If the template template parameter has a name, then link the identifier // into the scope and lookup mechanisms. if (Name) { S->AddDecl(Param); @@ -735,7 +735,7 @@ Decl *Sema::ActOnTemplateTemplateParameter(Scope* S, Diag(EqualLoc, diag::err_template_param_pack_default_arg); Default = ParsedTemplateArgument(); } - + if (!Default.isInvalid()) { // Check only that we have a template template argument. We don't want to // try to check well-formedness now, because our template template parameter @@ -751,16 +751,16 @@ Decl *Sema::ActOnTemplateTemplateParameter(Scope* S, << DefaultArg.getSourceRange(); return Param; } - + // Check for unexpanded parameter packs. - if (DiagnoseUnexpandedParameterPack(DefaultArg.getLocation(), + if (DiagnoseUnexpandedParameterPack(DefaultArg.getLocation(), DefaultArg.getArgument().getAsTemplate(), UPPC_DefaultArgument)) return Param; - + Param->setDefaultArgument(DefaultArg, false); } - + return Param; } @@ -777,7 +777,7 @@ Sema::ActOnTemplateParameterList(unsigned Depth, Diag(ExportLoc, diag::warn_template_export_unsupported); return TemplateParameterList::Create(Context, TemplateLoc, LAngleLoc, - (NamedDecl**)Params, NumParams, + (NamedDecl**)Params, NumParams, RAngleLoc); } @@ -834,7 +834,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, if (Previous.isAmbiguous()) return true; - + NamedDecl *PrevDecl = 0; if (Previous.begin() != Previous.end()) PrevDecl = (*Previous.begin())->getUnderlyingDecl(); @@ -845,12 +845,12 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, = dyn_cast_or_null(PrevDecl); // We may have found the injected-class-name of a class template, - // class template partial specialization, or class template specialization. + // class template partial specialization, or class template specialization. // In these cases, grab the template that is being defined or specialized. - if (!PrevClassTemplate && PrevDecl && isa(PrevDecl) && + if (!PrevClassTemplate && PrevDecl && isa(PrevDecl) && cast(PrevDecl)->isInjectedClassName()) { PrevDecl = cast(PrevDecl->getDeclContext()); - PrevClassTemplate + PrevClassTemplate = cast(PrevDecl)->getDescribedClassTemplate(); if (!PrevClassTemplate && isa(PrevDecl)) { PrevClassTemplate @@ -861,8 +861,8 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, if (TUK == TUK_Friend) { // C++ [namespace.memdef]p3: - // [...] When looking for a prior declaration of a class or a function - // declared as a friend, and when the name of the friend class or + // [...] When looking for a prior declaration of a class or a function + // declared as a friend, and when the name of the friend class or // function is neither a qualified name nor a template-id, scopes outside // the innermost enclosing namespace scope are not considered. if (!SS.isSet()) { @@ -876,7 +876,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SemanticContext = PrevDecl->getDeclContext(); } else { // Declarations in outer scopes don't matter. However, the outermost - // context we computed is the semantic context for our new + // context we computed is the semantic context for our new // declaration. PrevDecl = PrevClassTemplate = 0; SemanticContext = OutermostContext; @@ -892,7 +892,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, } } else if (PrevDecl && !isDeclInScope(PrevDecl, SemanticContext, S)) PrevDecl = PrevClassTemplate = 0; - + if (PrevClassTemplate) { // Ensure that the template parameter lists are compatible. if (!TemplateParameterListsAreEqual(TemplateParams, @@ -950,14 +950,14 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, Invalid = true; if (SS.isSet()) { - // If the name of the template was qualified, we must be defining the + // If the name of the template was qualified, we must be defining the // template out-of-line. if (!SS.isInvalid() && !Invalid && !PrevClassTemplate && !(TUK == TUK_Friend && CurContext->isDependentContext())) Diag(NameLoc, diag::err_member_def_does_not_match) << Name << SemanticContext << SS.getRange(); - } - + } + CXXRecordDecl *NewClass = CXXRecordDecl::Create(Context, Kind, SemanticContext, NameLoc, Name, KWLoc, PrevClassTemplate? @@ -977,12 +977,12 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, assert(T->isDependentType() && "Class template type is not dependent?"); (void)T; - // If we are providing an explicit specialization of a member that is a + // If we are providing an explicit specialization of a member that is a // class template, make a note of that. - if (PrevClassTemplate && + if (PrevClassTemplate && PrevClassTemplate->getInstantiatedFromMemberTemplate()) PrevClassTemplate->setMemberSpecialization(); - + // Set the access specifier. if (!Invalid && TUK != TUK_Friend) SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS); @@ -1007,16 +1007,16 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, NewTemplate->setObjectOfFriendDecl(/* PreviouslyDeclared = */ PrevClassTemplate != NULL); - + // Friend templates are visible in fairly strange ways. if (!CurContext->isDependentContext()) { DeclContext *DC = SemanticContext->getRedeclContext(); DC->makeDeclVisibleInContext(NewTemplate, /* Recoverable = */ false); if (Scope *EnclosingScope = getScopeForDeclContext(S, DC)) PushOnScopeChains(NewTemplate, EnclosingScope, - /* AddToContext = */ false); + /* AddToContext = */ false); } - + FriendDecl *Friend = FriendDecl::Create(Context, CurContext, NewClass->getLocation(), NewTemplate, @@ -1036,7 +1036,7 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, /// template parameter, which is ill-formed in certain contexts. /// /// \returns true if the default template argument should be dropped. -static bool DiagnoseDefaultTemplateArgument(Sema &S, +static bool DiagnoseDefaultTemplateArgument(Sema &S, Sema::TemplateParamListContext TPC, SourceLocation ParamLoc, SourceRange DefArgRange) { @@ -1045,13 +1045,13 @@ static bool DiagnoseDefaultTemplateArgument(Sema &S, return false; case Sema::TPC_FunctionTemplate: - // C++ [temp.param]p9: + // C++ [temp.param]p9: // A default template-argument shall not be specified in a // function template declaration or a function template // definition [...] // (This sentence is not in C++0x, per DR226). if (!S.getLangOptions().CPlusPlus0x) - S.Diag(ParamLoc, + S.Diag(ParamLoc, diag::err_template_parameter_default_in_function_template) << DefArgRange; return false; @@ -1088,20 +1088,20 @@ bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP){ for (unsigned I = 0, N = Params->size(); I != N; ++I) { NamedDecl *P = Params->getParam(I); if (NonTypeTemplateParmDecl *NTTP = dyn_cast(P)) { - if (S.DiagnoseUnexpandedParameterPack(NTTP->getLocation(), + if (S.DiagnoseUnexpandedParameterPack(NTTP->getLocation(), NTTP->getTypeSourceInfo(), Sema::UPPC_NonTypeTemplateParameterType)) return true; - + continue; } - - if (TemplateTemplateParmDecl *InnerTTP + + if (TemplateTemplateParmDecl *InnerTTP = dyn_cast(P)) if (DiagnoseUnexpandedParameterPacks(S, InnerTTP)) return true; } - + return false; } @@ -1162,7 +1162,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, bool MissingDefaultArg = false; // C++0x [temp.param]p11: - // If a template parameter of a primary class template is a template + // If a template parameter of a primary class template is a template // parameter pack, it shall be the last template parameter. if (SawParameterPack && TPC == TPC_ClassTemplate) { Diag(ParameterPackLoc, @@ -1173,9 +1173,9 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, if (TemplateTypeParmDecl *NewTypeParm = dyn_cast(*NewParam)) { // Check the presence of a default argument here. - if (NewTypeParm->hasDefaultArgument() && - DiagnoseDefaultTemplateArgument(*this, TPC, - NewTypeParm->getLocation(), + if (NewTypeParm->hasDefaultArgument() && + DiagnoseDefaultTemplateArgument(*this, TPC, + NewTypeParm->getLocation(), NewTypeParm->getDefaultArgumentInfo()->getTypeLoc() .getSourceRange())) NewTypeParm->removeDefaultArgument(); @@ -1212,16 +1212,16 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, = dyn_cast(*NewParam)) { // Check for unexpanded parameter packs. if (DiagnoseUnexpandedParameterPack(NewNonTypeParm->getLocation(), - NewNonTypeParm->getTypeSourceInfo(), + NewNonTypeParm->getTypeSourceInfo(), UPPC_NonTypeTemplateParameterType)) { Invalid = true; continue; } // Check the presence of a default argument here. - if (NewNonTypeParm->hasDefaultArgument() && - DiagnoseDefaultTemplateArgument(*this, TPC, - NewNonTypeParm->getLocation(), + if (NewNonTypeParm->hasDefaultArgument() && + DiagnoseDefaultTemplateArgument(*this, TPC, + NewNonTypeParm->getLocation(), NewNonTypeParm->getDefaultArgument()->getSourceRange())) { NewNonTypeParm->removeDefaultArgument(); } @@ -1261,16 +1261,16 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, // Check the presence of a default argument here. TemplateTemplateParmDecl *NewTemplateParm = cast(*NewParam); - + // Check for unexpanded parameter packs, recursively. if (DiagnoseUnexpandedParameterPacks(*this, NewTemplateParm)) { Invalid = true; continue; } - - if (NewTemplateParm->hasDefaultArgument() && - DiagnoseDefaultTemplateArgument(*this, TPC, - NewTemplateParm->getLocation(), + + if (NewTemplateParm->hasDefaultArgument() && + DiagnoseDefaultTemplateArgument(*this, TPC, + NewTemplateParm->getLocation(), NewTemplateParm->getDefaultArgument().getSourceRange())) NewTemplateParm->removeDefaultArgument(); @@ -1317,8 +1317,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, Invalid = true; } else if (MissingDefaultArg) { // C++ [temp.param]p11: - // If a template-parameter of a class template has a default - // template-argument, each subsequent template-parameter shall either + // If a template-parameter of a class template has a default + // template-argument, each subsequent template-parameter shall either // have a default template-argument supplied or be a template parameter // pack. Diag((*NewParam)->getLocation(), @@ -1342,14 +1342,14 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, NewParam != NewParamEnd; ++NewParam) { if (TemplateTypeParmDecl *TTP = dyn_cast(*NewParam)) TTP->removeDefaultArgument(); - else if (NonTypeTemplateParmDecl *NTTP + else if (NonTypeTemplateParmDecl *NTTP = dyn_cast(*NewParam)) NTTP->removeDefaultArgument(); else cast(*NewParam)->removeDefaultArgument(); } } - + return Invalid; } @@ -1455,7 +1455,7 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, bool &IsExplicitSpecialization, bool &Invalid) { IsExplicitSpecialization = false; - + // Find the template-ids that occur within the nested-name-specifier. These // template-ids will match up with the template parameter lists. llvm::SmallVector @@ -1610,12 +1610,12 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, ExplicitSpecializationsInSpecifier.pop_back(); } - // We have a template parameter list with no corresponding scope, which + // We have a template parameter list with no corresponding scope, which // means that the resulting template declaration can't be instantiated // properly (we'll end up with dependent nodes when we shouldn't). if (!isExplicitSpecHeader) Invalid = true; - + ++ParamIdx; } } @@ -1688,7 +1688,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, if (!isa(Record) && !Record->getDescribedClassTemplate()) continue; - + // Fetch the injected class name type and check whether its // injected type is equal to the type we just built. QualType ICNT = Context.getTypeDeclType(Record); @@ -1711,7 +1711,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, // corresponds to these arguments. void *InsertPos = 0; ClassTemplateSpecializationDecl *Decl - = ClassTemplate->findSpecialization(Converted.data(), Converted.size(), + = ClassTemplate->findSpecialization(Converted.data(), Converted.size(), InsertPos); if (!Decl) { // This is the first time we have referenced this class template @@ -1722,7 +1722,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, ClassTemplate->getDeclContext(), ClassTemplate->getLocation(), ClassTemplate, - Converted.data(), + Converted.data(), Converted.size(), 0); ClassTemplate->AddSpecialization(Decl, InsertPos); Decl->setLexicalDeclContext(CurContext); @@ -1830,12 +1830,12 @@ ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS, // We don't want lookup warnings at this point. R.suppressDiagnostics(); - + UnresolvedLookupExpr *ULE = UnresolvedLookupExpr::Create(Context, R.getNamingClass(), Qualifier, QualifierRange, R.getLookupNameInfo(), - RequiresADL, TemplateArgs, + RequiresADL, TemplateArgs, R.begin(), R.end()); return Owned(ULE); @@ -1859,7 +1859,7 @@ Sema::BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, if (R.isAmbiguous()) return ExprError(); - + if (R.empty()) { Diag(NameInfo.getLoc(), diag::err_template_kw_refers_to_non_template) << NameInfo.getName() << SS.getRange(); @@ -1884,7 +1884,7 @@ Sema::BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, /// example, given "MetaFun::template apply", the scope specifier \p /// SS will be "MetaFun::", \p TemplateKWLoc contains the location /// of the "template" keyword, and "apply" is the \p Name. -TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, +TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, SourceLocation TemplateKWLoc, CXXScopeSpec &SS, UnqualifiedId &Name, @@ -1894,8 +1894,8 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, if (TemplateKWLoc.isValid() && S && !S->getTemplateParamParent() && !getLangOptions().CPlusPlus0x) Diag(TemplateKWLoc, diag::ext_template_outside_of_template) - << FixItHint::CreateRemoval(TemplateKWLoc); - + << FixItHint::CreateRemoval(TemplateKWLoc); + DeclContext *LookupCtx = 0; if (SS.isSet()) LookupCtx = computeDeclContext(SS, EnteringContext); @@ -1927,7 +1927,7 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, cast(LookupCtx)->hasAnyDependentBases()) { // This is a dependent template. Handle it below. } else if (TNK == TNK_Non_template) { - Diag(Name.getSourceRange().getBegin(), + Diag(Name.getSourceRange().getBegin(), diag::err_template_kw_refers_to_non_template) << GetNameFromUnqualifiedId(Name).getName() << Name.getSourceRange() @@ -1941,13 +1941,13 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, NestedNameSpecifier *Qualifier = static_cast(SS.getScopeRep()); - + switch (Name.getKind()) { case UnqualifiedId::IK_Identifier: - Result = TemplateTy::make(Context.getDependentTemplateName(Qualifier, + Result = TemplateTy::make(Context.getDependentTemplateName(Qualifier, Name.Identifier)); return TNK_Dependent_template_name; - + case UnqualifiedId::IK_OperatorFunctionId: Result = TemplateTy::make(Context.getDependentTemplateName(Qualifier, Name.OperatorFunctionId.Operator)); @@ -1959,8 +1959,8 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S, default: break; } - - Diag(Name.getSourceRange().getBegin(), + + Diag(Name.getSourceRange().getBegin(), diag::err_template_kw_refers_to_non_template) << GetNameFromUnqualifiedId(Name).getName() << Name.getSourceRange() @@ -2018,7 +2018,7 @@ bool Sema::CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, /// \param SemaRef the semantic analysis object for which we are performing /// the substitution. /// -/// \param Template the template that we are synthesizing template arguments +/// \param Template the template that we are synthesizing template arguments /// for. /// /// \param TemplateLoc the location of the template name that started the @@ -2046,9 +2046,9 @@ SubstDefaultTemplateArgument(Sema &SemaRef, // If the argument type is dependent, instantiate it now based // on the previously-computed template arguments. if (ArgType->getType()->isDependentType()) { - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, + TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted.data(), Converted.size()); - + MultiLevelTemplateArgumentList AllTemplateArgs = SemaRef.getTemplateInstantiationArgs(Template, &TemplateArgs); @@ -2056,7 +2056,7 @@ SubstDefaultTemplateArgument(Sema &SemaRef, Template, Converted.data(), Converted.size(), SourceRange(TemplateLoc, RAngleLoc)); - + ArgType = SemaRef.SubstType(ArgType, AllTemplateArgs, Param->getDefaultArgumentLoc(), Param->getDeclName()); @@ -2071,7 +2071,7 @@ SubstDefaultTemplateArgument(Sema &SemaRef, /// \param SemaRef the semantic analysis object for which we are performing /// the substitution. /// -/// \param Template the template that we are synthesizing template arguments +/// \param Template the template that we are synthesizing template arguments /// for. /// /// \param TemplateLoc the location of the template name that started the @@ -2094,12 +2094,12 @@ SubstDefaultTemplateArgument(Sema &SemaRef, SourceLocation RAngleLoc, NonTypeTemplateParmDecl *Param, llvm::SmallVectorImpl &Converted) { - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, + TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted.data(), Converted.size()); - + MultiLevelTemplateArgumentList AllTemplateArgs = SemaRef.getTemplateInstantiationArgs(Template, &TemplateArgs); - + Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, Template, Converted.data(), Converted.size(), @@ -2114,7 +2114,7 @@ SubstDefaultTemplateArgument(Sema &SemaRef, /// \param SemaRef the semantic analysis object for which we are performing /// the substitution. /// -/// \param Template the template that we are synthesizing template arguments +/// \param Template the template that we are synthesizing template arguments /// for. /// /// \param TemplateLoc the location of the template name that started the @@ -2137,27 +2137,27 @@ SubstDefaultTemplateArgument(Sema &SemaRef, SourceLocation RAngleLoc, TemplateTemplateParmDecl *Param, llvm::SmallVectorImpl &Converted) { - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, + TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted.data(), Converted.size()); - + MultiLevelTemplateArgumentList AllTemplateArgs = SemaRef.getTemplateInstantiationArgs(Template, &TemplateArgs); - + Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, Template, Converted.data(), Converted.size(), SourceRange(TemplateLoc, RAngleLoc)); - + return SemaRef.SubstTemplateName( Param->getDefaultArgument().getArgument().getAsTemplate(), - Param->getDefaultArgument().getTemplateNameLoc(), + Param->getDefaultArgument().getTemplateNameLoc(), AllTemplateArgs); } /// \brief If the given template parameter has a default template /// argument, substitute into that default template argument and /// return the corresponding template argument. -TemplateArgumentLoc +TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, @@ -2201,14 +2201,14 @@ Sema::SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, return TemplateArgumentLoc(); TemplateName TName = SubstDefaultTemplateArgument(*this, Template, - TemplateLoc, + TemplateLoc, RAngleLoc, TempTempParm, Converted); if (TName.isNull()) return TemplateArgumentLoc(); - return TemplateArgumentLoc(TemplateArgument(TName), + return TemplateArgumentLoc(TemplateArgument(TName), TempTempParm->getDefaultArgument().getTemplateQualifierRange(), TempTempParm->getDefaultArgument().getTemplateNameLoc()); } @@ -2216,7 +2216,7 @@ Sema::SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, /// \brief Check that the given template argument corresponds to the given /// template parameter. /// -/// \param Param The template parameter against which the argument will be +/// \param Param The template parameter against which the argument will be /// checked. /// /// \param Arg The template argument. @@ -2250,16 +2250,16 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, // Check template type parameters. if (TemplateTypeParmDecl *TTP = dyn_cast(Param)) return CheckTemplateTypeArgument(TTP, Arg, Converted); - + // Check non-type template parameters. - if (NonTypeTemplateParmDecl *NTTP =dyn_cast(Param)) { + if (NonTypeTemplateParmDecl *NTTP =dyn_cast(Param)) { // Do substitution on the type of the non-type template parameter // with the template arguments we've seen thus far. But if the // template has a dependent context then we cannot substitute yet. QualType NTTPType = NTTP->getType(); if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack()) NTTPType = NTTP->getExpansionType(ArgumentPackIndex); - + if (NTTPType->isDependentType() && !isa(Template) && !Template->getDeclContext()->isDependentContext()) { @@ -2267,8 +2267,8 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, InstantiatingTemplate Inst(*this, TemplateLoc, Template, NTTP, Converted.data(), Converted.size(), SourceRange(TemplateLoc, RAngleLoc)); - - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, + + TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted.data(), Converted.size()); NTTPType = SubstType(NTTPType, MultiLevelTemplateArgumentList(TemplateArgs), @@ -2282,29 +2282,29 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, if (NTTPType.isNull()) return true; } - + switch (Arg.getArgument().getKind()) { case TemplateArgument::Null: assert(false && "Should never see a NULL template argument here"); return true; - + case TemplateArgument::Expression: { Expr *E = Arg.getArgument().getAsExpr(); TemplateArgument Result; if (CheckTemplateArgument(NTTP, NTTPType, E, Result, CTAK)) return true; - + Converted.push_back(Result); break; } - + case TemplateArgument::Declaration: case TemplateArgument::Integral: // We've already checked this template argument, so just copy // it to the list of converted arguments. Converted.push_back(Arg.getArgument()); break; - + case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: // We were given a template template argument. It may not be ill-formed; @@ -2324,39 +2324,39 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, DTN->getQualifier(), Arg.getTemplateQualifierRange(), NameInfo); - + // If we parsed the template argument as a pack expansion, create a // pack expansion expression. if (Arg.getArgument().getKind() == TemplateArgument::TemplateExpansion){ - ExprResult Expansion = ActOnPackExpansion(E, + ExprResult Expansion = ActOnPackExpansion(E, Arg.getTemplateEllipsisLoc()); if (Expansion.isInvalid()) return true; - + E = Expansion.get(); } - + TemplateArgument Result; if (CheckTemplateArgument(NTTP, NTTPType, E, Result)) return true; - + Converted.push_back(Result); break; } - + // We have a template argument that actually does refer to a class // template, template alias, or template template parameter, and // therefore cannot be a non-type template argument. Diag(Arg.getLocation(), diag::err_template_arg_must_be_expr) << Arg.getSourceRange(); - + Diag(Param->getLocation(), diag::note_template_param_here); return true; - + case TemplateArgument::Type: { // We have a non-type template parameter but the template // argument is a type. - + // C++ [temp.arg]p2: // In a template-argument, an ambiguity between a type-id and // an expression is resolved to a type-id, regardless of the @@ -2373,19 +2373,19 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, Diag(Param->getLocation(), diag::note_template_param_here); return true; } - + case TemplateArgument::Pack: llvm_unreachable("Caller must expand template argument packs"); break; } - + return false; - } - - + } + + // Check template template parameters. TemplateTemplateParmDecl *TempParm = cast(Param); - + // Substitute into the template parameter list of the template // template parameter, since previously-supplied template arguments // may appear within the template template parameter. @@ -2395,36 +2395,36 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, InstantiatingTemplate Inst(*this, TemplateLoc, Template, TempParm, Converted.data(), Converted.size(), SourceRange(TemplateLoc, RAngleLoc)); - - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, + + TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted.data(), Converted.size()); TempParm = cast_or_null( - SubstDecl(TempParm, CurContext, + SubstDecl(TempParm, CurContext, MultiLevelTemplateArgumentList(TemplateArgs))); if (!TempParm) return true; } - + switch (Arg.getArgument().getKind()) { case TemplateArgument::Null: assert(false && "Should never see a NULL template argument here"); return true; - + case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: if (CheckTemplateArgument(TempParm, Arg)) return true; - + Converted.push_back(Arg.getArgument()); break; - + case TemplateArgument::Expression: case TemplateArgument::Type: // We have a template template parameter but the template // argument does not refer to a template. Diag(Arg.getLocation(), diag::err_template_arg_must_be_template); return true; - + case TemplateArgument::Declaration: llvm_unreachable( "Declaration argument with template template parameter"); @@ -2433,12 +2433,12 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, llvm_unreachable( "Integral argument with template template parameter"); break; - + case TemplateArgument::Pack: llvm_unreachable("Caller must expand template argument packs"); break; } - + return false; } @@ -2496,9 +2496,9 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, if (ArgIdx < NumArgs) { // If we have an expanded parameter pack, make sure we don't have too // many arguments. - if (NonTypeTemplateParmDecl *NTTP + if (NonTypeTemplateParmDecl *NTTP = dyn_cast(*Param)) { - if (NTTP->isExpandedParameterPack() && + if (NTTP->isExpandedParameterPack() && ArgumentPack.size() >= NTTP->getNumExpansionTypes()) { Diag(TemplateLoc, diag::err_template_arg_list_different_arity) << true @@ -2511,13 +2511,13 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, return true; } } - + // Check the template argument we were given. - if (CheckTemplateArgument(*Param, TemplateArgs[ArgIdx], Template, - TemplateLoc, RAngleLoc, + if (CheckTemplateArgument(*Param, TemplateArgs[ArgIdx], Template, + TemplateLoc, RAngleLoc, ArgumentPack.size(), Converted)) return true; - + if ((*Param)->isTemplateParameterPack()) { // The template parameter was a template parameter pack, so take the // deduced argument and place it on the argument pack. Note that we @@ -2532,19 +2532,19 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, ++ArgIdx; continue; } - - // If we have a template parameter pack with no more corresponding + + // If we have a template parameter pack with no more corresponding // arguments, just break out now and we'll fill in the argument pack below. if ((*Param)->isTemplateParameterPack()) break; - + // We have a default template argument that we will use. TemplateArgumentLoc Arg; - + // Retrieve the default template argument from the template // parameter. For each kind of template parameter, we substitute the // template arguments provided thus far and any "outer" template arguments - // (when the template parameter was part of a nested template) into + // (when the template parameter was part of a nested template) into // the default argument. if (TemplateTypeParmDecl *TTP = dyn_cast(*Param)) { if (!TTP->hasDefaultArgument()) { @@ -2552,7 +2552,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, break; } - TypeSourceInfo *ArgType = SubstDefaultTemplateArgument(*this, + TypeSourceInfo *ArgType = SubstDefaultTemplateArgument(*this, Template, TemplateLoc, RAngleLoc, @@ -2560,7 +2560,7 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, Converted); if (!ArgType) return true; - + Arg = TemplateArgumentLoc(TemplateArgument(ArgType->getType()), ArgType); } else if (NonTypeTemplateParmDecl *NTTP @@ -2571,9 +2571,9 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, } ExprResult E = SubstDefaultTemplateArgument(*this, Template, - TemplateLoc, - RAngleLoc, - NTTP, + TemplateLoc, + RAngleLoc, + NTTP, Converted); if (E.isInvalid()) return true; @@ -2590,74 +2590,74 @@ bool Sema::CheckTemplateArgumentList(TemplateDecl *Template, } TemplateName Name = SubstDefaultTemplateArgument(*this, Template, - TemplateLoc, - RAngleLoc, + TemplateLoc, + RAngleLoc, TempParm, Converted); if (Name.isNull()) return true; - - Arg = TemplateArgumentLoc(TemplateArgument(Name), + + Arg = TemplateArgumentLoc(TemplateArgument(Name), TempParm->getDefaultArgument().getTemplateQualifierRange(), TempParm->getDefaultArgument().getTemplateNameLoc()); } - + // Introduce an instantiation record that describes where we are using // the default template argument. InstantiatingTemplate Instantiating(*this, RAngleLoc, Template, *Param, Converted.data(), Converted.size(), - SourceRange(TemplateLoc, RAngleLoc)); - + SourceRange(TemplateLoc, RAngleLoc)); + // Check the default template argument. if (CheckTemplateArgument(*Param, Arg, Template, TemplateLoc, RAngleLoc, 0, Converted)) return true; - + // Move to the next template parameter and argument. ++Param; ++ArgIdx; } - + // Form argument packs for each of the parameter packs remaining. while (Param != ParamEnd) { // If we're checking a partial list of template arguments, don't fill // in arguments for non-template parameter packs. - - if ((*Param)->isTemplateParameterPack()) { + + if ((*Param)->isTemplateParameterPack()) { if (PartialTemplateArgs && ArgumentPack.empty()) { Converted.push_back(TemplateArgument()); } else if (ArgumentPack.empty()) Converted.push_back(TemplateArgument(0, 0)); else { - Converted.push_back(TemplateArgument::CreatePackCopy(Context, - ArgumentPack.data(), + Converted.push_back(TemplateArgument::CreatePackCopy(Context, + ArgumentPack.data(), ArgumentPack.size())); ArgumentPack.clear(); } } - + ++Param; } - + return Invalid; } namespace { - class UnnamedLocalNoLinkageFinder - : public TypeVisitor + class UnnamedLocalNoLinkageFinder + : public TypeVisitor { Sema &S; SourceRange SR; - + typedef TypeVisitor inherited; - + public: UnnamedLocalNoLinkageFinder(Sema &S, SourceRange SR) : S(S), SR(SR) { } - bool Visit(QualType T) { - return inherited::Visit(T.getTypePtr()); + bool Visit(QualType T) { + return inherited::Visit(T.getTypePtr()); } - + #define TYPE(Class, Parent) \ bool Visit##Class##Type(const Class##Type *); #define ABSTRACT_TYPE(Class, Parent) \ @@ -2665,13 +2665,13 @@ namespace { #define NON_CANONICAL_TYPE(Class, Parent) \ bool Visit##Class##Type(const Class##Type *) { return false; } #include "clang/AST/TypeNodes.def" - + bool VisitTagDecl(const TagDecl *Tag); bool VisitNestedNameSpecifier(NestedNameSpecifier *NNS); }; } -bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(const BuiltinType*) { +bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(const BuiltinType*) { return false; } @@ -2679,52 +2679,52 @@ bool UnnamedLocalNoLinkageFinder::VisitComplexType(const ComplexType* T) { return Visit(T->getElementType()); } -bool UnnamedLocalNoLinkageFinder::VisitPointerType(const PointerType* T) { +bool UnnamedLocalNoLinkageFinder::VisitPointerType(const PointerType* T) { return Visit(T->getPointeeType()); } bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType( - const BlockPointerType* T) { + const BlockPointerType* T) { return Visit(T->getPointeeType()); } bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType( - const LValueReferenceType* T) { + const LValueReferenceType* T) { return Visit(T->getPointeeType()); } bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType( - const RValueReferenceType* T) { + const RValueReferenceType* T) { return Visit(T->getPointeeType()); } bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType( - const MemberPointerType* T) { + const MemberPointerType* T) { return Visit(T->getPointeeType()) || Visit(QualType(T->getClass(), 0)); } bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType( - const ConstantArrayType* T) { + const ConstantArrayType* T) { return Visit(T->getElementType()); } bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType( - const IncompleteArrayType* T) { + const IncompleteArrayType* T) { return Visit(T->getElementType()); } bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType( - const VariableArrayType* T) { + const VariableArrayType* T) { return Visit(T->getElementType()); } bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType( - const DependentSizedArrayType* T) { + const DependentSizedArrayType* T) { return Visit(T->getElementType()); } bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType( - const DependentSizedExtVectorType* T) { + const DependentSizedExtVectorType* T) { return Visit(T->getElementType()); } @@ -2739,12 +2739,12 @@ bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(const ExtVectorType* T) { bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType( const FunctionProtoType* T) { for (FunctionProtoType::arg_type_iterator A = T->arg_type_begin(), - AEnd = T->arg_type_end(); + AEnd = T->arg_type_end(); A != AEnd; ++A) { if (Visit(*A)) return true; } - + return Visit(T->getResultType()); } @@ -2832,8 +2832,8 @@ bool UnnamedLocalNoLinkageFinder::VisitTagDecl(const TagDecl *Tag) { S.Diag(SR.getBegin(), diag::ext_template_arg_local_type) << S.Context.getTypeDeclType(Tag) << SR; return true; - } - + } + if (!Tag->getDeclName() && !Tag->getTypedefForAnonDecl()) { S.Diag(SR.getBegin(), diag::ext_template_arg_unnamed_type) << SR; S.Diag(Tag->getLocation(), diag::note_template_unnamed_type_here); @@ -2847,13 +2847,13 @@ bool UnnamedLocalNoLinkageFinder::VisitNestedNameSpecifier( NestedNameSpecifier *NNS) { if (NNS->getPrefix() && VisitNestedNameSpecifier(NNS->getPrefix())) return true; - + switch (NNS->getKind()) { case NestedNameSpecifier::Identifier: case NestedNameSpecifier::Namespace: case NestedNameSpecifier::Global: return false; - + case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpecWithTemplate: return Visit(QualType(NNS->getAsType(), 0)); @@ -2896,7 +2896,7 @@ bool Sema::CheckTemplateArgument(TemplateTypeParmDecl *Param, /// \brief Checks whether the given template argument is the address /// of an object or function according to C++ [temp.arg.nontype]p1. -static bool +static bool CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, NonTypeTemplateParmDecl *Param, QualType ParamType, @@ -3037,7 +3037,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, // A value of reference type is not an object. if (Var->getType()->isReferenceType()) { - S.Diag(Arg->getSourceRange().getBegin(), + S.Diag(Arg->getSourceRange().getBegin(), diag::err_template_arg_reference_var) << Var->getType() << Arg->getSourceRange(); S.Diag(Param->getLocation(), diag::note_template_param_here); @@ -3101,7 +3101,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, return true; } - if (ParamType->isPointerType() && + if (ParamType->isPointerType() && !ParamType->getAs()->getPointeeType()->isFunctionType() && S.IsQualificationConversion(ArgType, ParamType, false)) { // For pointer-to-object types, qualification conversions are @@ -3128,7 +3128,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, << Arg->getSourceRange(); S.Diag(Param->getLocation(), diag::note_template_param_here); return true; - } + } } } @@ -3157,7 +3157,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, /// \brief Checks whether the given template argument is a pointer to /// member constant according to C++ [temp.arg.nontype]p1. -bool Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, +bool Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, TemplateArgument &Converted) { bool Invalid = false; @@ -3194,13 +3194,13 @@ bool Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, if (DRE && !DRE->getQualifier()) DRE = 0; } - } + } // A constant of pointer-to-member type. else if ((DRE = dyn_cast(Arg))) { if (ValueDecl *VD = dyn_cast(DRE->getDecl())) { if (VD->getType()->isMemberPointerType()) { if (isa(VD) || - (isa(VD) && + (isa(VD) && Context.getCanonicalType(VD->getType()).isConstQualified())) { if (Arg->isTypeDependent() || Arg->isValueDependent()) Converted = TemplateArgument(Arg); @@ -3210,10 +3210,10 @@ bool Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, } } } - + DRE = 0; } - + if (!DRE) return Diag(Arg->getSourceRange().getBegin(), diag::err_template_arg_not_pointer_to_member_form) @@ -3343,8 +3343,8 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, if (!Arg->isValueDependent()) { llvm::APSInt OldValue = Value; - - // Coerce the template argument's value to the value it will have + + // Coerce the template argument's value to the value it will have // based on the template parameter's type. unsigned AllowedBits = Context.getTypeSize(IntegerType); if (Value.getBitWidth() != AllowedBits) @@ -3399,7 +3399,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // from a template argument of type std::nullptr_t to a non-type // template parameter of type pointer to object, pointer to // function, or pointer-to-member, respectively. - if (ArgType->isNullPtrType() && + if (ArgType->isNullPtrType() && (ParamType->isPointerType() || ParamType->isMemberPointerType())) { Converted = TemplateArgument((NamedDecl *)0); return false; @@ -3430,7 +3430,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, ->isFunctionType())) { if (Arg->getType() == Context.OverloadTy) { - if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType, + if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType, true, FoundResult)) { if (DiagnoseUseOfDecl(Fn, Arg->getSourceRange().getBegin())) @@ -3441,10 +3441,10 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, } else return true; } - + if (!ParamType->isMemberPointerType()) return CheckTemplateArgumentAddressOfObjectOrFunction(*this, Param, - ParamType, + ParamType, Arg, Converted); if (IsQualificationConversion(ArgType, ParamType.getNonReferenceType(), @@ -3471,7 +3471,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, assert(ParamType->getPointeeType()->isIncompleteOrObjectType() && "Only object pointers allowed here"); - return CheckTemplateArgumentAddressOfObjectOrFunction(*this, Param, + return CheckTemplateArgumentAddressOfObjectOrFunction(*this, Param, ParamType, Arg, Converted); } @@ -3487,8 +3487,8 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, "Only object references allowed here"); if (Arg->getType() == Context.OverloadTy) { - if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, - ParamRefType->getPointeeType(), + if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, + ParamRefType->getPointeeType(), true, FoundResult)) { if (DiagnoseUseOfDecl(Fn, Arg->getSourceRange().getBegin())) @@ -3499,8 +3499,8 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, } else return true; } - - return CheckTemplateArgumentAddressOfObjectOrFunction(*this, Param, + + return CheckTemplateArgumentAddressOfObjectOrFunction(*this, Param, ParamType, Arg, Converted); } @@ -3562,7 +3562,7 @@ bool Sema::CheckTemplateArgument(TemplateTemplateParmDecl *Param, return !TemplateParameterListsAreEqual(Template->getTemplateParameters(), Param->getTemplateParameters(), - true, + true, TPL_TemplateTemplateArgumentMatch, Arg.getLocation()); } @@ -3571,7 +3571,7 @@ bool Sema::CheckTemplateArgument(TemplateTemplateParmDecl *Param, /// declaration and the type of its corresponding non-type template /// parameter, produce an expression that properly refers to that /// declaration. -ExprResult +ExprResult Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc) { @@ -3579,7 +3579,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, "Only declaration template arguments permitted here"); ValueDecl *VD = cast(Arg.getAsDecl()); - if (VD->getDeclContext()->isRecord() && + if (VD->getDeclContext()->isRecord() && (isa(VD) || isa(VD))) { // If the value is a class member, we might have a pointer-to-member. // Determine whether the non-type template template parameter is of @@ -3602,16 +3602,16 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, if (isa(VD) && cast(VD)->isInstance()) VK = VK_RValue; - ExprResult RefExpr = BuildDeclRefExpr(VD, + ExprResult RefExpr = BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(), VK, Loc, &SS); if (RefExpr.isInvalid()) return ExprError(); - + RefExpr = CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.get()); - + // We might need to perform a trailing qualification conversion, since // the element type on the parameter could be more qualified than the // element type in the expression we constructed. @@ -3621,14 +3621,14 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, ImpCastExprToType(RefE, ParamType.getUnqualifiedType(), CK_NoOp); RefExpr = Owned(RefE); } - + assert(!RefExpr.isInvalid() && Context.hasSameType(((Expr*) RefExpr.get())->getType(), ParamType.getUnqualifiedType())); return move(RefExpr); } } - + QualType T = VD->getType().getNonReferenceType(); if (ParamType->isPointerType()) { // When the non-type template parameter is a pointer, take the @@ -3648,7 +3648,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, return move(RefExpr); } - + // Take the address of everything else return CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.get()); } @@ -3663,7 +3663,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, T = Context.getQualifiedType(T, TargetRef->getPointeeType().getQualifiers()); } - + return BuildDeclRefExpr(VD, T, VK, Loc); } @@ -3674,7 +3674,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, /// This routine takes care of the mapping from an integral template /// argument (which may have any integral type) to the appropriate /// literal value. -ExprResult +ExprResult Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, SourceLocation Loc) { assert(Arg.getKind() == TemplateArgument::Integral && @@ -3722,12 +3722,12 @@ static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old, S.Diag(Old->getLocation(), diag::note_template_prev_declaration) << (Kind != Sema::TPL_TemplateMatch); } - + return false; } - // Check that both are parameter packs are neither are parameter packs. - // However, if we are matching a template template argument to a + // Check that both are parameter packs are neither are parameter packs. + // However, if we are matching a template template argument to a // template template parameter, the template template parameter can have // a parameter pack where the template template argument does not. if (Old->isTemplateParameterPack() != New->isTemplateParameterPack() && @@ -3740,7 +3740,7 @@ static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old, diag::err_template_arg_template_params_mismatch); NextDiag = diag::note_template_parameter_pack_non_pack; } - + unsigned ParamKind = isa(New)? 0 : isa(New)? 1 : 2; @@ -3749,15 +3749,15 @@ static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old, S.Diag(Old->getLocation(), diag::note_template_parameter_pack_here) << ParamKind << Old->isParameterPack(); } - + return false; } - + // For non-type template parameters, check the type of the parameter. if (NonTypeTemplateParmDecl *OldNTTP = dyn_cast(Old)) { NonTypeTemplateParmDecl *NewNTTP = cast(New); - + // If we are matching a template template argument to a template // template parameter and one of the non-type template parameter types // is dependent, then we must wait until template instantiation time @@ -3766,12 +3766,12 @@ static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old, (OldNTTP->getType()->isDependentType() || NewNTTP->getType()->isDependentType())) return true; - + if (!S.Context.hasSameType(OldNTTP->getType(), NewNTTP->getType())) { if (Complain) { unsigned NextDiag = diag::err_template_nontype_parm_different_type; if (TemplateArgLoc.isValid()) { - S.Diag(TemplateArgLoc, + S.Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch); NextDiag = diag::note_template_nontype_parm_different_type; } @@ -3782,35 +3782,35 @@ static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old, diag::note_template_nontype_parm_prev_declaration) << OldNTTP->getType(); } - + return false; } - + return true; } - + // For template template parameters, check the template parameter types. // The template parameter lists of template template // parameters must agree. if (TemplateTemplateParmDecl *OldTTP = dyn_cast(Old)) { - TemplateTemplateParmDecl *NewTTP = cast(New); + TemplateTemplateParmDecl *NewTTP = cast(New); return S.TemplateParameterListsAreEqual(NewTTP->getTemplateParameters(), OldTTP->getTemplateParameters(), Complain, (Kind == Sema::TPL_TemplateMatch - ? Sema::TPL_TemplateTemplateParmMatch + ? Sema::TPL_TemplateTemplateParmMatch : Kind), TemplateArgLoc); } - + return true; } /// \brief Diagnose a known arity mismatch when comparing template argument /// lists. static -void DiagnoseTemplateParameterListArityMismatch(Sema &S, +void DiagnoseTemplateParameterListArityMismatch(Sema &S, TemplateParameterList *New, TemplateParameterList *Old, Sema::TemplateParameterListEqualKind Kind, @@ -3883,18 +3883,18 @@ Sema::TemplateParameterListsAreEqual(TemplateParameterList *New, if (Complain) DiagnoseTemplateParameterListArityMismatch(*this, New, Old, Kind, TemplateArgLoc); - + return false; } - + if (!MatchTemplateParameterKind(*this, *NewParm, *OldParm, Complain, Kind, TemplateArgLoc)) - return false; - + return false; + ++NewParm; continue; } - + // C++0x [temp.arg.template]p3: // [...] When P's template- parameter-list contains a template parameter // pack (14.5.3), the template parameter pack will match zero or more @@ -3905,19 +3905,19 @@ Sema::TemplateParameterListsAreEqual(TemplateParameterList *New, for (; NewParm != NewParmEnd; ++NewParm) { if (!MatchTemplateParameterKind(*this, *NewParm, *OldParm, Complain, Kind, TemplateArgLoc)) - return false; + return false; } } - + // Make sure we exhausted all of the arguments. if (NewParm != NewParmEnd) { if (Complain) DiagnoseTemplateParameterListArityMismatch(*this, New, Old, Kind, TemplateArgLoc); - + return false; } - + return true; } @@ -3957,18 +3957,18 @@ Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) { static TemplateSpecializationKind getTemplateSpecializationKind(NamedDecl *D) { if (!D) return TSK_Undeclared; - + if (CXXRecordDecl *Record = dyn_cast(D)) return Record->getTemplateSpecializationKind(); if (FunctionDecl *Function = dyn_cast(D)) return Function->getTemplateSpecializationKind(); if (VarDecl *Var = dyn_cast(D)) return Var->getTemplateSpecializationKind(); - + return TSK_Undeclared; } -/// \brief Check whether a specialization is well-formed in the current +/// \brief Check whether a specialization is well-formed in the current /// context. /// /// This routine determines whether a template specialization can be declared @@ -3979,7 +3979,7 @@ static TemplateSpecializationKind getTemplateSpecializationKind(NamedDecl *D) { /// /// \param Specialized the entity being specialized or instantiated, which /// may be a kind of template (class template, function template, etc.) or -/// a member of a class template (member function, static data member, +/// a member of a class template (member function, static data member, /// member class). /// /// \param PrevDecl the previous declaration of this entity, if any. @@ -4040,28 +4040,28 @@ static bool CheckTemplateSpecializationScope(Sema &S, << Specialized; return true; } - + // C++ [temp.class.spec]p6: // A class template partial specialization may be declared or redeclared - // in any namespace scope in which its definition may be defined (14.5.1 - // and 14.5.2). + // in any namespace scope in which its definition may be defined (14.5.1 + // and 14.5.2). bool ComplainedAboutScope = false; - DeclContext *SpecializedContext + DeclContext *SpecializedContext = Specialized->getDeclContext()->getEnclosingNamespaceContext(); DeclContext *DC = S.CurContext->getEnclosingNamespaceContext(); - if ((!PrevDecl || + if ((!PrevDecl || getTemplateSpecializationKind(PrevDecl) == TSK_Undeclared || getTemplateSpecializationKind(PrevDecl) == TSK_ImplicitInstantiation)){ // C++ [temp.exp.spec]p2: // An explicit specialization shall be declared in the namespace of which - // the template is a member, or, for member templates, in the namespace + // the template is a member, or, for member templates, in the namespace // of which the enclosing class or enclosing class template is a member. - // An explicit specialization of a member function, member class or - // static data member of a class template shall be declared in the + // An explicit specialization of a member function, member class or + // static data member of a class template shall be declared in the // namespace of which the class template is a member. // // C++0x [temp.expl.spec]p2: - // An explicit specialization shall be declared in a namespace enclosing + // An explicit specialization shall be declared in a namespace enclosing // the specialized template. if (!DC->InEnclosingNamespaceSetOf(SpecializedContext) && !(S.getLangOptions().CPlusPlus0x && DC->Encloses(SpecializedContext))) { @@ -4078,15 +4078,15 @@ static bool CheckTemplateSpecializationScope(Sema &S, : diag::err_template_spec_decl_out_of_scope) << EntityKind << Specialized << cast(SpecializedContext); - + S.Diag(Specialized->getLocation(), diag::note_specialized_entity); ComplainedAboutScope = true; } } - - // Make sure that this redeclaration (or definition) occurs in an enclosing + + // Make sure that this redeclaration (or definition) occurs in an enclosing // namespace. - // Note that HandleDeclarator() performs this check for explicit + // Note that HandleDeclarator() performs this check for explicit // specializations of function templates, static data members, and member // functions, so we skip the check here for those kinds of entities. // FIXME: HandleDeclarator's diagnostics aren't quite as good, though. @@ -4101,15 +4101,15 @@ static bool CheckTemplateSpecializationScope(Sema &S, S.Diag(Loc, diag::err_template_spec_redecl_out_of_scope) << EntityKind << Specialized << cast(SpecializedContext); - + S.Diag(Specialized->getLocation(), diag::note_specialized_entity); } - + // FIXME: check for specialization-after-instantiation errors and such. - + return false; } - + /// \brief Subroutine of Sema::CheckClassTemplatePartialSpecializationArgs /// that checks non-type template partial specialization arguments. static bool CheckNonTypeClassTemplatePartialSpecializationArgs(Sema &S, @@ -4119,13 +4119,13 @@ static bool CheckNonTypeClassTemplatePartialSpecializationArgs(Sema &S, for (unsigned I = 0; I != NumArgs; ++I) { if (Args[I].getKind() == TemplateArgument::Pack) { if (CheckNonTypeClassTemplatePartialSpecializationArgs(S, Param, - Args[I].pack_begin(), + Args[I].pack_begin(), Args[I].pack_size())) return true; - + continue; } - + Expr *ArgExpr = Args[I].getAsExpr(); if (!ArgExpr) { continue; @@ -4138,7 +4138,7 @@ static bool CheckNonTypeClassTemplatePartialSpecializationArgs(Sema &S, // Strip off any implicit casts we added as part of type checking. while (ImplicitCastExpr *ICE = dyn_cast(ArgExpr)) ArgExpr = ICE->getSubExpr(); - + // C++ [temp.class.spec]p8: // A non-type argument is non-specialized if it is the name of a // non-type parameter. All other non-type arguments are @@ -4150,7 +4150,7 @@ static bool CheckNonTypeClassTemplatePartialSpecializationArgs(Sema &S, if (DeclRefExpr *DRE = dyn_cast(ArgExpr)) if (isa(DRE->getDecl())) continue; - + // C++ [temp.class.spec]p9: // Within the argument list of a class template partial // specialization, the following restrictions apply: @@ -4164,7 +4164,7 @@ static bool CheckNonTypeClassTemplatePartialSpecializationArgs(Sema &S, << ArgExpr->getSourceRange(); return true; } - + // -- The type of a template parameter corresponding to a // specialized non-type argument shall not be dependent on a // parameter of the specialization. @@ -4177,10 +4177,10 @@ static bool CheckNonTypeClassTemplatePartialSpecializationArgs(Sema &S, return true; } } - + return false; } - + /// \brief Check the non-type template arguments of a class template /// partial specialization according to C++ [temp.class.spec]p9. /// @@ -4202,7 +4202,7 @@ static bool CheckClassTemplatePartialSpecializationArgs(Sema &S, if (!Param) continue; - if (CheckNonTypeClassTemplatePartialSpecializationArgs(S, Param, + if (CheckNonTypeClassTemplatePartialSpecializationArgs(S, Param, &ArgList[I], 1)) return true; } @@ -4248,7 +4248,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, if (!ClassTemplate) { Diag(TemplateNameLoc, diag::err_not_class_template_specialization) - << (Name.getAsTemplateDecl() && + << (Name.getAsTemplateDecl() && isa(Name.getAsTemplateDecl())); return true; } @@ -4270,7 +4270,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, Invalid); if (Invalid) return true; - + unsigned NumMatchedTemplateParamLists = TemplateParameterLists.size(); if (TemplateParams) --NumMatchedTemplateParamLists; @@ -4283,7 +4283,7 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, << SourceRange(LAngleLoc, RAngleLoc); return true; } - + // C++ [temp.class.spec]p10: // The template parameter list of a specialization shall not // contain default template argument values. @@ -4352,10 +4352,10 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, // Check for unexpanded parameter packs in any of the template arguments. for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I) - if (DiagnoseUnexpandedParameterPack(TemplateArgs[I], + if (DiagnoseUnexpandedParameterPack(TemplateArgs[I], UPPC_PartialSpecialization)) return true; - + // Check that the template argument list is well-formed for this // template. llvm::SmallVector Converted; @@ -4374,9 +4374,9 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, Converted)) return true; - if (!Name.isDependent() && + if (!Name.isDependent() && !TemplateSpecializationType::anyDependentTemplateArguments( - TemplateArgs.getArgumentArray(), + TemplateArgs.getArgumentArray(), TemplateArgs.size())) { Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized) << ClassTemplate->getDeclName(); @@ -4403,14 +4403,14 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, // Check whether we can declare a class template specialization in // the current scope. if (TUK != TUK_Friend && - CheckTemplateSpecializationScope(*this, ClassTemplate, PrevDecl, - TemplateNameLoc, + CheckTemplateSpecializationScope(*this, ClassTemplate, PrevDecl, + TemplateNameLoc, isPartialSpecialization)) return true; - + // The canonical type QualType CanonType; - if (PrevDecl && + if (PrevDecl && (PrevDecl->getSpecializationKind() == TSK_Undeclared || TUK == TUK_Friend)) { // Since the only prior class template specialization with these @@ -4429,8 +4429,8 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, CanonType = Context.getTemplateSpecializationType(CanonTemplate, Converted.data(), Converted.size()); - - if (Context.hasSameType(CanonType, + + if (Context.hasSameType(CanonType, ClassTemplate->getInjectedClassNameSpecialization())) { // C++ [temp.class.spec]p9b3: // @@ -4475,18 +4475,18 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, ClassTemplate->AddPartialSpecialization(Partial, InsertPos); Specialization = Partial; - // If we are providing an explicit specialization of a member class + // If we are providing an explicit specialization of a member class // template specialization, make a note of that. if (PrevPartial && PrevPartial->getInstantiatedFromMember()) PrevPartial->setMemberSpecialization(); - + // Check that all of the template parameters of the class template // partial specialization are deducible from the template // arguments. If not, this class template partial specialization // will never be used. llvm::SmallVector DeducibleParams; DeducibleParams.resize(TemplateParams->size()); - MarkUsedTemplateParameters(Partial->getTemplateArgs(), true, + MarkUsedTemplateParameters(Partial->getTemplateArgs(), true, TemplateParams->getDepth(), DeducibleParams); unsigned NumNonDeducible = 0; @@ -4538,9 +4538,9 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, // C++ [temp.expl.spec]p6: // If a template, a member template or the member of a class template is - // explicitly specialized then that specialization shall be declared + // explicitly specialized then that specialization shall be declared // before the first use of that specialization that would cause an implicit - // instantiation to take place, in every translation unit in which such a + // instantiation to take place, in every translation unit in which such a // use occurs; no diagnostic is required. if (PrevDecl && PrevDecl->getPointOfInstantiation().isValid()) { bool Okay = false; @@ -4557,14 +4557,14 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, Diag(TemplateNameLoc, diag::err_specialization_after_instantiation) << Context.getTypeDeclType(Specialization) << Range; - Diag(PrevDecl->getPointOfInstantiation(), + Diag(PrevDecl->getPointOfInstantiation(), diag::note_instantiation_required_here) - << (PrevDecl->getTemplateSpecializationKind() + << (PrevDecl->getTemplateSpecializationKind() != TSK_ImplicitInstantiation); return true; } } - + // If this is not a friend, note that this is an explicit specialization. if (TUK != TUK_Friend) Specialization->setSpecializationKind(TSK_ExplicitSpecialization); @@ -4671,12 +4671,12 @@ static void StripImplicitInstantiation(NamedDecl *D) { } } -/// \brief Diagnose cases where we have an explicit template specialization +/// \brief Diagnose cases where we have an explicit template specialization /// before/after an explicit template instantiation, producing diagnostics -/// for those cases where they are required and determining whether the +/// for those cases where they are required and determining whether the /// new specialization/instantiation will have any effect. /// -/// \param NewLoc the location of the new explicit specialization or +/// \param NewLoc the location of the new explicit specialization or /// instantiation. /// /// \param NewTSK the kind of the new explicit specialization or instantiation. @@ -4685,10 +4685,10 @@ static void StripImplicitInstantiation(NamedDecl *D) { /// /// \param PrevTSK the kind of the old explicit specialization or instantiatin. /// -/// \param PrevPointOfInstantiation if valid, indicates where the previus +/// \param PrevPointOfInstantiation if valid, indicates where the previus /// declaration was instantiated (either implicitly or explicitly). /// -/// \param HasNoEffect will be set to true to indicate that the new +/// \param HasNoEffect will be set to true to indicate that the new /// specialization or instantiation has no effect and should be ignored. /// /// \returns true if there was an error that should prevent the introduction of @@ -4701,18 +4701,18 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, SourceLocation PrevPointOfInstantiation, bool &HasNoEffect) { HasNoEffect = false; - + switch (NewTSK) { case TSK_Undeclared: case TSK_ImplicitInstantiation: assert(false && "Don't check implicit instantiations here"); return false; - + case TSK_ExplicitSpecialization: switch (PrevTSK) { case TSK_Undeclared: case TSK_ExplicitSpecialization: - // Okay, we're just specializing something that is either already + // Okay, we're just specializing something that is either already // explicitly specialized or has merely been mentioned without any // instantiation. return false; @@ -4725,17 +4725,17 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, return false; } // Fall through - + case TSK_ExplicitInstantiationDeclaration: case TSK_ExplicitInstantiationDefinition: - assert((PrevTSK == TSK_ImplicitInstantiation || - PrevPointOfInstantiation.isValid()) && + assert((PrevTSK == TSK_ImplicitInstantiation || + PrevPointOfInstantiation.isValid()) && "Explicit instantiation without point of instantiation?"); - + // C++ [temp.expl.spec]p6: - // If a template, a member template or the member of a class template + // If a template, a member template or the member of a class template // is explicitly specialized then that specialization shall be declared - // before the first use of that specialization that would cause an + // before the first use of that specialization that would cause an // implicit instantiation to take place, in every translation unit in // which such a use occurs; no diagnostic is required. for (NamedDecl *Prev = PrevDecl; Prev; Prev = getPreviousDecl(Prev)) { @@ -4748,41 +4748,41 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, << PrevDecl; Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here) << (PrevTSK != TSK_ImplicitInstantiation); - + return true; } break; - + case TSK_ExplicitInstantiationDeclaration: switch (PrevTSK) { case TSK_ExplicitInstantiationDeclaration: // This explicit instantiation declaration is redundant (that's okay). HasNoEffect = true; return false; - + case TSK_Undeclared: case TSK_ImplicitInstantiation: // We're explicitly instantiating something that may have already been // implicitly instantiated; that's fine. return false; - + case TSK_ExplicitSpecialization: // C++0x [temp.explicit]p4: // For a given set of template parameters, if an explicit instantiation - // of a template appears after a declaration of an explicit + // of a template appears after a declaration of an explicit // specialization for that template, the explicit instantiation has no // effect. HasNoEffect = true; return false; - + case TSK_ExplicitInstantiationDefinition: // C++0x [temp.explicit]p10: - // If an entity is the subject of both an explicit instantiation - // declaration and an explicit instantiation definition in the same + // If an entity is the subject of both an explicit instantiation + // declaration and an explicit instantiation definition in the same // translation unit, the definition shall follow the declaration. - Diag(NewLoc, + Diag(NewLoc, diag::err_explicit_instantiation_declaration_after_definition); - Diag(PrevPointOfInstantiation, + Diag(PrevPointOfInstantiation, diag::note_explicit_instantiation_definition_here); assert(PrevPointOfInstantiation.isValid() && "Explicit instantiation without point of instantiation?"); @@ -4790,7 +4790,7 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, return false; } break; - + case TSK_ExplicitInstantiationDefinition: switch (PrevTSK) { case TSK_Undeclared: @@ -4798,7 +4798,7 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, // We're explicitly instantiating something that may have already been // implicitly instantiated; that's fine. return false; - + case TSK_ExplicitSpecialization: // C++ DR 259, C++0x [temp.explicit]p4: // For a given set of template parameters, if an explicit @@ -4806,7 +4806,7 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, // an explicit specialization for that template, the explicit // instantiation has no effect. // - // In C++98/03 mode, we only give an extension warning here, because it + // In C++98/03 mode, we only give an extension warning here, because it // is not harmful to try to explicitly instantiate something that // has been explicitly specialized. if (!getLangOptions().CPlusPlus0x) { @@ -4817,12 +4817,12 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, } HasNoEffect = true; return false; - + case TSK_ExplicitInstantiationDeclaration: // We're explicity instantiating a definition for something for which we - // were previously asked to suppress instantiations. That's fine. + // were previously asked to suppress instantiations. That's fine. return false; - + case TSK_ExplicitInstantiationDefinition: // C++0x [temp.spec]p5: // For a given template and a given set of template-arguments, @@ -4830,16 +4830,16 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, // in a program, Diag(NewLoc, diag::err_explicit_instantiation_duplicate) << PrevDecl; - Diag(PrevPointOfInstantiation, + Diag(PrevPointOfInstantiation, diag::note_previous_explicit_instantiation); HasNoEffect = true; - return false; + return false; } break; } - + assert(false && "Missing specialization/instantiation case?"); - + return false; } @@ -4905,21 +4905,21 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD, // The set of function template specializations that could match this // explicit function template specialization. UnresolvedSet<8> Candidates; - + DeclContext *FDLookupContext = FD->getDeclContext()->getRedeclContext(); for (LookupResult::iterator I = Previous.begin(), E = Previous.end(); I != E; ++I) { NamedDecl *Ovl = (*I)->getUnderlyingDecl(); if (FunctionTemplateDecl *FunTmpl = dyn_cast(Ovl)) { - // Only consider templates found within the same semantic lookup scope as + // Only consider templates found within the same semantic lookup scope as // FD. if (!FDLookupContext->InEnclosingNamespaceSetOf( Ovl->getDeclContext()->getRedeclContext())) continue; - + // C++ [temp.expl.spec]p11: - // A trailing template-argument can be left unspecified in the - // template-id naming an explicit function template specialization + // A trailing template-argument can be left unspecified in the + // template-id naming an explicit function template specialization // provided it can be deduced from the function argument type. // Perform template argument deduction to determine whether we may be // specializing this template. @@ -4936,17 +4936,17 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD, (void)TDK; continue; } - + // Record this candidate. Candidates.addDecl(Specialization, I.getAccess()); } } - + // Find the most specialized function template. UnresolvedSetIterator Result = getMostSpecialized(Candidates.begin(), Candidates.end(), TPOC_Other, 0, FD->getLocation(), - PDiag(diag::err_function_template_spec_no_match) + PDiag(diag::err_function_template_spec_no_match) << FD->getDeclName(), PDiag(diag::err_function_template_spec_ambiguous) << FD->getDeclName() << (ExplicitTemplateArgs != 0), @@ -4957,27 +4957,27 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD, // Ignore access information; it doesn't figure into redeclaration checking. FunctionDecl *Specialization = cast(*Result); Specialization->setLocation(FD->getLocation()); - + // FIXME: Check if the prior specialization has a point of instantiation. // If so, we have run afoul of . // If this is a friend declaration, then we're not really declaring // an explicit specialization. bool isFriend = (FD->getFriendObjectKind() != Decl::FOK_None); - + // Check the scope of this explicit specialization. if (!isFriend && - CheckTemplateSpecializationScope(*this, + CheckTemplateSpecializationScope(*this, Specialization->getPrimaryTemplate(), - Specialization, FD->getLocation(), + Specialization, FD->getLocation(), false)) return true; // C++ [temp.expl.spec]p6: // If a template, a member template or the member of a class template is - // explicitly specialized then that specialization shall be declared + // explicitly specialized then that specialization shall be declared // before the first use of that specialization that would cause an implicit - // instantiation to take place, in every translation unit in which such a + // instantiation to take place, in every translation unit in which such a // use occurs; no diagnostic is required. FunctionTemplateSpecializationInfo *SpecInfo = Specialization->getTemplateSpecializationInfo(); @@ -4992,14 +4992,14 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD, SpecInfo->getPointOfInstantiation(), HasNoEffect)) return true; - + // Mark the prior declaration as an explicit specialization, so that later // clients know that this is an explicit specialization. if (!isFriend) { SpecInfo->setTemplateSpecializationKind(TSK_ExplicitSpecialization); MarkUnusedFileScopedDecl(Specialization); } - + // Turn the given function declaration into a function template // specialization, with the template arguments from the previous // specialization. @@ -5023,7 +5023,7 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD, /// \brief Perform semantic analysis for the given non-template member /// specialization. /// -/// This routine performs all of the semantic analysis required for an +/// This routine performs all of the semantic analysis required for an /// explicit member function specialization. On successful completion, /// the function declaration \p FD will become a member function /// specialization. @@ -5034,7 +5034,7 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD, /// \param Previous the set of declarations, one of which may be specialized /// by this function specialization; the set will be modified to contain the /// redeclared member. -bool +bool Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) { assert(!isa(Member) && "Only for non-template members"); @@ -5076,7 +5076,7 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) { MSInfo = PrevRecord->getMemberSpecializationInfo(); } } - + if (!Instantiation) { // There is no previous declaration that matches. Since member // specializations are always out-of-line, the caller will complain about @@ -5102,7 +5102,7 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) { Previous.addDecl(Instantiation); return false; } - + // Make sure that this is a specialization of a member. if (!InstantiatedFrom) { Diag(Member->getLocation(), diag::err_spec_member_not_instantiated) @@ -5110,12 +5110,12 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) { Diag(Instantiation->getLocation(), diag::note_specialized_decl); return true; } - + // C++ [temp.expl.spec]p6: // If a template, a member template or the member of a class template is - // explicitly specialized then that spe- cialization shall be declared + // explicitly specialized then that spe- cialization shall be declared // before the first use of that specialization that would cause an implicit - // instantiation to take place, in every translation unit in which such a + // instantiation to take place, in every translation unit in which such a // use occurs; no diagnostic is required. assert(MSInfo && "Member specialization info missing?"); @@ -5127,11 +5127,11 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) { MSInfo->getPointOfInstantiation(), HasNoEffect)) return true; - + // Check the scope of this explicit specialization. - if (CheckTemplateSpecializationScope(*this, + if (CheckTemplateSpecializationScope(*this, InstantiatedFrom, - Instantiation, Member->getLocation(), + Instantiation, Member->getLocation(), false)) return true; @@ -5147,7 +5147,7 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) { TSK_ExplicitSpecialization); InstantiationFunction->setLocation(Member->getLocation()); } - + cast(Member)->setInstantiationOfMemberFunction( cast(InstantiatedFrom), TSK_ExplicitSpecialization); @@ -5160,7 +5160,7 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) { TSK_ExplicitSpecialization); InstantiationVar->setLocation(Member->getLocation()); } - + Context.setInstantiatedFromStaticDataMember(cast(Member), cast(InstantiatedFrom), TSK_ExplicitSpecialization); @@ -5174,12 +5174,12 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) { TSK_ExplicitSpecialization); InstantiationClass->setLocation(Member->getLocation()); } - + cast(Member)->setInstantiationOfMemberClass( cast(InstantiatedFrom), TSK_ExplicitSpecialization); } - + // Save the caller the trouble of having to figure out which declaration // this specialization matches. Previous.clear(); @@ -5195,28 +5195,28 @@ static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, bool WasQualifiedName) { DeclContext *OrigContext= D->getDeclContext()->getEnclosingNamespaceContext(); DeclContext *CurContext = S.CurContext->getRedeclContext(); - + if (CurContext->isRecord()) { S.Diag(InstLoc, diag::err_explicit_instantiation_in_class) << D; return true; } - + // C++0x [temp.explicit]p2: - // An explicit instantiation shall appear in an enclosing namespace of its + // An explicit instantiation shall appear in an enclosing namespace of its // template. // // This is DR275, which we do not retroactively apply to C++98/03. - if (S.getLangOptions().CPlusPlus0x && + if (S.getLangOptions().CPlusPlus0x && !CurContext->Encloses(OrigContext)) { if (NamespaceDecl *NS = dyn_cast(OrigContext)) - S.Diag(InstLoc, - S.getLangOptions().CPlusPlus0x? + S.Diag(InstLoc, + S.getLangOptions().CPlusPlus0x? diag::err_explicit_instantiation_out_of_scope : diag::warn_explicit_instantiation_out_of_scope_0x) << D << NS; else - S.Diag(InstLoc, + S.Diag(InstLoc, S.getLangOptions().CPlusPlus0x? diag::err_explicit_instantiation_must_be_global : diag::warn_explicit_instantiation_out_of_scope_0x) @@ -5226,8 +5226,8 @@ static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, } // C++0x [temp.explicit]p2: - // If the name declared in the explicit instantiation is an unqualified - // name, the explicit instantiation shall appear in the namespace where + // If the name declared in the explicit instantiation is an unqualified + // name, the explicit instantiation shall appear in the namespace where // its template is declared or, if that namespace is inline (7.3.1), any // namespace from its enclosing namespace set. if (WasQualifiedName) @@ -5236,7 +5236,7 @@ static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, if (CurContext->InEnclosingNamespaceSetOf(OrigContext)) return false; - S.Diag(InstLoc, + S.Diag(InstLoc, S.getLangOptions().CPlusPlus0x? diag::err_explicit_instantiation_unqualified_wrong_namespace : diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x) @@ -5249,9 +5249,9 @@ static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D, static bool ScopeSpecifierHasTemplateId(const CXXScopeSpec &SS) { if (!SS.isSet()) return false; - + // C++0x [temp.explicit]p2: - // If the explicit instantiation is for a member function, a member class + // If the explicit instantiation is for a member function, a member class // or a static data member of a class template specialization, the name of // the class template specialization in the qualified-id for the member // name shall be a simple-template-id. @@ -5304,12 +5304,12 @@ Sema::ActOnExplicitInstantiation(Scope *S, // C++0x [temp.explicit]p2: // There are two forms of explicit instantiation: an explicit instantiation - // definition and an explicit instantiation declaration. An explicit - // instantiation declaration begins with the extern keyword. [...] + // definition and an explicit instantiation declaration. An explicit + // instantiation declaration begins with the extern keyword. [...] TemplateSpecializationKind TSK = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition : TSK_ExplicitInstantiationDeclaration; - + // Translate the parser's template argument list in our AST format. TemplateArgumentListInfo TemplateArgs(LAngleLoc, RAngleLoc); translateTemplateArguments(TemplateArgsIn, TemplateArgs); @@ -5342,7 +5342,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, if (CheckExplicitInstantiationScope(*this, ClassTemplate, TemplateNameLoc, SS.isSet())) return true; - + ClassTemplateSpecializationDecl *Specialization = 0; bool HasNoEffect = false; @@ -5489,7 +5489,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, if (Tag->isInvalidDecl()) return true; - + CXXRecordDecl *Record = cast(Tag); CXXRecordDecl *Pattern = Record->getInstantiatedFromMemberClass(); if (!Pattern) { @@ -5500,32 +5500,32 @@ Sema::ActOnExplicitInstantiation(Scope *S, } // C++0x [temp.explicit]p2: - // If the explicit instantiation is for a class or member class, the - // elaborated-type-specifier in the declaration shall include a + // If the explicit instantiation is for a class or member class, the + // elaborated-type-specifier in the declaration shall include a // simple-template-id. // // C++98 has the same restriction, just worded differently. if (!ScopeSpecifierHasTemplateId(SS)) Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id) << Record << SS.getRange(); - + // C++0x [temp.explicit]p2: // There are two forms of explicit instantiation: an explicit instantiation - // definition and an explicit instantiation declaration. An explicit + // definition and an explicit instantiation declaration. An explicit // instantiation declaration begins with the extern keyword. [...] TemplateSpecializationKind TSK = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition : TSK_ExplicitInstantiationDeclaration; - + // C++0x [temp.explicit]p2: // [...] An explicit instantiation shall appear in an enclosing // namespace of its template. [...] // // This is C++ DR 275. CheckExplicitInstantiationScope(*this, Record, NameLoc, true); - + // Verify that it is okay to explicitly instantiate here. - CXXRecordDecl *PrevDecl + CXXRecordDecl *PrevDecl = cast_or_null(Record->getPreviousDeclaration()); if (!PrevDecl && Record->getDefinition()) PrevDecl = Record; @@ -5533,23 +5533,23 @@ Sema::ActOnExplicitInstantiation(Scope *S, MemberSpecializationInfo *MSInfo = PrevDecl->getMemberSpecializationInfo(); bool HasNoEffect = false; assert(MSInfo && "No member specialization information?"); - if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK, + if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK, PrevDecl, MSInfo->getTemplateSpecializationKind(), - MSInfo->getPointOfInstantiation(), + MSInfo->getPointOfInstantiation(), HasNoEffect)) return true; if (HasNoEffect) return TagD; } - + CXXRecordDecl *RecordDef = cast_or_null(Record->getDefinition()); if (!RecordDef) { // C++ [temp.explicit]p3: - // A definition of a member class of a class template shall be in scope + // A definition of a member class of a class template shall be in scope // at the point of an explicit instantiation of the member class. - CXXRecordDecl *Def + CXXRecordDecl *Def = cast_or_null(Pattern->getDefinition()); if (!Def) { Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member) @@ -5567,8 +5567,8 @@ Sema::ActOnExplicitInstantiation(Scope *S, if (!RecordDef) return true; } - } - + } + // Instantiate all of the members of the class. InstantiateClassMembers(NameLoc, RecordDef, getTemplateInstantiationArgs(Record), TSK); @@ -5597,7 +5597,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, diag::err_explicit_instantiation_requires_name) << D.getDeclSpec().getSourceRange() << D.getSourceRange(); - + return true; } @@ -5612,7 +5612,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, QualType R = T->getType(); if (R.isNull()) return true; - + if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) { // Cannot explicitly instantiate a typedef. Diag(D.getIdentifierLoc(), diag::err_explicit_instantiation_of_typedef) @@ -5626,31 +5626,31 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, // Presumably, this also applies to member functions of class templates as // well. if (D.getDeclSpec().isInlineSpecified() && getLangOptions().CPlusPlus0x) - Diag(D.getDeclSpec().getInlineSpecLoc(), + Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_explicit_instantiation_inline) <isFunctionType()) { // C++ [temp.explicit]p1: - // A [...] static data member of a class template can be explicitly - // instantiated from the member definition associated with its class + // A [...] static data member of a class template can be explicitly + // instantiated from the member definition associated with its class // template. if (Previous.isAmbiguous()) return true; - + VarDecl *Prev = Previous.getAsSingle(); if (!Prev || !Prev->isStaticDataMember()) { // We expect to see a data data member here. @@ -5661,54 +5661,54 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, Diag((*P)->getLocation(), diag::note_explicit_instantiation_here); return true; } - + if (!Prev->getInstantiatedFromStaticDataMember()) { // FIXME: Check for explicit specialization? - Diag(D.getIdentifierLoc(), + Diag(D.getIdentifierLoc(), diag::err_explicit_instantiation_data_member_not_instantiated) << Prev; Diag(Prev->getLocation(), diag::note_explicit_instantiation_here); // FIXME: Can we provide a note showing where this was declared? return true; } - + // C++0x [temp.explicit]p2: - // If the explicit instantiation is for a member function, a member class + // If the explicit instantiation is for a member function, a member class // or a static data member of a class template specialization, the name of // the class template specialization in the qualified-id for the member // name shall be a simple-template-id. // // C++98 has the same restriction, just worded differently. if (!ScopeSpecifierHasTemplateId(D.getCXXScopeSpec())) - Diag(D.getIdentifierLoc(), + Diag(D.getIdentifierLoc(), diag::ext_explicit_instantiation_without_qualified_id) << Prev << D.getCXXScopeSpec().getRange(); - + // Check the scope of this explicit instantiation. CheckExplicitInstantiationScope(*this, Prev, D.getIdentifierLoc(), true); - + // Verify that it is okay to explicitly instantiate here. MemberSpecializationInfo *MSInfo = Prev->getMemberSpecializationInfo(); assert(MSInfo && "Missing static data member specialization info?"); bool HasNoEffect = false; if (CheckSpecializationInstantiationRedecl(D.getIdentifierLoc(), TSK, Prev, MSInfo->getTemplateSpecializationKind(), - MSInfo->getPointOfInstantiation(), + MSInfo->getPointOfInstantiation(), HasNoEffect)) return true; if (HasNoEffect) return (Decl*) 0; - + // Instantiate static data member. Prev->setTemplateSpecializationKind(TSK, D.getIdentifierLoc()); if (TSK == TSK_ExplicitInstantiationDefinition) InstantiateStaticDataMemberDefinition(D.getIdentifierLoc(), Prev); - + // FIXME: Create an ExplicitInstantiation node? return (Decl*) 0; } - - // If the declarator is a template-id, translate the parser's template + + // If the declarator is a template-id, translate the parser's template // argument list into our AST format. bool HasExplicitTemplateArgs = false; TemplateArgumentListInfo TemplateArgs; @@ -5723,11 +5723,11 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, HasExplicitTemplateArgs = true; TemplateArgsPtr.release(); } - + // C++ [temp.explicit]p1: - // A [...] function [...] can be explicitly instantiated from its template. - // A member function [...] of a class template can be explicitly - // instantiated from the member definition associated with its class + // A [...] function [...] can be explicitly instantiated from its template. + // A member function [...] of a class template can be explicitly + // instantiated from the member definition associated with its class // template. UnresolvedSet<8> Matches; for (LookupResult::iterator P = Previous.begin(), PEnd = Previous.end(); @@ -5744,7 +5744,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, } } } - + FunctionTemplateDecl *FunTmpl = dyn_cast(Prev); if (!FunTmpl) continue; @@ -5752,21 +5752,21 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, TemplateDeductionInfo Info(Context, D.getIdentifierLoc()); FunctionDecl *Specialization = 0; if (TemplateDeductionResult TDK - = DeduceTemplateArguments(FunTmpl, + = DeduceTemplateArguments(FunTmpl, (HasExplicitTemplateArgs ? &TemplateArgs : 0), R, Specialization, Info)) { // FIXME: Keep track of almost-matches? (void)TDK; continue; } - + Matches.addDecl(Specialization, P.getAccess()); } - + // Find the most specialized function template specialization. UnresolvedSetIterator Result = getMostSpecialized(Matches.begin(), Matches.end(), TPOC_Other, 0, - D.getIdentifierLoc(), + D.getIdentifierLoc(), PDiag(diag::err_explicit_instantiation_not_known) << Name, PDiag(diag::err_explicit_instantiation_ambiguous) << Name, PDiag(diag::note_explicit_instantiation_candidate)); @@ -5776,17 +5776,17 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, // Ignore access control bits, we don't need them for redeclaration checking. FunctionDecl *Specialization = cast(*Result); - + if (Specialization->getTemplateSpecializationKind() == TSK_Undeclared) { - Diag(D.getIdentifierLoc(), + Diag(D.getIdentifierLoc(), diag::err_explicit_instantiation_member_function_not_instantiated) << Specialization << (Specialization->getTemplateSpecializationKind() == TSK_ExplicitSpecialization); Diag(Specialization->getLocation(), diag::note_explicit_instantiation_here); return true; - } - + } + FunctionDecl *PrevDecl = Specialization->getPreviousDeclaration(); if (!PrevDecl && Specialization->isThisDeclarationADefinition()) PrevDecl = Specialization; @@ -5794,12 +5794,12 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, if (PrevDecl) { bool HasNoEffect = false; if (CheckSpecializationInstantiationRedecl(D.getIdentifierLoc(), TSK, - PrevDecl, - PrevDecl->getTemplateSpecializationKind(), + PrevDecl, + PrevDecl->getTemplateSpecializationKind(), PrevDecl->getPointOfInstantiation(), HasNoEffect)) return true; - + // FIXME: We may still want to build some representation of this // explicit specialization. if (HasNoEffect) @@ -5807,12 +5807,12 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, } Specialization->setTemplateSpecializationKind(TSK, D.getIdentifierLoc()); - + if (TSK == TSK_ExplicitInstantiationDefinition) InstantiateFunctionDefinition(D.getIdentifierLoc(), Specialization); - + // C++0x [temp.explicit]p2: - // If the explicit instantiation is for a member function, a member class + // If the explicit instantiation is for a member function, a member class // or a static data member of a class template specialization, the name of // the class template specialization in the qualified-id for the member // name shall be a simple-template-id. @@ -5820,18 +5820,18 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, // C++98 has the same restriction, just worded differently. FunctionTemplateDecl *FunTmpl = Specialization->getPrimaryTemplate(); if (D.getName().getKind() != UnqualifiedId::IK_TemplateId && !FunTmpl && - D.getCXXScopeSpec().isSet() && + D.getCXXScopeSpec().isSet() && !ScopeSpecifierHasTemplateId(D.getCXXScopeSpec())) - Diag(D.getIdentifierLoc(), + Diag(D.getIdentifierLoc(), diag::ext_explicit_instantiation_without_qualified_id) << Specialization << D.getCXXScopeSpec().getRange(); - + CheckExplicitInstantiationScope(*this, - FunTmpl? (NamedDecl *)FunTmpl + FunTmpl? (NamedDecl *)FunTmpl : Specialization->getInstantiatedFromMemberFunction(), - D.getIdentifierLoc(), + D.getIdentifierLoc(), D.getCXXScopeSpec().isSet()); - + // FIXME: Create some kind of ExplicitInstantiationDecl here. return (Decl*) 0; } @@ -5861,8 +5861,8 @@ Sema::ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, } TypeResult -Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, - const CXXScopeSpec &SS, const IdentifierInfo &II, +Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, + const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc) { NestedNameSpecifier *NNS = static_cast(SS.getScopeRep()); @@ -5872,8 +5872,8 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, if (TypenameLoc.isValid() && S && !S->getTemplateParamParent() && !getLangOptions().CPlusPlus0x) Diag(TypenameLoc, diag::ext_typename_outside_of_template) - << FixItHint::CreateRemoval(TypenameLoc); - + << FixItHint::CreateRemoval(TypenameLoc); + QualType T = CheckTypenameType(ETK_Typename, NNS, II, TypenameLoc, SS.getRange(), IdLoc); if (T.isNull()) @@ -5891,23 +5891,23 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, TL.setQualifierRange(SS.getRange()); cast(TL.getNamedTypeLoc()).setNameLoc(IdLoc); } - + return CreateParsedType(T, TSI); } TypeResult -Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, - const CXXScopeSpec &SS, SourceLocation TemplateLoc, +Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, + const CXXScopeSpec &SS, SourceLocation TemplateLoc, ParsedType Ty) { if (TypenameLoc.isValid() && S && !S->getTemplateParamParent() && !getLangOptions().CPlusPlus0x) Diag(TypenameLoc, diag::ext_typename_outside_of_template) - << FixItHint::CreateRemoval(TypenameLoc); - + << FixItHint::CreateRemoval(TypenameLoc); + TypeSourceInfo *InnerTSI = 0; QualType T = GetTypeFromParser(Ty, &InnerTSI); - assert(isa(T) && + assert(isa(T) && "Expected a template specialization type"); if (computeDeclContext(SS, false)) { @@ -6019,13 +6019,13 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, } // Fall through to create a dependent typename type, from which we can recover // better. - + case LookupResult::NotFoundInCurrentInstantiation: // Okay, it's a member of an unknown instantiation. return Context.getDependentNameType(Keyword, NNS, &II); case LookupResult::Found: - if (TypeDecl *Type = dyn_cast(Result.getFoundDecl())) { + if (TypeDecl *Type = dyn_cast(Result.getFoundDecl())) { // We found a type. Build an ElaboratedType, since the // typename-specifier was just sugar. return Context.getElaboratedType(ETK_Typename, NNS, @@ -6036,7 +6036,7 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, Referenced = Result.getFoundDecl(); break; - + llvm_unreachable("unresolved using decl in non-dependent context"); return QualType(); @@ -6069,7 +6069,7 @@ namespace { public: typedef TreeTransform inherited; - + CurrentInstantiationRebuilder(Sema &SemaRef, SourceLocation Loc, DeclarationName Entity) @@ -6149,7 +6149,7 @@ bool Sema::RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS) { NestedNameSpecifier *NNS = static_cast(SS.getScopeRep()); CurrentInstantiationRebuilder Rebuilder(*this, SS.getRange().getBegin(), DeclarationName()); - NestedNameSpecifier *Rebuilt = + NestedNameSpecifier *Rebuilt = Rebuilder.TransformNestedNameSpecifier(NNS, SS.getRange()); if (!Rebuilt) return true; @@ -6174,22 +6174,22 @@ Sema::getTemplateArgumentBindingsText(const TemplateParameterList *Params, if (!Params || Params->size() == 0 || NumArgs == 0) return std::string(); - + for (unsigned I = 0, N = Params->size(); I != N; ++I) { if (I >= NumArgs) break; - + if (I == 0) Out << "[with "; else Out << ", "; - + if (const IdentifierInfo *Id = Params->getParam(I)->getIdentifier()) { Out << Id->getName(); } else { Out << '$' << I; } - + Out << " = "; Args[I].print(Context.PrintingPolicy, Out); } diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 1cad33360f..5a0359c5fd 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -51,7 +51,7 @@ namespace clang { /// may apply. TDF_SkipNonDependent = 0x08, /// \brief Whether we are performing template argument deduction for - /// parameters and arguments in a top-level template argument + /// parameters and arguments in a top-level template argument TDF_TopLevelParameterTypeList = 0x10 }; } @@ -90,21 +90,21 @@ DeduceTemplateArguments(Sema &S, /// \brief Whether template argument deduction for two reference parameters /// resulted in the argument type, parameter type, or neither type being more /// qualified than the other. -enum DeductionQualifierComparison { - NeitherMoreQualified = 0, - ParamMoreQualified, - ArgMoreQualified +enum DeductionQualifierComparison { + NeitherMoreQualified = 0, + ParamMoreQualified, + ArgMoreQualified }; /// \brief Stores the result of comparing two reference parameters while /// performing template argument deduction for partial ordering of function -/// templates. +/// templates. struct RefParamPartialOrderingComparison { /// \brief Whether the parameter type is an rvalue reference type. bool ParamIsRvalueRef; /// \brief Whether the argument type is an rvalue reference type. bool ArgIsRvalueRef; - + /// \brief Whether the parameter or argument (or neither) is more qualified. DeductionQualifierComparison Qualifiers; }; @@ -150,12 +150,12 @@ static NonTypeTemplateParmDecl *getDeducedParameterFromExpr(Expr *E) { static bool isSameDeclaration(Decl *X, Decl *Y) { if (!X || !Y) return !X && !Y; - + if (NamedDecl *NX = dyn_cast(X)) X = NX->getUnderlyingDecl(); if (NamedDecl *NY = dyn_cast(Y)) Y = NY->getUnderlyingDecl(); - + return X->getCanonicalDecl() == Y->getCanonicalDecl(); } @@ -163,7 +163,7 @@ static bool isSameDeclaration(Decl *X, Decl *Y) { /// /// \returns The deduced template argument, or a NULL template argument if /// the deduced template arguments were incompatible. -static DeducedTemplateArgument +static DeducedTemplateArgument checkDeducedTemplateArguments(ASTContext &Context, const DeducedTemplateArgument &X, const DeducedTemplateArgument &Y) { @@ -171,7 +171,7 @@ checkDeducedTemplateArguments(ASTContext &Context, if (X.isNull()) return Y; if (Y.isNull()) - return X; + return X; switch (X.getKind()) { case TemplateArgument::Null: @@ -182,9 +182,9 @@ checkDeducedTemplateArguments(ASTContext &Context, if (Y.getKind() == TemplateArgument::Type && Context.hasSameType(X.getAsType(), Y.getAsType())) return X; - + return DeducedTemplateArgument(); - + case TemplateArgument::Integral: // If we deduced a constant in one case and either a dependent expression or // declaration in another case, keep the integral constant. @@ -193,39 +193,39 @@ checkDeducedTemplateArguments(ASTContext &Context, Y.getKind() == TemplateArgument::Declaration || (Y.getKind() == TemplateArgument::Integral && hasSameExtendedValue(*X.getAsIntegral(), *Y.getAsIntegral()))) - return DeducedTemplateArgument(X, + return DeducedTemplateArgument(X, X.wasDeducedFromArrayBound() && Y.wasDeducedFromArrayBound()); // All other combinations are incompatible. return DeducedTemplateArgument(); - + case TemplateArgument::Template: if (Y.getKind() == TemplateArgument::Template && Context.hasSameTemplateName(X.getAsTemplate(), Y.getAsTemplate())) return X; - + // All other combinations are incompatible. - return DeducedTemplateArgument(); + return DeducedTemplateArgument(); case TemplateArgument::TemplateExpansion: if (Y.getKind() == TemplateArgument::TemplateExpansion && - Context.hasSameTemplateName(X.getAsTemplateOrTemplatePattern(), + Context.hasSameTemplateName(X.getAsTemplateOrTemplatePattern(), Y.getAsTemplateOrTemplatePattern())) return X; - + // All other combinations are incompatible. - return DeducedTemplateArgument(); + return DeducedTemplateArgument(); case TemplateArgument::Expression: - // If we deduced a dependent expression in one case and either an integral - // constant or a declaration in another case, keep the integral constant + // If we deduced a dependent expression in one case and either an integral + // constant or a declaration in another case, keep the integral constant // or declaration. if (Y.getKind() == TemplateArgument::Integral || Y.getKind() == TemplateArgument::Declaration) return DeducedTemplateArgument(Y, X.wasDeducedFromArrayBound() && Y.wasDeducedFromArrayBound()); - + if (Y.getKind() == TemplateArgument::Expression) { // Compare the expressions for equality llvm::FoldingSetNodeID ID1, ID2; @@ -234,49 +234,49 @@ checkDeducedTemplateArguments(ASTContext &Context, if (ID1 == ID2) return X; } - + // All other combinations are incompatible. return DeducedTemplateArgument(); - + case TemplateArgument::Declaration: // If we deduced a declaration and a dependent expression, keep the // declaration. if (Y.getKind() == TemplateArgument::Expression) return X; - + // If we deduced a declaration and an integral constant, keep the // integral constant. if (Y.getKind() == TemplateArgument::Integral) return Y; - + // If we deduced two declarations, make sure they they refer to the // same declaration. if (Y.getKind() == TemplateArgument::Declaration && isSameDeclaration(X.getAsDecl(), Y.getAsDecl())) return X; - + // All other combinations are incompatible. return DeducedTemplateArgument(); - + case TemplateArgument::Pack: if (Y.getKind() != TemplateArgument::Pack || X.pack_size() != Y.pack_size()) return DeducedTemplateArgument(); - - for (TemplateArgument::pack_iterator XA = X.pack_begin(), + + for (TemplateArgument::pack_iterator XA = X.pack_begin(), XAEnd = X.pack_end(), YA = Y.pack_begin(); XA != XAEnd; ++XA, ++YA) { - if (checkDeducedTemplateArguments(Context, - DeducedTemplateArgument(*XA, X.wasDeducedFromArrayBound()), + if (checkDeducedTemplateArguments(Context, + DeducedTemplateArgument(*XA, X.wasDeducedFromArrayBound()), DeducedTemplateArgument(*YA, Y.wasDeducedFromArrayBound())) .isNull()) return DeducedTemplateArgument(); } - + return X; } - + return DeducedTemplateArgument(); } @@ -293,16 +293,16 @@ DeduceNonTypeTemplateArgument(Sema &S, "Cannot deduce non-type template argument with depth > 0"); DeducedTemplateArgument NewDeduced(Value, ValueType, DeducedFromArrayBound); - DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, + DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, Deduced[NTTP->getIndex()], NewDeduced); if (Result.isNull()) { Info.Param = NTTP; Info.FirstArg = Deduced[NTTP->getIndex()]; Info.SecondArg = NewDeduced; - return Sema::TDK_Inconsistent; + return Sema::TDK_Inconsistent; } - + Deduced[NTTP->getIndex()] = Result; return Sema::TDK_Success; } @@ -323,17 +323,17 @@ DeduceNonTypeTemplateArgument(Sema &S, "Expression template argument must be type- or value-dependent."); DeducedTemplateArgument NewDeduced(Value); - DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, - Deduced[NTTP->getIndex()], + DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, + Deduced[NTTP->getIndex()], NewDeduced); - + if (Result.isNull()) { Info.Param = NTTP; Info.FirstArg = Deduced[NTTP->getIndex()]; Info.SecondArg = NewDeduced; - return Sema::TDK_Inconsistent; + return Sema::TDK_Inconsistent; } - + Deduced[NTTP->getIndex()] = Result; return Sema::TDK_Success; } @@ -350,18 +350,18 @@ DeduceNonTypeTemplateArgument(Sema &S, llvm::SmallVectorImpl &Deduced) { assert(NTTP->getDepth() == 0 && "Cannot deduce non-type template argument with depth > 0"); - + DeducedTemplateArgument NewDeduced(D? D->getCanonicalDecl() : 0); - DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, + DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, Deduced[NTTP->getIndex()], NewDeduced); if (Result.isNull()) { Info.Param = NTTP; Info.FirstArg = Deduced[NTTP->getIndex()]; Info.SecondArg = NewDeduced; - return Sema::TDK_Inconsistent; + return Sema::TDK_Inconsistent; } - + Deduced[NTTP->getIndex()] = Result; return Sema::TDK_Success; } @@ -379,28 +379,28 @@ DeduceTemplateArguments(Sema &S, // so there is nothing that we can deduce. return Sema::TDK_Success; } - + if (TemplateTemplateParmDecl *TempParam = dyn_cast(ParamDecl)) { DeducedTemplateArgument NewDeduced(S.Context.getCanonicalTemplateName(Arg)); - DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, + DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, Deduced[TempParam->getIndex()], NewDeduced); if (Result.isNull()) { Info.Param = TempParam; Info.FirstArg = Deduced[TempParam->getIndex()]; Info.SecondArg = NewDeduced; - return Sema::TDK_Inconsistent; + return Sema::TDK_Inconsistent; } - + Deduced[TempParam->getIndex()] = Result; - return Sema::TDK_Success; + return Sema::TDK_Success; } - + // Verify that the two template names are equivalent. if (S.Context.hasSameTemplateName(Param, Arg)) return Sema::TDK_Success; - + // Mismatch of non-dependent template parameter to argument. Info.FirstArg = TemplateArgument(Param); Info.SecondArg = TemplateArgument(Arg); @@ -449,8 +449,8 @@ DeduceTemplateArguments(Sema &S, // Perform template argument deduction on each template // argument. Ignore any missing/extra arguments, since they could be // filled in by default arguments. - return DeduceTemplateArguments(S, TemplateParams, - Param->getArgs(), Param->getNumArgs(), + return DeduceTemplateArguments(S, TemplateParams, + Param->getArgs(), Param->getNumArgs(), SpecArg->getArgs(), SpecArg->getNumArgs(), Info, Deduced, /*NumberOfArgumentsMustMatch=*/false); @@ -478,7 +478,7 @@ DeduceTemplateArguments(Sema &S, return Result; // Perform template argument deduction for the template arguments. - return DeduceTemplateArguments(S, TemplateParams, + return DeduceTemplateArguments(S, TemplateParams, Param->getArgs(), Param->getNumArgs(), SpecArg->getTemplateArgs().data(), SpecArg->getTemplateArgs().size(), @@ -510,25 +510,25 @@ static bool IsPossiblyOpaquelyQualifiedType(QualType T) { } /// \brief Retrieve the depth and index of a template parameter. -static std::pair +static std::pair getDepthAndIndex(NamedDecl *ND) { if (TemplateTypeParmDecl *TTP = dyn_cast(ND)) return std::make_pair(TTP->getDepth(), TTP->getIndex()); - + if (NonTypeTemplateParmDecl *NTTP = dyn_cast(ND)) return std::make_pair(NTTP->getDepth(), NTTP->getIndex()); - + TemplateTemplateParmDecl *TTP = cast(ND); return std::make_pair(TTP->getDepth(), TTP->getIndex()); } /// \brief Retrieve the depth and index of an unexpanded parameter pack. -static std::pair +static std::pair getDepthAndIndex(UnexpandedParameterPack UPP) { if (const TemplateTypeParmType *TTP = UPP.first.dyn_cast()) return std::make_pair(TTP->getDepth(), TTP->getIndex()); - + return getDepthAndIndex(UPP.first.get()); } @@ -539,16 +539,16 @@ static TemplateParameter makeTemplateParameter(Decl *D) { return TemplateParameter(TTP); else if (NonTypeTemplateParmDecl *NTTP = dyn_cast(D)) return TemplateParameter(NTTP); - + return TemplateParameter(cast(D)); } /// \brief Prepare to perform template argument deduction for all of the /// arguments in a set of argument packs. -static void PrepareArgumentPackDeduction(Sema &S, - llvm::SmallVectorImpl &Deduced, +static void PrepareArgumentPackDeduction(Sema &S, + llvm::SmallVectorImpl &Deduced, const llvm::SmallVectorImpl &PackIndices, - llvm::SmallVectorImpl &SavedPacks, + llvm::SmallVectorImpl &SavedPacks, llvm::SmallVectorImpl< llvm::SmallVector > &NewlyDeducedPacks) { // Save the deduced template arguments for each parameter pack expanded @@ -557,18 +557,18 @@ static void PrepareArgumentPackDeduction(Sema &S, // Save the previously-deduced argument pack, then clear it out so that we // can deduce a new argument pack. SavedPacks[I] = Deduced[PackIndices[I]]; - Deduced[PackIndices[I]] = TemplateArgument(); - + Deduced[PackIndices[I]] = TemplateArgument(); + // If the template arugment pack was explicitly specified, add that to // the set of deduced arguments. const TemplateArgument *ExplicitArgs; unsigned NumExplicitArgs; - if (NamedDecl *PartiallySubstitutedPack + if (NamedDecl *PartiallySubstitutedPack = S.CurrentInstantiationScope->getPartiallySubstitutedPack( &ExplicitArgs, &NumExplicitArgs)) { if (getDepthAndIndex(PartiallySubstitutedPack).second == PackIndices[I]) - NewlyDeducedPacks[I].append(ExplicitArgs, + NewlyDeducedPacks[I].append(ExplicitArgs, ExplicitArgs + NumExplicitArgs); } } @@ -581,9 +581,9 @@ static Sema::TemplateDeductionResult FinishArgumentPackDeduction(Sema &S, TemplateParameterList *TemplateParams, bool HasAnyArguments, - llvm::SmallVectorImpl &Deduced, + llvm::SmallVectorImpl &Deduced, const llvm::SmallVectorImpl &PackIndices, - llvm::SmallVectorImpl &SavedPacks, + llvm::SmallVectorImpl &SavedPacks, llvm::SmallVectorImpl< llvm::SmallVector > &NewlyDeducedPacks, TemplateDeductionInfo &Info) { @@ -596,9 +596,9 @@ FinishArgumentPackDeduction(Sema &S, Deduced[PackIndices[I]] = SavedPacks[I]; continue; } - + DeducedTemplateArgument NewPack; - + if (NewlyDeducedPacks[I].empty()) { // If we deduced an empty argument pack, create it now. NewPack = DeducedTemplateArgument(TemplateArgument(0, 0)); @@ -610,9 +610,9 @@ FinishArgumentPackDeduction(Sema &S, NewPack = DeducedTemplateArgument(TemplateArgument(ArgumentPack, NewlyDeducedPacks[I].size()), - NewlyDeducedPacks[I][0].wasDeducedFromArrayBound()); + NewlyDeducedPacks[I][0].wasDeducedFromArrayBound()); } - + DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, SavedPacks[I], NewPack); if (Result.isNull()) { @@ -622,16 +622,16 @@ FinishArgumentPackDeduction(Sema &S, Info.SecondArg = NewPack; return Sema::TDK_Inconsistent; } - + Deduced[PackIndices[I]] = Result; } - + return Sema::TDK_Success; } /// \brief Deduce the template arguments by comparing the list of parameter -/// types to the list of argument types, as in the parameter-type-lists of -/// function types (C++ [temp.deduct.type]p10). +/// types to the list of argument types, as in the parameter-type-lists of +/// function types (C++ [temp.deduct.type]p10). /// /// \param S The semantic analysis object within which we are deducing /// @@ -653,7 +653,7 @@ FinishArgumentPackDeduction(Sema &S, /// how template argument deduction is performed. /// /// \param PartialOrdering If true, we are performing template argument -/// deduction for during partial ordering for a call +/// deduction for during partial ordering for a call /// (C++0x [temp.deduct.partial]). /// /// \param RefParamComparisons If we're performing template argument deduction @@ -678,24 +678,24 @@ DeduceTemplateArguments(Sema &S, !(NumParams && isa(Params[NumParams - 1])) && !(NumArgs && isa(Args[NumArgs - 1]))) return Sema::TDK_NonDeducedMismatch; - + // C++0x [temp.deduct.type]p10: - // Similarly, if P has a form that contains (T), then each parameter type - // Pi of the respective parameter-type- list of P is compared with the - // corresponding parameter type Ai of the corresponding parameter-type-list - // of A. [...] + // Similarly, if P has a form that contains (T), then each parameter type + // Pi of the respective parameter-type- list of P is compared with the + // corresponding parameter type Ai of the corresponding parameter-type-list + // of A. [...] unsigned ArgIdx = 0, ParamIdx = 0; for (; ParamIdx != NumParams; ++ParamIdx) { // Check argument types. - const PackExpansionType *Expansion + const PackExpansionType *Expansion = dyn_cast(Params[ParamIdx]); if (!Expansion) { // Simple case: compare the parameter and argument types at this point. - + // Make sure we have an argument. if (ArgIdx >= NumArgs) return Sema::TDK_NonDeducedMismatch; - + if (isa(Args[ArgIdx])) { // C++0x [temp.deduct.type]p22: // If the original function parameter associated with A is a function @@ -703,7 +703,7 @@ DeduceTemplateArguments(Sema &S, // a function parameter pack, then template argument deduction fails. return Sema::TDK_NonDeducedMismatch; } - + if (Sema::TemplateDeductionResult Result = DeduceTemplateArguments(S, TemplateParams, Params[ParamIdx], @@ -712,25 +712,25 @@ DeduceTemplateArguments(Sema &S, PartialOrdering, RefParamComparisons)) return Result; - + ++ArgIdx; continue; } - + // C++0x [temp.deduct.type]p5: // The non-deduced contexts are: - // - A function parameter pack that does not occur at the end of the + // - A function parameter pack that does not occur at the end of the // parameter-declaration-clause. if (ParamIdx + 1 < NumParams) return Sema::TDK_Success; // C++0x [temp.deduct.type]p10: - // If the parameter-declaration corresponding to Pi is a function + // If the parameter-declaration corresponding to Pi is a function // parameter pack, then the type of its declarator- id is compared with - // each remaining parameter type in the parameter-type-list of A. Each + // each remaining parameter type in the parameter-type-list of A. Each // comparison deduces template arguments for subsequent positions in the // template parameter packs expanded by the function parameter pack. - + // Compute the set of template parameter indices that correspond to // parameter packs expanded by the pack expansion. llvm::SmallVector PackIndices; @@ -751,26 +751,26 @@ DeduceTemplateArguments(Sema &S, assert(!PackIndices.empty() && "Pack expansion without unexpanded packs?"); // Keep track of the deduced template arguments for each parameter pack - // expanded by this pack expansion (the outer index) and for each + // expanded by this pack expansion (the outer index) and for each // template argument (the inner SmallVectors). llvm::SmallVector, 2> NewlyDeducedPacks(PackIndices.size()); - llvm::SmallVector + llvm::SmallVector SavedPacks(PackIndices.size()); - PrepareArgumentPackDeduction(S, Deduced, PackIndices, SavedPacks, + PrepareArgumentPackDeduction(S, Deduced, PackIndices, SavedPacks, NewlyDeducedPacks); - + bool HasAnyArguments = false; for (; ArgIdx < NumArgs; ++ArgIdx) { HasAnyArguments = true; - + // Deduce template arguments from the pattern. - if (Sema::TemplateDeductionResult Result + if (Sema::TemplateDeductionResult Result = DeduceTemplateArguments(S, TemplateParams, Pattern, Args[ArgIdx], Info, Deduced, TDF, PartialOrdering, RefParamComparisons)) return Result; - + // Capture the deduced template arguments for each parameter pack expanded // by this pack expansion, add them to the list of arguments we've deduced // for that pack, then clear out the deduced argument. @@ -782,20 +782,20 @@ DeduceTemplateArguments(Sema &S, } } } - + // Build argument packs for each of the parameter packs expanded by this // pack expansion. if (Sema::TemplateDeductionResult Result - = FinishArgumentPackDeduction(S, TemplateParams, HasAnyArguments, + = FinishArgumentPackDeduction(S, TemplateParams, HasAnyArguments, Deduced, PackIndices, SavedPacks, NewlyDeducedPacks, Info)) - return Result; + return Result; } - + // Make sure we don't have any extra arguments. if (ArgIdx < NumArgs) return Sema::TDK_NonDeducedMismatch; - + return Sema::TDK_Success; } @@ -841,34 +841,34 @@ DeduceTemplateArguments(Sema &S, QualType Arg = S.Context.getCanonicalType(ArgIn); // If the argument type is a pack expansion, look at its pattern. - // This isn't explicitly called out + // This isn't explicitly called out if (const PackExpansionType *ArgExpansion = dyn_cast(Arg)) Arg = ArgExpansion->getPattern(); - + if (PartialOrdering) { // C++0x [temp.deduct.partial]p5: - // Before the partial ordering is done, certain transformations are - // performed on the types used for partial ordering: - // - If P is a reference type, P is replaced by the type referred to. + // Before the partial ordering is done, certain transformations are + // performed on the types used for partial ordering: + // - If P is a reference type, P is replaced by the type referred to. const ReferenceType *ParamRef = Param->getAs(); if (ParamRef) Param = ParamRef->getPointeeType(); - + // - If A is a reference type, A is replaced by the type referred to. const ReferenceType *ArgRef = Arg->getAs(); if (ArgRef) Arg = ArgRef->getPointeeType(); - + if (RefParamComparisons && ParamRef && ArgRef) { // C++0x [temp.deduct.partial]p6: - // If both P and A were reference types (before being replaced with the - // type referred to above), determine which of the two types (if any) is + // If both P and A were reference types (before being replaced with the + // type referred to above), determine which of the two types (if any) is // more cv-qualified than the other; otherwise the types are considered - // to be equally cv-qualified for partial ordering purposes. The result + // to be equally cv-qualified for partial ordering purposes. The result // of this determination will be used below. // - // We save this information for later, using it only when deduction + // We save this information for later, using it only when deduction // succeeds in both directions. RefParamPartialOrderingComparison Comparison; Comparison.ParamIsRvalueRef = ParamRef->getAs(); @@ -880,13 +880,13 @@ DeduceTemplateArguments(Sema &S, Comparison.Qualifiers = ArgMoreQualified; RefParamComparisons->push_back(Comparison); } - + // C++0x [temp.deduct.partial]p7: // Remove any top-level cv-qualifiers: - // - If P is a cv-qualified type, P is replaced by the cv-unqualified + // - If P is a cv-qualified type, P is replaced by the cv-unqualified // version of P. Param = Param.getUnqualifiedType(); - // - If A is a cv-qualified type, A is replaced by the cv-unqualified + // - If A is a cv-qualified type, A is replaced by the cv-unqualified // version of A. Arg = Arg.getUnqualifiedType(); } else { @@ -901,21 +901,21 @@ DeduceTemplateArguments(Sema &S, Arg.getCVRQualifiers()); Param = S.Context.getQualifiedType(UnqualParam, Quals); } - + if ((TDF & TDF_TopLevelParameterTypeList) && !Param->isFunctionType()) { // C++0x [temp.deduct.type]p10: // If P and A are function types that originated from deduction when // taking the address of a function template (14.8.2.2) or when deducing // template arguments from a function declaration (14.8.2.6) and Pi and - // Ai are parameters of the top-level parameter-type-list of P and A, - // respectively, Pi is adjusted if it is an rvalue reference to a - // cv-unqualified template parameter and Ai is an lvalue reference, in - // which case the type of Pi is changed to be the template parameter + // Ai are parameters of the top-level parameter-type-list of P and A, + // respectively, Pi is adjusted if it is an rvalue reference to a + // cv-unqualified template parameter and Ai is an lvalue reference, in + // which case the type of Pi is changed to be the template parameter // type (i.e., T&& is changed to simply T). [ Note: As a result, when // Pi is T&& and Ai is X&, the adjusted Pi will be T, causing T to be // deduced as X&. - end note ] TDF &= ~TDF_TopLevelParameterTypeList; - + if (const RValueReferenceType *ParamRef = Param->getAs()) { if (isa(ParamRef->getPointeeType()) && @@ -925,12 +925,12 @@ DeduceTemplateArguments(Sema &S, } } } - + // If the parameter type is not dependent, there is nothing to deduce. if (!Param->isDependentType()) { if (!(TDF & TDF_SkipNonDependent) && Param != Arg) return Sema::TDK_NonDeducedMismatch; - + return Sema::TDK_Success; } @@ -977,18 +977,18 @@ DeduceTemplateArguments(Sema &S, DeducedType = S.Context.getCanonicalType(DeducedType); DeducedTemplateArgument NewDeduced(DeducedType); - DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, + DeducedTemplateArgument Result = checkDeducedTemplateArguments(S.Context, Deduced[Index], NewDeduced); if (Result.isNull()) { Info.Param = cast(TemplateParams->getParam(Index)); Info.FirstArg = Deduced[Index]; Info.SecondArg = NewDeduced; - return Sema::TDK_Inconsistent; + return Sema::TDK_Inconsistent; } - + Deduced[Index] = Result; - return Sema::TDK_Success; + return Sema::TDK_Success; } // Set up the template argument deduction information for a failure. @@ -1125,7 +1125,7 @@ DeduceTemplateArguments(Sema &S, if (const ConstantArrayType *ConstantArrayArg = dyn_cast(ArrayArg)) { llvm::APSInt Size(ConstantArrayArg->getSize()); - return DeduceNonTypeTemplateArgument(S, NTTP, Size, + return DeduceNonTypeTemplateArgument(S, NTTP, Size, S.Context.getSizeType(), /*ArrayBound=*/true, Info, Deduced); @@ -1154,9 +1154,9 @@ DeduceTemplateArguments(Sema &S, const FunctionProtoType *FunctionProtoParam = cast(Param); - if (FunctionProtoParam->getTypeQuals() + if (FunctionProtoParam->getTypeQuals() != FunctionProtoArg->getTypeQuals() || - FunctionProtoParam->getRefQualifier() + FunctionProtoParam->getRefQualifier() != FunctionProtoArg->getRefQualifier() || FunctionProtoParam->isVariadic() != FunctionProtoArg->isVariadic()) return Sema::TDK_NonDeducedMismatch; @@ -1347,7 +1347,7 @@ DeduceTemplateArguments(Sema &S, // partial ordering. if (Arg.isPackExpansion()) Arg = Arg.getPackExpansionPattern(); - + switch (Param.getKind()) { case TemplateArgument::Null: assert(false && "Null template argument in parameter list"); @@ -1363,7 +1363,7 @@ DeduceTemplateArguments(Sema &S, case TemplateArgument::Template: if (Arg.getKind() == TemplateArgument::Template) - return DeduceTemplateArguments(S, TemplateParams, + return DeduceTemplateArguments(S, TemplateParams, Param.getAsTemplate(), Arg.getAsTemplate(), Info, Deduced); Info.FirstArg = Param; @@ -1373,13 +1373,13 @@ DeduceTemplateArguments(Sema &S, case TemplateArgument::TemplateExpansion: llvm_unreachable("caller should handle pack expansions"); break; - + case TemplateArgument::Declaration: if (Arg.getKind() == TemplateArgument::Declaration && Param.getAsDecl()->getCanonicalDecl() == Arg.getAsDecl()->getCanonicalDecl()) return Sema::TDK_Success; - + Info.FirstArg = Param; Info.SecondArg = Arg; return Sema::TDK_NonDeducedMismatch; @@ -1419,7 +1419,7 @@ DeduceTemplateArguments(Sema &S, if (Arg.getKind() == TemplateArgument::Declaration) return DeduceNonTypeTemplateArgument(S, NTTP, Arg.getAsDecl(), Info, Deduced); - + Info.FirstArg = Param; Info.SecondArg = Arg; return Sema::TDK_NonDeducedMismatch; @@ -1443,12 +1443,12 @@ DeduceTemplateArguments(Sema &S, /// /// \returns true if there is another template argument (which will be at /// \c Args[ArgIdx]), false otherwise. -static bool hasTemplateArgumentForDeduction(const TemplateArgument *&Args, +static bool hasTemplateArgumentForDeduction(const TemplateArgument *&Args, unsigned &ArgIdx, unsigned &NumArgs) { if (ArgIdx == NumArgs) return false; - + const TemplateArgument &Arg = Args[ArgIdx]; if (Arg.getKind() != TemplateArgument::Pack) return true; @@ -1467,7 +1467,7 @@ static bool hasPackExpansionBeforeEnd(const TemplateArgument *Args, unsigned ArgIdx = 0; while (ArgIdx < NumArgs) { const TemplateArgument &Arg = Args[ArgIdx]; - + // Unwrap argument packs. if (Args[ArgIdx].getKind() == TemplateArgument::Pack) { Args = Arg.pack_begin(); @@ -1475,15 +1475,15 @@ static bool hasPackExpansionBeforeEnd(const TemplateArgument *Args, ArgIdx = 0; continue; } - + ++ArgIdx; if (ArgIdx == NumArgs) return false; - + if (Arg.isPackExpansion()) return true; } - + return false; } @@ -1496,54 +1496,54 @@ DeduceTemplateArguments(Sema &S, llvm::SmallVectorImpl &Deduced, bool NumberOfArgumentsMustMatch) { // C++0x [temp.deduct.type]p9: - // If the template argument list of P contains a pack expansion that is not - // the last template argument, the entire template argument list is a + // If the template argument list of P contains a pack expansion that is not + // the last template argument, the entire template argument list is a // non-deduced context. if (hasPackExpansionBeforeEnd(Params, NumParams)) return Sema::TDK_Success; - + // C++0x [temp.deduct.type]p9: - // If P has a form that contains or , then each argument Pi of the - // respective template argument list P is compared with the corresponding + // If P has a form that contains or , then each argument Pi of the + // respective template argument list P is compared with the corresponding // argument Ai of the corresponding template argument list of A. unsigned ArgIdx = 0, ParamIdx = 0; - for (; hasTemplateArgumentForDeduction(Params, ParamIdx, NumParams); + for (; hasTemplateArgumentForDeduction(Params, ParamIdx, NumParams); ++ParamIdx) { if (!Params[ParamIdx].isPackExpansion()) { // The simple case: deduce template arguments by matching Pi and Ai. - + // Check whether we have enough arguments. if (!hasTemplateArgumentForDeduction(Args, ArgIdx, NumArgs)) return NumberOfArgumentsMustMatch? Sema::TDK_NonDeducedMismatch : Sema::TDK_Success; - + if (Args[ArgIdx].isPackExpansion()) { // FIXME: We follow the logic of C++0x [temp.deduct.type]p22 here, // but applied to pack expansions that are template arguments. return Sema::TDK_NonDeducedMismatch; } - + // Perform deduction for this Pi/Ai pair. if (Sema::TemplateDeductionResult Result = DeduceTemplateArguments(S, TemplateParams, Params[ParamIdx], Args[ArgIdx], Info, Deduced)) - return Result; - + return Result; + // Move to the next argument. ++ArgIdx; continue; } - + // The parameter is a pack expansion. - + // C++0x [temp.deduct.type]p9: - // If Pi is a pack expansion, then the pattern of Pi is compared with - // each remaining argument in the template argument list of A. Each - // comparison deduces template arguments for subsequent positions in the + // If Pi is a pack expansion, then the pattern of Pi is compared with + // each remaining argument in the template argument list of A. Each + // comparison deduces template arguments for subsequent positions in the // template parameter packs expanded by Pi. TemplateArgument Pattern = Params[ParamIdx].getPackExpansionPattern(); - + // Compute the set of template parameter indices that correspond to // parameter packs expanded by the pack expansion. llvm::SmallVector PackIndices; @@ -1561,33 +1561,33 @@ DeduceTemplateArguments(Sema &S, } } assert(!PackIndices.empty() && "Pack expansion without unexpanded packs?"); - + // FIXME: If there are no remaining arguments, we can bail out early // and set any deduced parameter packs to an empty argument pack. // The latter part of this is a (minor) correctness issue. - + // Save the deduced template arguments for each parameter pack expanded // by this pack expansion, then clear out the deduction. - llvm::SmallVector + llvm::SmallVector SavedPacks(PackIndices.size()); llvm::SmallVector, 2> NewlyDeducedPacks(PackIndices.size()); - PrepareArgumentPackDeduction(S, Deduced, PackIndices, SavedPacks, + PrepareArgumentPackDeduction(S, Deduced, PackIndices, SavedPacks, NewlyDeducedPacks); // Keep track of the deduced template arguments for each parameter pack - // expanded by this pack expansion (the outer index) and for each + // expanded by this pack expansion (the outer index) and for each // template argument (the inner SmallVectors). bool HasAnyArguments = false; while (hasTemplateArgumentForDeduction(Args, ArgIdx, NumArgs)) { HasAnyArguments = true; - + // Deduce template arguments from the pattern. - if (Sema::TemplateDeductionResult Result + if (Sema::TemplateDeductionResult Result = DeduceTemplateArguments(S, TemplateParams, Pattern, Args[ArgIdx], Info, Deduced)) return Result; - + // Capture the deduced template arguments for each parameter pack expanded // by this pack expansion, add them to the list of arguments we've deduced // for that pack, then clear out the deduced argument. @@ -1598,24 +1598,24 @@ DeduceTemplateArguments(Sema &S, DeducedArg = DeducedTemplateArgument(); } } - + ++ArgIdx; } - + // Build argument packs for each of the parameter packs expanded by this // pack expansion. if (Sema::TemplateDeductionResult Result - = FinishArgumentPackDeduction(S, TemplateParams, HasAnyArguments, + = FinishArgumentPackDeduction(S, TemplateParams, HasAnyArguments, Deduced, PackIndices, SavedPacks, NewlyDeducedPacks, Info)) - return Result; + return Result; } - + // If there is an argument remaining, then we had too many arguments. if (NumberOfArgumentsMustMatch && hasTemplateArgumentForDeduction(Args, ArgIdx, NumArgs)) return Sema::TDK_NonDeducedMismatch; - + return Sema::TDK_Success; } @@ -1626,7 +1626,7 @@ DeduceTemplateArguments(Sema &S, const TemplateArgumentList &ArgList, TemplateDeductionInfo &Info, llvm::SmallVectorImpl &Deduced) { - return DeduceTemplateArguments(S, TemplateParams, + return DeduceTemplateArguments(S, TemplateParams, ParamList.data(), ParamList.size(), ArgList.data(), ArgList.size(), Info, Deduced); @@ -1658,14 +1658,14 @@ static bool isSameTemplateArg(ASTContext &Context, X.getAsTemplateOrTemplatePattern()).getAsVoidPointer() == Context.getCanonicalTemplateName( Y.getAsTemplateOrTemplatePattern()).getAsVoidPointer(); - + case TemplateArgument::Integral: return *X.getAsIntegral() == *Y.getAsIntegral(); case TemplateArgument::Expression: { llvm::FoldingSetNodeID XID, YID; X.getAsExpr()->Profile(XID, Context, true); - Y.getAsExpr()->Profile(YID, Context, true); + Y.getAsExpr()->Profile(YID, Context, true); return XID == YID; } @@ -1700,33 +1700,33 @@ static bool isSameTemplateArg(ASTContext &Context, /// /// \param Loc The source location to use for the resulting template /// argument. -static TemplateArgumentLoc +static TemplateArgumentLoc getTrivialTemplateArgumentLoc(Sema &S, - const TemplateArgument &Arg, + const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc) { switch (Arg.getKind()) { case TemplateArgument::Null: llvm_unreachable("Can't get a NULL template argument here"); break; - + case TemplateArgument::Type: - return TemplateArgumentLoc(Arg, + return TemplateArgumentLoc(Arg, S.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc)); - + case TemplateArgument::Declaration: { Expr *E = S.BuildExpressionFromDeclTemplateArgument(Arg, NTTPType, Loc) .takeAs(); return TemplateArgumentLoc(TemplateArgument(E), E); } - + case TemplateArgument::Integral: { Expr *E = S.BuildExpressionFromIntegralTemplateArgument(Arg, Loc).takeAs(); return TemplateArgumentLoc(TemplateArgument(E), E); } - + case TemplateArgument::Template: return TemplateArgumentLoc(Arg, SourceRange(), Loc); @@ -1735,21 +1735,21 @@ getTrivialTemplateArgumentLoc(Sema &S, case TemplateArgument::Expression: return TemplateArgumentLoc(Arg, Arg.getAsExpr()); - + case TemplateArgument::Pack: return TemplateArgumentLoc(Arg, TemplateArgumentLocInfo()); } - + return TemplateArgumentLoc(); } /// \brief Convert the given deduced template argument and add it to the set of /// fully-converted template arguments. -static bool ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, +static bool ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, DeducedTemplateArgument Arg, - NamedDecl *Template, - QualType NTTPType, + NamedDecl *Template, + QualType NTTPType, unsigned ArgumentPackIndex, TemplateDeductionInfo &Info, bool InFunctionTemplate, @@ -1758,7 +1758,7 @@ static bool ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, // This is a template argument pack, so check each of its arguments against // the template parameter. llvm::SmallVector PackedArgsBuilder; - for (TemplateArgument::pack_iterator PA = Arg.pack_begin(), + for (TemplateArgument::pack_iterator PA = Arg.pack_begin(), PAEnd = Arg.pack_end(); PA != PAEnd; ++PA) { // When converting the deduced template argument, append it to the @@ -1766,29 +1766,29 @@ static bool ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, // checking logic has all of the prior template arguments available. DeducedTemplateArgument InnerArg(*PA); InnerArg.setDeducedFromArrayBound(Arg.wasDeducedFromArrayBound()); - if (ConvertDeducedTemplateArgument(S, Param, InnerArg, Template, + if (ConvertDeducedTemplateArgument(S, Param, InnerArg, Template, NTTPType, PackedArgsBuilder.size(), Info, InFunctionTemplate, Output)) return true; - + // Move the converted template argument into our argument pack. PackedArgsBuilder.push_back(Output.back()); Output.pop_back(); } - + // Create the resulting argument pack. - Output.push_back(TemplateArgument::CreatePackCopy(S.Context, + Output.push_back(TemplateArgument::CreatePackCopy(S.Context, PackedArgsBuilder.data(), PackedArgsBuilder.size())); return false; } - + // Convert the deduced template argument into a template // argument that we can check, almost as if the user had written // the template argument explicitly. TemplateArgumentLoc ArgLoc = getTrivialTemplateArgumentLoc(S, Arg, NTTPType, Info.getLocation()); - + // Check the template argument, converting it as necessary. return S.CheckTemplateArgument(Param, ArgLoc, Template, @@ -1798,7 +1798,7 @@ static bool ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, Output, InFunctionTemplate ? (Arg.wasDeducedFromArrayBound() - ? Sema::CTAK_DeducedFromArrayBound + ? Sema::CTAK_DeducedFromArrayBound : Sema::CTAK_Deduced) : Sema::CTAK_Specified); } @@ -1806,14 +1806,14 @@ static bool ConvertDeducedTemplateArgument(Sema &S, NamedDecl *Param, /// Complete template argument deduction for a class template partial /// specialization. static Sema::TemplateDeductionResult -FinishTemplateArgumentDeduction(Sema &S, +FinishTemplateArgumentDeduction(Sema &S, ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, llvm::SmallVectorImpl &Deduced, TemplateDeductionInfo &Info) { // Trap errors. Sema::SFINAETrap Trap(S); - + Sema::ContextRAII SavedContext(S, Partial); // C++ [temp.deduct.type]p2: @@ -1827,19 +1827,19 @@ FinishTemplateArgumentDeduction(Sema &S, Info.Param = makeTemplateParameter(Param); return Sema::TDK_Incomplete; } - + // We have deduced this argument, so it still needs to be // checked and converted. - + // First, for a non-type template parameter type that is // initialized by a declaration, we need the type of the // corresponding non-type template parameter. QualType NTTPType; - if (NonTypeTemplateParmDecl *NTTP + if (NonTypeTemplateParmDecl *NTTP = dyn_cast(Param)) { NTTPType = NTTP->getType(); if (NTTPType->isDependentType()) { - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, + TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Builder.data(), Builder.size()); NTTPType = S.SubstType(NTTPType, MultiLevelTemplateArgumentList(TemplateArgs), @@ -1848,8 +1848,8 @@ FinishTemplateArgumentDeduction(Sema &S, if (NTTPType.isNull()) { Info.Param = makeTemplateParameter(Param); // FIXME: These template arguments are temporary. Free them! - Info.reset(TemplateArgumentList::CreateCopy(S.Context, - Builder.data(), + Info.reset(TemplateArgumentList::CreateCopy(S.Context, + Builder.data(), Builder.size())); return Sema::TDK_SubstitutionFailure; } @@ -1861,15 +1861,15 @@ FinishTemplateArgumentDeduction(Sema &S, Builder)) { Info.Param = makeTemplateParameter(Param); // FIXME: These template arguments are temporary. Free them! - Info.reset(TemplateArgumentList::CreateCopy(S.Context, Builder.data(), - Builder.size())); + Info.reset(TemplateArgumentList::CreateCopy(S.Context, Builder.data(), + Builder.size())); return Sema::TDK_SubstitutionFailure; } } - + // Form the template argument list from the deduced template arguments. TemplateArgumentList *DeducedArgumentList - = TemplateArgumentList::CreateCopy(S.Context, Builder.data(), + = TemplateArgumentList::CreateCopy(S.Context, Builder.data(), Builder.size()); Info.reset(DeducedArgumentList); @@ -1906,7 +1906,7 @@ FinishTemplateArgumentDeduction(Sema &S, if (S.CheckTemplateArgumentList(ClassTemplate, Partial->getLocation(), InstArgs, false, ConvertedInstArgs)) return Sema::TDK_SubstitutionFailure; - + TemplateParameterList *TemplateParams = ClassTemplate->getTemplateParameters(); for (unsigned I = 0, E = TemplateParams->size(); I != E; ++I) { @@ -1954,8 +1954,8 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, if (Trap.hasErrorOccurred()) return Sema::TDK_SubstitutionFailure; - - return ::FinishTemplateArgumentDeduction(*this, Partial, TemplateArgs, + + return ::FinishTemplateArgumentDeduction(*this, Partial, TemplateArgs, Deduced, Info); } @@ -2056,14 +2056,14 @@ Sema::SubstituteExplicitTemplateArguments( TemplateArgumentList *ExplicitArgumentList = TemplateArgumentList::CreateCopy(Context, Builder.data(), Builder.size()); Info.reset(ExplicitArgumentList); - + // Template argument deduction and the final substitution should be // done in the context of the templated declaration. Explicit // argument substitution, on the other hand, needs to happen in the // calling context. ContextRAII SavedContext(*this, FunctionTemplate->getTemplatedDecl()); - // If we deduced template arguments for a template parameter pack, + // If we deduced template arguments for a template parameter pack, // note that the template argument pack is partially substituted and record // the explicit template arguments. They'll be used as part of deduction // for this template parameter pack. @@ -2071,7 +2071,7 @@ Sema::SubstituteExplicitTemplateArguments( const TemplateArgument &Arg = Builder[I]; if (Arg.getKind() == TemplateArgument::Pack) { CurrentInstantiationScope->SetPartiallySubstitutedPack( - TemplateParams->getParam(I), + TemplateParams->getParam(I), Arg.pack_begin(), Arg.pack_size()); break; @@ -2080,7 +2080,7 @@ Sema::SubstituteExplicitTemplateArguments( // Instantiate the types of each of the function parameters given the // explicitly-specified template arguments. - if (SubstParmTypes(Function->getLocation(), + if (SubstParmTypes(Function->getLocation(), Function->param_begin(), Function->getNumParams(), MultiLevelTemplateArgumentList(*ExplicitArgumentList), ParamTypes)) @@ -2169,11 +2169,11 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, llvm::SmallVector Builder; for (unsigned I = 0, N = TemplateParams->size(); I != N; ++I) { NamedDecl *Param = TemplateParams->getParam(I); - + if (!Deduced[I].isNull()) { if (I < NumExplicitlySpecified) { // We have already fully type-checked and converted this - // argument, because it was explicitly-specified. Just record the + // argument, because it was explicitly-specified. Just record the // presence of this argument. Builder.push_back(Deduced[I]); continue; @@ -2186,11 +2186,11 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, // initialized by a declaration, we need the type of the // corresponding non-type template parameter. QualType NTTPType; - if (NonTypeTemplateParmDecl *NTTP - = dyn_cast(Param)) { + if (NonTypeTemplateParmDecl *NTTP + = dyn_cast(Param)) { NTTPType = NTTP->getType(); if (NTTPType->isDependentType()) { - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, + TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Builder.data(), Builder.size()); NTTPType = SubstType(NTTPType, MultiLevelTemplateArgumentList(TemplateArgs), @@ -2199,8 +2199,8 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, if (NTTPType.isNull()) { Info.Param = makeTemplateParameter(Param); // FIXME: These template arguments are temporary. Free them! - Info.reset(TemplateArgumentList::CreateCopy(Context, - Builder.data(), + Info.reset(TemplateArgumentList::CreateCopy(Context, + Builder.data(), Builder.size())); return TDK_SubstitutionFailure; } @@ -2212,16 +2212,16 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, true, Builder)) { Info.Param = makeTemplateParameter(Param); // FIXME: These template arguments are temporary. Free them! - Info.reset(TemplateArgumentList::CreateCopy(Context, Builder.data(), - Builder.size())); + Info.reset(TemplateArgumentList::CreateCopy(Context, Builder.data(), + Builder.size())); return TDK_SubstitutionFailure; } continue; } - + // C++0x [temp.arg.explicit]p3: - // A trailing template parameter pack (14.5.3) not otherwise deduced will + // A trailing template parameter pack (14.5.3) not otherwise deduced will // be deduced to an empty sequence of template arguments. // FIXME: Where did the word "trailing" come from? if (Param->isTemplateParameterPack()) { @@ -2234,13 +2234,13 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, &NumExplicitArgs) == Param) Builder.push_back(TemplateArgument(ExplicitArgs, NumExplicitArgs)); - else + else Builder.push_back(TemplateArgument(0, 0)); - + continue; } - // Substitute into the default template argument, if available. + // Substitute into the default template argument, if available. TemplateArgumentLoc DefArg = SubstDefaultTemplateArgumentIfAvailable(FunctionTemplate, FunctionTemplate->getLocation(), @@ -2254,7 +2254,7 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, const_cast(TemplateParams->getParam(I))); return TDK_Incomplete; } - + // Check whether we can actually use the default argument. if (CheckTemplateArgument(Param, DefArg, FunctionTemplate, @@ -2265,7 +2265,7 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, Info.Param = makeTemplateParameter( const_cast(TemplateParams->getParam(I))); // FIXME: These template arguments are temporary. Free them! - Info.reset(TemplateArgumentList::CreateCopy(Context, Builder.data(), + Info.reset(TemplateArgumentList::CreateCopy(Context, Builder.data(), Builder.size())); return TDK_SubstitutionFailure; } @@ -2289,9 +2289,9 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, if (!Specialization) return TDK_SubstitutionFailure; - assert(Specialization->getPrimaryTemplate()->getCanonicalDecl() == + assert(Specialization->getPrimaryTemplate()->getCanonicalDecl() == FunctionTemplate->getCanonicalDecl()); - + // If the template argument list is owned by the function template // specialization, release it. if (Specialization->getTemplateSpecializationArgs() == DeducedArgumentList && @@ -2316,7 +2316,7 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, if (Pos == SuppressedDiagnostics.end()) SuppressedDiagnostics[Specialization->getCanonicalDecl()] .append(Info.diag_begin(), Info.diag_end()); - } + } return TDK_Success; } @@ -2348,7 +2348,7 @@ static QualType ResolveOverloadForDeduction(Sema &S, TemplateParameterList *TemplateParams, Expr *Arg, QualType ParamType, bool ParamWasReference) { - + OverloadExpr::FindResult R = OverloadExpr::find(Arg); OverloadExpr *Ovl = R.Expression; @@ -2396,10 +2396,10 @@ ResolveOverloadForDeduction(Sema &S, TemplateParameterList *TemplateParams, if (ArgType.isNull()) continue; // Function-to-pointer conversion. - if (!ParamWasReference && ParamType->isPointerType() && + if (!ParamWasReference && ParamType->isPointerType() && ArgType->isFunctionType()) ArgType = S.Context.getPointerType(ArgType); - + // - If the argument is an overload set (not containing function // templates), trial argument deduction is attempted using each // of the members of the set. If deduction succeeds for only one @@ -2412,7 +2412,7 @@ ResolveOverloadForDeduction(Sema &S, TemplateParameterList *TemplateParams, // Type deduction is done independently for each P/A pair, and // the deduced template argument values are then combined. // So we do not reject deductions which were made elsewhere. - llvm::SmallVector + llvm::SmallVector Deduced(TemplateParams->size()); TemplateDeductionInfo Info(S.Context, Ovl->getNameLoc()); Sema::TemplateDeductionResult Result @@ -2427,7 +2427,7 @@ ResolveOverloadForDeduction(Sema &S, TemplateParameterList *TemplateParams, return Match; } -/// \brief Perform the adjustments to the parameter and argument types +/// \brief Perform the adjustments to the parameter and argument types /// described in C++ [temp.deduct.call]. /// /// \returns true if the caller should not attempt to perform any template @@ -2461,7 +2461,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction(Sema &S, // for type deduction. ParamType = ParamRefType->getPointeeType(); } - + // Overload sets usually make this parameter an undeduced // context, but there are sometimes special circumstances. if (ArgType == S.Context.OverloadTy) { @@ -2471,7 +2471,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction(Sema &S, if (ArgType.isNull()) return true; } - + if (ParamRefType) { // C++0x [temp.deduct.call]p3: // [...] If P is of the form T&&, where T is a template parameter, and @@ -2501,13 +2501,13 @@ static bool AdjustFunctionParmAndArgTypesForDeduction(Sema &S, ArgType = ArgType.getUnqualifiedType(); } } - + // C++0x [temp.deduct.call]p4: // In general, the deduction process attempts to find template argument // values that will make the deduced A identical to A (after the type A // is transformed as described above). [...] TDF = TDF_SkipNonDependent; - + // - If the original P is a reference type, the deduced A (i.e., the // type referred to by the reference) can be more cv-qualified than // the transformed A. @@ -2529,7 +2529,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction(Sema &S, isSimpleTemplateIdType( ParamType->getAs()->getPointeeType()))) TDF |= TDF_DerivedClass; - + return false; } @@ -2549,7 +2549,7 @@ static bool AdjustFunctionParmAndArgTypesForDeduction(Sema &S, /// \param Name the name of the function being called. This is only significant /// when the function template is a conversion function template, in which /// case this routine will also perform template argument deduction based on -/// the function to which +/// the function to which /// /// \param Specialization if template argument deduction was successful, /// this will be set to the function template specialization produced by @@ -2581,7 +2581,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, /* Do nothing */; else if (Proto->isVariadic()) CheckArgs = Function->getNumParams(); - else + else return TDK_TooManyArguments; } @@ -2614,17 +2614,17 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, // Deduce template arguments from the function parameters. Deduced.resize(TemplateParams->size()); unsigned ArgIdx = 0; - for (unsigned ParamIdx = 0, NumParams = ParamTypes.size(); + for (unsigned ParamIdx = 0, NumParams = ParamTypes.size(); ParamIdx != NumParams; ++ParamIdx) { QualType ParamType = ParamTypes[ParamIdx]; - - const PackExpansionType *ParamExpansion + + const PackExpansionType *ParamExpansion = dyn_cast(ParamType); if (!ParamExpansion) { // Simple case: matching a function parameter to a function argument. if (ArgIdx >= CheckArgs) break; - + Expr *Arg = Args[ArgIdx++]; QualType ArgType = Arg->getType(); unsigned TDF = 0; @@ -2632,7 +2632,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, ParamType, ArgType, Arg, TDF)) continue; - + if (TemplateDeductionResult Result = ::DeduceTemplateArguments(*this, TemplateParams, ParamType, ArgType, Info, Deduced, @@ -2643,19 +2643,19 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, // modulo the various allowed differences. continue; } - + // C++0x [temp.deduct.call]p1: - // For a function parameter pack that occurs at the end of the - // parameter-declaration-list, the type A of each remaining argument of - // the call is compared with the type P of the declarator-id of the - // function parameter pack. Each comparison deduces template arguments - // for subsequent positions in the template parameter packs expanded by + // For a function parameter pack that occurs at the end of the + // parameter-declaration-list, the type A of each remaining argument of + // the call is compared with the type P of the declarator-id of the + // function parameter pack. Each comparison deduces template arguments + // for subsequent positions in the template parameter packs expanded by // the function parameter pack. For a function parameter pack that does - // not occur at the end of the parameter-declaration-list, the type of + // not occur at the end of the parameter-declaration-list, the type of // the parameter pack is a non-deduced context. if (ParamIdx + 1 < NumParams) break; - + QualType ParamPattern = ParamExpansion->getPattern(); llvm::SmallVector PackIndices; { @@ -2672,20 +2672,20 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, } } assert(!PackIndices.empty() && "Pack expansion without unexpanded packs?"); - + // Keep track of the deduced template arguments for each parameter pack - // expanded by this pack expansion (the outer index) and for each + // expanded by this pack expansion (the outer index) and for each // template argument (the inner SmallVectors). llvm::SmallVector, 2> NewlyDeducedPacks(PackIndices.size()); - llvm::SmallVector + llvm::SmallVector SavedPacks(PackIndices.size()); PrepareArgumentPackDeduction(*this, Deduced, PackIndices, SavedPacks, - NewlyDeducedPacks); + NewlyDeducedPacks); bool HasAnyArguments = false; for (; ArgIdx < NumArgs; ++ArgIdx) { HasAnyArguments = true; - + ParamType = ParamPattern; Expr *Arg = Args[ArgIdx]; QualType ArgType = Arg->getType(); @@ -2698,7 +2698,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, ++ArgIdx; break; } - + if (TemplateDeductionResult Result = ::DeduceTemplateArguments(*this, TemplateParams, ParamType, ArgType, Info, Deduced, @@ -2716,14 +2716,14 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, } } } - + // Build argument packs for each of the parameter packs expanded by this // pack expansion. if (Sema::TemplateDeductionResult Result - = FinishArgumentPackDeduction(*this, TemplateParams, HasAnyArguments, + = FinishArgumentPackDeduction(*this, TemplateParams, HasAnyArguments, Deduced, PackIndices, SavedPacks, NewlyDeducedPacks, Info)) - return Result; + return Result; // After we've matching against a parameter pack, we're done. break; @@ -2741,7 +2741,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, /// \param FunctionTemplate the function template for which we are performing /// template argument deduction. /// -/// \param ExplicitTemplateArguments the explicitly-specified template +/// \param ExplicitTemplateArguments the explicitly-specified template /// arguments. /// /// \param ArgFunctionType the function type that will be used as the @@ -2799,7 +2799,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, return Result; } - if (TemplateDeductionResult Result + if (TemplateDeductionResult Result = FinishTemplateArgumentDeduction(FunctionTemplate, Deduced, NumExplicitlySpecified, Specialization, Info)) @@ -2914,7 +2914,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, LocalInstantiationScope InstScope(*this); FunctionDecl *Spec = 0; TemplateDeductionResult Result - = FinishTemplateArgumentDeduction(FunctionTemplate, Deduced, 0, Spec, + = FinishTemplateArgumentDeduction(FunctionTemplate, Deduced, 0, Spec, Info); Specialization = cast_or_null(Spec); return Result; @@ -2926,7 +2926,7 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, /// \param FunctionTemplate the function template for which we are performing /// template argument deduction. /// -/// \param ExplicitTemplateArguments the explicitly-specified template +/// \param ExplicitTemplateArguments the explicitly-specified template /// arguments. /// /// \param Specialization if template argument deduction was successful, @@ -2951,8 +2951,8 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T, bool OnlyDeduced, unsigned Level, llvm::SmallVectorImpl &Deduced); - -/// \brief If this is a non-static member function, + +/// \brief If this is a non-static member function, static void MaybeAddImplicitObjectParameterType(ASTContext &Context, CXXMethodDecl *Method, llvm::SmallVectorImpl &ArgTypes) { @@ -2983,13 +2983,13 @@ static bool isAtLeastAsSpecializedAs(Sema &S, FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, TemplatePartialOrderingContext TPOC, - unsigned NumCallArguments, + unsigned NumCallArguments, llvm::SmallVectorImpl *RefParamComparisons) { FunctionDecl *FD1 = FT1->getTemplatedDecl(); - FunctionDecl *FD2 = FT2->getTemplatedDecl(); + FunctionDecl *FD2 = FT2->getTemplatedDecl(); const FunctionProtoType *Proto1 = FD1->getType()->getAs(); const FunctionProtoType *Proto2 = FD2->getType()->getAs(); - + assert(Proto1 && Proto2 && "Function templates must have prototypes"); TemplateParameterList *TemplateParams = FT2->getTemplateParameters(); llvm::SmallVector Deduced; @@ -3025,21 +3025,21 @@ static bool isAtLeastAsSpecializedAs(Sema &S, // first argument of the free function or static member, which // seems to match existing practice. llvm::SmallVector Args1; - unsigned Skip1 = !S.getLangOptions().CPlusPlus0x && + unsigned Skip1 = !S.getLangOptions().CPlusPlus0x && IsNonStatic2 && !IsNonStatic1; if (S.getLangOptions().CPlusPlus0x && IsNonStatic1 && !IsNonStatic2) - MaybeAddImplicitObjectParameterType(S.Context, Method1, Args1); - Args1.insert(Args1.end(), + MaybeAddImplicitObjectParameterType(S.Context, Method1, Args1); + Args1.insert(Args1.end(), Proto1->arg_type_begin() + Skip1, Proto1->arg_type_end()); llvm::SmallVector Args2; - Skip2 = !S.getLangOptions().CPlusPlus0x && + Skip2 = !S.getLangOptions().CPlusPlus0x && IsNonStatic1 && !IsNonStatic2; if (S.getLangOptions().CPlusPlus0x && IsNonStatic2 && !IsNonStatic1) MaybeAddImplicitObjectParameterType(S.Context, Method2, Args2); - Args2.insert(Args2.end(), + Args2.insert(Args2.end(), Proto2->arg_type_begin() + Skip2, Proto2->arg_type_end()); - + // C++ [temp.func.order]p5: // The presence of unused ellipsis and default arguments has no effect on // the partial ordering of function templates. @@ -3052,10 +3052,10 @@ static bool isAtLeastAsSpecializedAs(Sema &S, TDF_None, /*PartialOrdering=*/true, RefParamComparisons)) return false; - + break; } - + case TPOC_Conversion: // - In the context of a call to a conversion operator, the return types // of the conversion function templates are used. @@ -3065,23 +3065,23 @@ static bool isAtLeastAsSpecializedAs(Sema &S, RefParamComparisons)) return false; break; - + case TPOC_Other: // - In other contexts (14.6.6.2) the function template's function type // is used. // FIXME: Don't we actually want to perform the adjustments on the parameter // types? - if (DeduceTemplateArguments(S, TemplateParams, FD2->getType(), + if (DeduceTemplateArguments(S, TemplateParams, FD2->getType(), FD1->getType(), Info, Deduced, TDF_None, /*PartialOrdering=*/true, RefParamComparisons)) return false; break; } - + // C++0x [temp.deduct.partial]p11: - // In most cases, all template parameters must have values in order for - // deduction to succeed, but for partial ordering purposes a template - // parameter may remain without a value provided it is not used in the + // In most cases, all template parameters must have values in order for + // deduction to succeed, but for partial ordering purposes a template + // parameter may remain without a value provided it is not used in the // types being used for partial ordering. [ Note: a template parameter used // in a non-deduced context is considered used. -end note] unsigned ArgIdx = 0, NumArgs = Deduced.size(); @@ -3090,7 +3090,7 @@ static bool isAtLeastAsSpecializedAs(Sema &S, break; if (ArgIdx == NumArgs) { - // All template arguments were deduced. FT1 is at least as specialized + // All template arguments were deduced. FT1 is at least as specialized // as FT2. return true; } @@ -3100,41 +3100,41 @@ static bool isAtLeastAsSpecializedAs(Sema &S, UsedParameters.resize(TemplateParams->size()); switch (TPOC) { case TPOC_Call: { - unsigned NumParams = std::min(NumCallArguments, - std::min(Proto1->getNumArgs(), + unsigned NumParams = std::min(NumCallArguments, + std::min(Proto1->getNumArgs(), Proto2->getNumArgs())); if (S.getLangOptions().CPlusPlus0x && IsNonStatic2 && !IsNonStatic1) - ::MarkUsedTemplateParameters(S, Method2->getThisType(S.Context), false, + ::MarkUsedTemplateParameters(S, Method2->getThisType(S.Context), false, TemplateParams->getDepth(), UsedParameters); for (unsigned I = Skip2; I < NumParams; ++I) - ::MarkUsedTemplateParameters(S, Proto2->getArgType(I), false, + ::MarkUsedTemplateParameters(S, Proto2->getArgType(I), false, TemplateParams->getDepth(), UsedParameters); break; } - + case TPOC_Conversion: - ::MarkUsedTemplateParameters(S, Proto2->getResultType(), false, + ::MarkUsedTemplateParameters(S, Proto2->getResultType(), false, TemplateParams->getDepth(), UsedParameters); break; - + case TPOC_Other: - ::MarkUsedTemplateParameters(S, FD2->getType(), false, + ::MarkUsedTemplateParameters(S, FD2->getType(), false, TemplateParams->getDepth(), UsedParameters); break; } - + for (; ArgIdx != NumArgs; ++ArgIdx) // If this argument had no value deduced but was used in one of the types // used for partial ordering, then deduction fails. if (Deduced[ArgIdx].isNull() && UsedParameters[ArgIdx]) return false; - + return true; } - + /// \brief Determine whether this a function template whose parameter-type-list /// ends with a function parameter pack. static bool isVariadicFunctionTemplate(FunctionTemplateDecl *FunTmpl) { @@ -3142,20 +3142,20 @@ static bool isVariadicFunctionTemplate(FunctionTemplateDecl *FunTmpl) { unsigned NumParams = Function->getNumParams(); if (NumParams == 0) return false; - + ParmVarDecl *Last = Function->getParamDecl(NumParams - 1); if (!Last->isParameterPack()) return false; - + // Make sure that no previous parameter is a parameter pack. while (--NumParams > 0) { if (Function->getParamDecl(NumParams - 1)->isParameterPack()) return false; } - + return true; } - + /// \brief Returns the more specialized function template according /// to the rules of function template partial ordering (C++ [temp.func.order]). /// @@ -3178,22 +3178,22 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments) { llvm::SmallVector RefParamComparisons; - bool Better1 = isAtLeastAsSpecializedAs(*this, Loc, FT1, FT2, TPOC, + bool Better1 = isAtLeastAsSpecializedAs(*this, Loc, FT1, FT2, TPOC, NumCallArguments, 0); - bool Better2 = isAtLeastAsSpecializedAs(*this, Loc, FT2, FT1, TPOC, + bool Better2 = isAtLeastAsSpecializedAs(*this, Loc, FT2, FT1, TPOC, NumCallArguments, &RefParamComparisons); - + if (Better1 != Better2) // We have a clear winner return Better1? FT1 : FT2; - + if (!Better1 && !Better2) // Neither is better than the other return 0; // C++0x [temp.deduct.partial]p10: - // If for each type being considered a given template is at least as + // If for each type being considered a given template is at least as // specialized for all types and more specialized for some set of types and - // the other template is not more specialized for any types or is not at + // the other template is not more specialized for any types or is not at // least as specialized for any types, then the given template is more // specialized than the other template. Otherwise, neither template is more // specialized than the other. @@ -3206,7 +3206,7 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, // were reference types (before being replaced with the type referred to // above): - // -- if the type from the argument template was an lvalue reference + // -- if the type from the argument template was an lvalue reference // and the type from the parameter template was not, the argument // type is considered to be more specialized than the other; // otherwise, @@ -3223,7 +3223,7 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, return 0; continue; } - + // -- if the type from the argument template is more cv-qualified than // the type from the parameter template (as described above), the // argument type is considered to be more specialized than the @@ -3231,29 +3231,29 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, switch (RefParamComparisons[I].Qualifiers) { case NeitherMoreQualified: break; - + case ParamMoreQualified: Better1 = true; if (Better2) return 0; continue; - + case ArgMoreQualified: Better2 = true; if (Better1) return 0; continue; } - + // -- neither type is more specialized than the other. } - + assert(!(Better1 && Better2) && "Should have broken out in the loop above"); if (Better1) return FT1; else if (Better2) return FT2; - + // FIXME: This mimics what GCC implements, but doesn't match up with the // proposed resolution for core issue 692. This area needs to be sorted out, // but for now we attempt to maintain compatibility. @@ -3261,7 +3261,7 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, bool Variadic2 = isVariadicFunctionTemplate(FT2); if (Variadic1 != Variadic2) return Variadic1? FT2 : FT1; - + return 0; } @@ -3269,10 +3269,10 @@ Sema::getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, static bool isSameTemplate(TemplateDecl *T1, TemplateDecl *T2) { if (T1 == T2) return true; - + if (!T1 || !T2) return false; - + return T1->getCanonicalDecl() == T2->getCanonicalDecl(); } @@ -3291,7 +3291,7 @@ static bool isSameTemplate(TemplateDecl *T1, TemplateDecl *T2) { /// \param NumCallArguments The number of arguments in a call, used only /// when \c TPOC is \c TPOC_Call. /// -/// \param Loc the location where the ambiguity or no-specializations +/// \param Loc the location where the ambiguity or no-specializations /// diagnostic should occur. /// /// \param NoneDiag partial diagnostic used to diagnose cases where there are @@ -3305,14 +3305,14 @@ static bool isSameTemplate(TemplateDecl *T1, TemplateDecl *T2) { /// in this diagnostic should be unbound, which will correspond to the string /// describing the template arguments for the function template specialization. /// -/// \param Index if non-NULL and the result of this function is non-nULL, +/// \param Index if non-NULL and the result of this function is non-nULL, /// receives the index corresponding to the resulting function template /// specialization. /// -/// \returns the most specialized function template specialization, if +/// \returns the most specialized function template specialization, if /// found. Otherwise, returns SpecEnd. /// -/// \todo FIXME: Consider passing in the "also-ran" candidates that failed +/// \todo FIXME: Consider passing in the "also-ran" candidates that failed /// template argument deduction. UnresolvedSetIterator Sema::getMostSpecialized(UnresolvedSetIterator SpecBegin, @@ -3327,14 +3327,14 @@ Sema::getMostSpecialized(UnresolvedSetIterator SpecBegin, Diag(Loc, NoneDiag); return SpecEnd; } - - if (SpecBegin + 1 == SpecEnd) + + if (SpecBegin + 1 == SpecEnd) return SpecBegin; - + // Find the function template that is better than all of the templates it // has been compared to. UnresolvedSetIterator Best = SpecBegin; - FunctionTemplateDecl *BestTemplate + FunctionTemplateDecl *BestTemplate = cast(*Best)->getPrimaryTemplate(); assert(BestTemplate && "Not a function template specialization?"); for (UnresolvedSetIterator I = SpecBegin + 1; I != SpecEnd; ++I) { @@ -3348,7 +3348,7 @@ Sema::getMostSpecialized(UnresolvedSetIterator SpecBegin, BestTemplate = Challenger; } } - + // Make sure that the "best" function template is more specialized than all // of the others. bool Ambiguous = false; @@ -3356,29 +3356,29 @@ Sema::getMostSpecialized(UnresolvedSetIterator SpecBegin, FunctionTemplateDecl *Challenger = cast(*I)->getPrimaryTemplate(); if (I != Best && - !isSameTemplate(getMoreSpecializedTemplate(BestTemplate, Challenger, + !isSameTemplate(getMoreSpecializedTemplate(BestTemplate, Challenger, Loc, TPOC, NumCallArguments), BestTemplate)) { Ambiguous = true; break; } } - + if (!Ambiguous) { // We found an answer. Return it. return Best; } - + // Diagnose the ambiguity. Diag(Loc, AmbigDiag); - + // FIXME: Can we order the candidates in some sane way? for (UnresolvedSetIterator I = SpecBegin; I != SpecEnd; ++I) Diag((*I)->getLocation(), CandidateDiag) << getTemplateArgumentBindingsText( cast(*I)->getPrimaryTemplate()->getTemplateParameters(), *cast(*I)->getTemplateSpecializationArgs()); - + return SpecEnd; } @@ -3399,17 +3399,17 @@ Sema::getMoreSpecializedPartialSpecialization( SourceLocation Loc) { // C++ [temp.class.order]p1: // For two class template partial specializations, the first is at least as - // specialized as the second if, given the following rewrite to two - // function templates, the first function template is at least as - // specialized as the second according to the ordering rules for function + // specialized as the second if, given the following rewrite to two + // function templates, the first function template is at least as + // specialized as the second according to the ordering rules for function // templates (14.6.6.2): // - the first function template has the same template parameters as the - // first partial specialization and has a single function parameter - // whose type is a class template specialization with the template + // first partial specialization and has a single function parameter + // whose type is a class template specialization with the template // arguments of the first partial specialization, and // - the second function template has the same template parameters as the - // second partial specialization and has a single function parameter - // whose type is a class template specialization with the template + // second partial specialization and has a single function parameter + // whose type is a class template specialization with the template // arguments of the second partial specialization. // // Rather than synthesize function templates, we merely perform the @@ -3426,21 +3426,21 @@ Sema::getMoreSpecializedPartialSpecialization( QualType PT1 = PS1->getInjectedSpecializationType(); QualType PT2 = PS2->getInjectedSpecializationType(); - + // Determine whether PS1 is at least as specialized as PS2 Deduced.resize(PS2->getTemplateParameters()->size()); bool Better1 = !::DeduceTemplateArguments(*this, PS2->getTemplateParameters(), PT2, PT1, Info, Deduced, TDF_None, - /*PartialOrdering=*/true, + /*PartialOrdering=*/true, /*RefParamComparisons=*/0); if (Better1) { InstantiatingTemplate Inst(*this, PS2->getLocation(), PS2, Deduced.data(), Deduced.size(), Info); - Better1 = !::FinishTemplateArgumentDeduction(*this, PS2, - PS1->getTemplateArgs(), + Better1 = !::FinishTemplateArgumentDeduction(*this, PS2, + PS1->getTemplateArgs(), Deduced, Info); } - + // Determine whether PS2 is at least as specialized as PS1 Deduced.clear(); Deduced.resize(PS1->getTemplateParameters()->size()); @@ -3451,14 +3451,14 @@ Sema::getMoreSpecializedPartialSpecialization( if (Better2) { InstantiatingTemplate Inst(*this, PS1->getLocation(), PS1, Deduced.data(), Deduced.size(), Info); - Better2 = !::FinishTemplateArgumentDeduction(*this, PS1, - PS2->getTemplateArgs(), + Better2 = !::FinishTemplateArgumentDeduction(*this, PS1, + PS2->getTemplateArgs(), Deduced, Info); } - + if (Better1 == Better2) return 0; - + return Better1? PS1 : PS2; } @@ -3480,12 +3480,12 @@ MarkUsedTemplateParameters(Sema &SemaRef, // We can deduce from a pack expansion. if (const PackExpansionExpr *Expansion = dyn_cast(E)) E = Expansion->getPattern(); - + // Skip through any implicit casts we added while type-checking. while (const ImplicitCastExpr *ICE = dyn_cast(E)) E = ICE->getSubExpr(); - - // FIXME: if !OnlyDeduced, we have to walk the whole subexpression to + + // FIXME: if !OnlyDeduced, we have to walk the whole subexpression to // find other occurrences of template parameters. const DeclRefExpr *DRE = dyn_cast(E); if (!DRE) @@ -3510,13 +3510,13 @@ MarkUsedTemplateParameters(Sema &SemaRef, llvm::SmallVectorImpl &Used) { if (!NNS) return; - + MarkUsedTemplateParameters(SemaRef, NNS->getPrefix(), OnlyDeduced, Depth, Used); - MarkUsedTemplateParameters(SemaRef, QualType(NNS->getAsType(), 0), + MarkUsedTemplateParameters(SemaRef, QualType(NNS->getAsType(), 0), OnlyDeduced, Depth, Used); } - + /// \brief Mark the template parameters that are used by the given /// template name. static void @@ -3533,12 +3533,12 @@ MarkUsedTemplateParameters(Sema &SemaRef, } return; } - + if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) - MarkUsedTemplateParameters(SemaRef, QTN->getQualifier(), OnlyDeduced, + MarkUsedTemplateParameters(SemaRef, QTN->getQualifier(), OnlyDeduced, Depth, Used); if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) - MarkUsedTemplateParameters(SemaRef, DTN->getQualifier(), OnlyDeduced, + MarkUsedTemplateParameters(SemaRef, DTN->getQualifier(), OnlyDeduced, Depth, Used); } @@ -3551,7 +3551,7 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T, llvm::SmallVectorImpl &Used) { if (T.isNull()) return; - + // Non-dependent types have nothing deducible if (!T->isDependentType()) return; @@ -3617,7 +3617,7 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T, = cast(T); MarkUsedTemplateParameters(SemaRef, VecType->getElementType(), OnlyDeduced, Depth, Used); - MarkUsedTemplateParameters(SemaRef, VecType->getSizeExpr(), OnlyDeduced, + MarkUsedTemplateParameters(SemaRef, VecType->getSizeExpr(), OnlyDeduced, Depth, Used); break; } @@ -3642,7 +3642,7 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T, case Type::SubstTemplateTypeParmPack: { const SubstTemplateTypeParmPackType *Subst = cast(T); - MarkUsedTemplateParameters(SemaRef, + MarkUsedTemplateParameters(SemaRef, QualType(Subst->getReplacedParameter(), 0), OnlyDeduced, Depth, Used); MarkUsedTemplateParameters(SemaRef, Subst->getArgumentPack(), @@ -3659,12 +3659,12 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T, = cast(T); MarkUsedTemplateParameters(SemaRef, Spec->getTemplateName(), OnlyDeduced, Depth, Used); - + // C++0x [temp.deduct.type]p9: - // If the template argument list of P contains a pack expansion that is not - // the last template argument, the entire template argument list is a + // If the template argument list of P contains a pack expansion that is not + // the last template argument, the entire template argument list is a // non-deduced context. - if (OnlyDeduced && + if (OnlyDeduced && hasPackExpansionBeforeEnd(Spec->getArgs(), Spec->getNumArgs())) break; @@ -3676,7 +3676,7 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T, case Type::Complex: if (!OnlyDeduced) - MarkUsedTemplateParameters(SemaRef, + MarkUsedTemplateParameters(SemaRef, cast(T)->getElementType(), OnlyDeduced, Depth, Used); break; @@ -3694,12 +3694,12 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T, if (!OnlyDeduced) MarkUsedTemplateParameters(SemaRef, Spec->getQualifier(), OnlyDeduced, Depth, Used); - + // C++0x [temp.deduct.type]p9: - // If the template argument list of P contains a pack expansion that is not - // the last template argument, the entire template argument list is a + // If the template argument list of P contains a pack expansion that is not + // the last template argument, the entire template argument list is a // non-deduced context. - if (OnlyDeduced && + if (OnlyDeduced && hasPackExpansionBeforeEnd(Spec->getArgs(), Spec->getNumArgs())) break; @@ -3731,7 +3731,7 @@ MarkUsedTemplateParameters(Sema &SemaRef, QualType T, break; case Type::PackExpansion: - MarkUsedTemplateParameters(SemaRef, + MarkUsedTemplateParameters(SemaRef, cast(T)->getPattern(), OnlyDeduced, Depth, Used); break; @@ -3776,16 +3776,16 @@ MarkUsedTemplateParameters(Sema &SemaRef, case TemplateArgument::Template: case TemplateArgument::TemplateExpansion: - MarkUsedTemplateParameters(SemaRef, - TemplateArg.getAsTemplateOrTemplatePattern(), + MarkUsedTemplateParameters(SemaRef, + TemplateArg.getAsTemplateOrTemplatePattern(), OnlyDeduced, Depth, Used); break; case TemplateArgument::Expression: - MarkUsedTemplateParameters(SemaRef, TemplateArg.getAsExpr(), OnlyDeduced, + MarkUsedTemplateParameters(SemaRef, TemplateArg.getAsExpr(), OnlyDeduced, Depth, Used); break; - + case TemplateArgument::Pack: for (TemplateArgument::pack_iterator P = TemplateArg.pack_begin(), PEnd = TemplateArg.pack_end(); @@ -3809,28 +3809,28 @@ Sema::MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs, bool OnlyDeduced, unsigned Depth, llvm::SmallVectorImpl &Used) { // C++0x [temp.deduct.type]p9: - // If the template argument list of P contains a pack expansion that is not - // the last template argument, the entire template argument list is a + // If the template argument list of P contains a pack expansion that is not + // the last template argument, the entire template argument list is a // non-deduced context. - if (OnlyDeduced && + if (OnlyDeduced && hasPackExpansionBeforeEnd(TemplateArgs.data(), TemplateArgs.size())) return; for (unsigned I = 0, N = TemplateArgs.size(); I != N; ++I) - ::MarkUsedTemplateParameters(*this, TemplateArgs[I], OnlyDeduced, + ::MarkUsedTemplateParameters(*this, TemplateArgs[I], OnlyDeduced, Depth, Used); } /// \brief Marks all of the template parameters that will be deduced by a /// call to the given function template. -void +void Sema::MarkDeducedTemplateParameters(FunctionTemplateDecl *FunctionTemplate, llvm::SmallVectorImpl &Deduced) { - TemplateParameterList *TemplateParams + TemplateParameterList *TemplateParams = FunctionTemplate->getTemplateParameters(); Deduced.clear(); Deduced.resize(TemplateParams->size()); - + FunctionDecl *Function = FunctionTemplate->getTemplatedDecl(); for (unsigned I = 0, N = Function->getNumParams(); I != N; ++I) ::MarkUsedTemplateParameters(*this, Function->getParamDecl(I)->getType(), diff --git a/lib/StaticAnalyzer/BasicStore.cpp b/lib/StaticAnalyzer/BasicStore.cpp index 64de19da53..abeac0d00c 100644 --- a/lib/StaticAnalyzer/BasicStore.cpp +++ b/lib/StaticAnalyzer/BasicStore.cpp @@ -592,4 +592,3 @@ Store BasicStoreManager::InvalidateRegion(Store store, SVal V = svalBuilder.getConjuredSymbolVal(R, E, T, Count); return Bind(store, loc::MemRegionVal(R), V); } -