diff options
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 233 |
1 files changed, 111 insertions, 122 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 12f60b99c6..3943ce103e 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -35,7 +35,7 @@ Sema::ActOnCXXConversionFunctionExpr(Scope *S, SourceLocation OperatorLoc, //FIXME: Preserve type source info. QualType ConvType = GetTypeFromParser(Ty); CanQualType ConvTypeCanon = Context.getCanonicalType(ConvType); - DeclarationName ConvName + DeclarationName ConvName = Context.DeclarationNames.getCXXConversionFunctionName(ConvTypeCanon); return ActOnDeclarationNameExpr(S, OperatorLoc, ConvName, HasTrailingLParen, &SS, isAddressOfOperand); @@ -79,10 +79,10 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, if (!isType) { // C++0x [expr.typeid]p3: - // When typeid is applied to an expression other than an lvalue of a - // polymorphic class type [...] [the] expression is an unevaluated + // When typeid is applied to an expression other than an lvalue of a + // polymorphic class type [...] [the] expression is an unevaluated // operand. - + // FIXME: if the type of the expression is a class type, the class // shall be completely defined. bool isUnevaluatedOperand = true; @@ -95,13 +95,13 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, isUnevaluatedOperand = false; } } - + // If this is an unevaluated operand, clear out the set of declaration // references we have been computing. if (isUnevaluatedOperand) PotentiallyReferencedDeclStack.back().clear(); } - + return Owned(new (Context) CXXTypeidExpr(isType, TyOrExpr, TypeInfoType.withConst(), SourceRange(OpLoc, RParenLoc))); @@ -195,9 +195,9 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, if (Ty->isDependentType() || CallExpr::hasAnyTypeDependentArguments(Exprs, NumExprs)) { exprs.release(); - - return Owned(CXXUnresolvedConstructExpr::Create(Context, - TypeRange.getBegin(), Ty, + + return Owned(CXXUnresolvedConstructExpr::Create(Context, + TypeRange.getBegin(), Ty, LParenLoc, Exprs, NumExprs, RParenLoc)); @@ -211,12 +211,12 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, PDiag(diag::err_invalid_incomplete_type_use) << FullRange)) return ExprError(); - + if (RequireNonAbstractType(TyBeginLoc, Ty, diag::err_allocation_of_abstract_type)) return ExprError(); - - + + // C++ [expr.type.conv]p1: // If the expression list is a single expression, the type conversion // expression is equivalent (in definedness, and if defined in meaning) to the @@ -232,9 +232,9 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, if (!ConversionDecl || !isa<CXXConstructorDecl>(ConversionDecl)) { exprs.release(); return Owned(new (Context) CXXFunctionalCastExpr(Ty.getNonReferenceType(), - Ty, TyBeginLoc, + Ty, TyBeginLoc, CastExpr::CK_UserDefinedConversion, - Exprs[0], ConversionDecl, + Exprs[0], ConversionDecl, RParenLoc)); } } @@ -242,7 +242,7 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, if (const RecordType *RT = Ty->getAs<RecordType>()) { CXXRecordDecl *Record = cast<CXXRecordDecl>(RT->getDecl()); - if (NumExprs > 1 || !Record->hasTrivialConstructor() || + if (NumExprs > 1 || !Record->hasTrivialConstructor() || !Record->hasTrivialDestructor()) { CXXConstructorDecl *Constructor = PerformInitializationByConstructor(Ty, Exprs, NumExprs, @@ -255,12 +255,12 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, if (!Constructor) return ExprError(); - OwningExprResult Result = - BuildCXXTemporaryObjectExpr(Constructor, Ty, TyBeginLoc, + OwningExprResult Result = + BuildCXXTemporaryObjectExpr(Constructor, Ty, TyBeginLoc, move(exprs), RParenLoc); if (Result.isInvalid()) return ExprError(); - + return MaybeBindToTemporary(Result.takeAs<Expr>()); } @@ -300,8 +300,7 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementRParen, bool ParenTypeId, Declarator &D, SourceLocation ConstructorLParen, MultiExprArg ConstructorArgs, - SourceLocation ConstructorRParen) -{ + SourceLocation ConstructorRParen) { Expr *ArraySize = 0; unsigned Skip = 0; // If the specified type is an array, unwrap it and save the expression. @@ -337,12 +336,12 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, ++i; } - return BuildCXXNew(StartLoc, UseGlobal, + return BuildCXXNew(StartLoc, UseGlobal, PlacementLParen, - move(PlacementArgs), + move(PlacementArgs), PlacementRParen, ParenTypeId, - AllocType, + AllocType, D.getSourceRange().getBegin(), D.getSourceRange(), Owned(ArraySize), @@ -351,12 +350,12 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, ConstructorRParen); } -Sema::OwningExprResult +Sema::OwningExprResult Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, - bool ParenTypeId, + bool ParenTypeId, QualType AllocType, SourceLocation TypeLoc, SourceRange TypeRange, @@ -472,15 +471,14 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, return Owned(new (Context) CXXNewExpr(UseGlobal, OperatorNew, PlaceArgs, NumPlaceArgs, ParenTypeId, ArraySize, Constructor, Init, ConsArgs, NumConsArgs, OperatorDelete, ResultType, - StartLoc, Init ? ConstructorRParen : SourceLocation())); + StartLoc, Init ? ConstructorRParen : SourceLocation())); } /// CheckAllocatedType - Checks that a type is suitable as the allocated type /// in a new-expression. /// dimension off and stores the size expression in ArraySize. bool Sema::CheckAllocatedType(QualType AllocType, SourceLocation Loc, - SourceRange R) -{ + SourceRange R) { // C++ 5.3.4p1: "[The] type shall be a complete object type, but not an // abstract class type or array thereof. if (AllocType->isFunctionType()) @@ -508,8 +506,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, bool IsArray, Expr **PlaceArgs, unsigned NumPlaceArgs, FunctionDecl *&OperatorNew, - FunctionDecl *&OperatorDelete) -{ + FunctionDecl *&OperatorDelete) { // --- Choosing an allocation function --- // C++ 5.3.4p8 - 14 & 18 // 1) If UseGlobal is true, only look in the global scope. Else, also look @@ -534,7 +531,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, DeclarationName NewName = Context.DeclarationNames.getCXXOperatorName( IsArray ? OO_Array_New : OO_New); if (AllocType->isRecordType() && !UseGlobal) { - CXXRecordDecl *Record + CXXRecordDecl *Record = cast<CXXRecordDecl>(AllocType->getAs<RecordType>()->getDecl()); // FIXME: We fail to find inherited overloads. if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], @@ -556,7 +553,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // copy them back. if (NumPlaceArgs > 0) std::copy(&AllocArgs[1], AllocArgs.end(), PlaceArgs); - + return false; } @@ -565,8 +562,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, DeclarationName Name, Expr** Args, unsigned NumArgs, DeclContext *Ctx, - bool AllowMissing, FunctionDecl *&Operator) -{ + bool AllowMissing, FunctionDecl *&Operator) { DeclContext::lookup_iterator Alloc, AllocEnd; llvm::tie(Alloc, AllocEnd) = Ctx->lookup(Name); if (Alloc == AllocEnd) { @@ -639,8 +635,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, /// @endcode /// Note that the placement and nothrow forms of new are *not* implicitly /// declared. Their use requires including \<new\>. -void Sema::DeclareGlobalNewDelete() -{ +void Sema::DeclareGlobalNewDelete() { if (GlobalNewDeleteDeclared) return; GlobalNewDeleteDeclared = true; @@ -666,8 +661,7 @@ void Sema::DeclareGlobalNewDelete() /// DeclareGlobalAllocationFunction - Declares a single implicit global /// allocation function if it doesn't already exist. void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, - QualType Return, QualType Argument) -{ + QualType Return, QualType Argument) { DeclContext *GlobalCtx = Context.getTranslationUnitDecl(); // Check if this function is already declared. @@ -705,15 +699,14 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, /// @code delete [] ptr; @endcode Action::OwningExprResult Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, - bool ArrayForm, ExprArg Operand) -{ + bool ArrayForm, ExprArg Operand) { // C++ 5.3.5p1: "The operand shall have a pointer type, or a class type // having a single conversion function to a pointer type. The result has // type void." // DR599 amends "pointer type" to "pointer to object type" in both cases. FunctionDecl *OperatorDelete = 0; - + Expr *Ex = (Expr *)Operand.get(); if (!Ex->isTypeDependent()) { QualType Type = Ex->getType(); @@ -731,12 +724,12 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, return ExprError(Diag(StartLoc, diag::err_delete_operand) << Type << Ex->getSourceRange()); else if (!Pointee->isDependentType() && - RequireCompleteType(StartLoc, Pointee, + RequireCompleteType(StartLoc, Pointee, PDiag(diag::warn_delete_incomplete) << Ex->getSourceRange())) return ExprError(); - // FIXME: This should be shared with the code for finding the delete + // FIXME: This should be shared with the code for finding the delete // operator in ActOnCXXNew. IntegerLiteral Size(llvm::APInt::getNullValue( Context.Target.getPointerWidth(0)), @@ -745,12 +738,12 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, ImplicitCastExpr Cast(Context.getPointerType(Context.VoidTy), CastExpr::CK_Unknown, &Size, false); Expr *DeleteArg = &Cast; - + DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName( ArrayForm ? OO_Array_Delete : OO_Delete); if (Pointee->isRecordType() && !UseGlobal) { - CXXRecordDecl *Record + CXXRecordDecl *Record = cast<CXXRecordDecl>(Pointee->getAs<RecordType>()->getDecl()); // FIXME: We fail to find inherited overloads. if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName, @@ -759,20 +752,20 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, return ExprError(); if (!Record->hasTrivialDestructor()) if (const CXXDestructorDecl *Dtor = Record->getDestructor(Context)) - MarkDeclarationReferenced(StartLoc, + MarkDeclarationReferenced(StartLoc, const_cast<CXXDestructorDecl*>(Dtor)); } - + if (!OperatorDelete) { // Didn't find a member overload. Look for a global one. DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); - if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName, + if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName, &DeleteArg, 1, TUDecl, /*AllowMissing=*/false, OperatorDelete)) return ExprError(); } - + // FIXME: Check access and ambiguity of operator delete and destructor. } @@ -804,7 +797,7 @@ Sema::ActOnCXXConditionDeclarationExpr(Scope *S, SourceLocation StartLoc, DeclaratorInfo *DInfo = 0; TagDecl *OwnedTag = 0; QualType Ty = GetTypeForDeclarator(D, S, &DInfo, /*Skip=*/0, &OwnedTag); - + if (Ty->isFunctionType()) { // The declarator shall not specify a function... // We exit without creating a CXXConditionDeclExpr because a FunctionDecl // would be created and CXXConditionDeclExpr wants a VarDecl. @@ -848,7 +841,7 @@ bool Sema::CheckCXXBooleanCondition(Expr *&CondExpr) { /// conversion from a string literal to a pointer to non-const char or /// non-const wchar_t (for narrow and wide string literals, /// respectively). -bool +bool Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) { // Look inside the implicit cast, if it exists. if (ImplicitCastExpr *Cast = dyn_cast<ImplicitCastExpr>(From)) @@ -860,7 +853,7 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) { // to wchar_t" (C++ 4.2p2). if (StringLiteral *StrLit = dyn_cast<StringLiteral>(From)) if (const PointerType *ToPtrType = ToType->getAs<PointerType>()) - if (const BuiltinType *ToPointeeType + if (const BuiltinType *ToPointeeType = ToPtrType->getPointeeType()->getAsBuiltinType()) { // This conversion is considered only when there is an // explicit appropriate pointer target type (C++ 4.2p2). @@ -886,19 +879,18 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) { bool Sema::PerformImplicitConversion(Expr *&From, QualType ToType, const char *Flavor, bool AllowExplicit, - bool Elidable) -{ + bool Elidable) { ImplicitConversionSequence ICS; ICS.ConversionKind = ImplicitConversionSequence::BadConversion; if (Elidable && getLangOptions().CPlusPlus0x) { - ICS = TryImplicitConversion(From, ToType, + ICS = TryImplicitConversion(From, ToType, /*SuppressUserConversions=*/false, - AllowExplicit, + AllowExplicit, /*ForceRValue=*/true, /*InOverloadResolution=*/false); } if (ICS.ConversionKind == ImplicitConversionSequence::BadConversion) { - ICS = TryImplicitConversion(From, ToType, + ICS = TryImplicitConversion(From, ToType, /*SuppressUserConversions=*/false, AllowExplicit, /*ForceRValue=*/false, @@ -929,9 +921,9 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, CastExpr::CastKind CastKind = CastExpr::CK_Unknown; if (CXXConversionDecl *CV = dyn_cast<CXXConversionDecl>(FD)) { // FIXME. Get actual Source Location. - From = + From = new (Context) CXXFunctionalCastExpr(ToType.getNonReferenceType(), - ToType, SourceLocation(), + ToType, SourceLocation(), CastExpr::CK_UserDefinedConversion, From, CV, SourceLocation()); @@ -940,9 +932,9 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, else if (CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) { // FIXME. Do we need to check for isLValueReferenceType? DefaultFunctionArrayConversion(From); - OwningExprResult InitResult = + OwningExprResult InitResult = BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(), - ToType.getNonReferenceType(), CD, + ToType.getNonReferenceType(), CD, MultiExprArg(*this, (void**)&From, 1)); // Take ownership of this expression. From = InitResult.takeAs<Expr>(); @@ -972,7 +964,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, /// otherwise. The expression From is replaced with the converted /// expression. Flavor is the context in which we're performing this /// conversion, for use in error messages. -bool +bool Sema::PerformImplicitConversion(Expr *&From, QualType ToType, const StandardConversionSequence& SCS, const char *Flavor) { @@ -985,15 +977,15 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, if (SCS.CopyConstructor) { // FIXME: When can ToType be a reference type? assert(!ToType->isReferenceType()); - - OwningExprResult FromResult = - BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(), - ToType, SCS.CopyConstructor, + + OwningExprResult FromResult = + BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(), + ToType, SCS.CopyConstructor, MultiExprArg(*this, (void**)&From, 1)); - + if (FromResult.isInvalid()) return true; - + From = FromResult.takeAs<Expr>(); return false; } @@ -1054,7 +1046,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, case ICK_Pointer_Conversion: if (SCS.IncompatibleObjC) { // Diagnose incompatible Objective-C conversions - Diag(From->getSourceRange().getBegin(), + Diag(From->getSourceRange().getBegin(), diag::ext_typecheck_convert_incompatible_pointer) << From->getType() << ToType << Flavor << From->getSourceRange(); @@ -1090,7 +1082,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, case ICK_Qualification: // FIXME: Not sure about lvalue vs rvalue here in the presence of rvalue // references. - ImpCastExprToType(From, ToType.getNonReferenceType(), + ImpCastExprToType(From, ToType.getNonReferenceType(), CastExpr::CK_Unknown, ToType->isLValueReferenceType()); break; @@ -1109,12 +1101,12 @@ Sema::OwningExprResult Sema::ActOnUnaryTypeTrait(UnaryTypeTrait OTT, TypeTy *Ty, SourceLocation RParen) { QualType T = GetTypeFromParser(Ty); - + // 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. if (OTT != UTT_IsClass && OTT != UTT_IsEnum && OTT != UTT_IsUnion) { - if (RequireCompleteType(KWLoc, T, + if (RequireCompleteType(KWLoc, T, diag::err_incomplete_type_used_in_type_trait_expr)) return ExprError(); } @@ -1127,8 +1119,7 @@ Sema::OwningExprResult Sema::ActOnUnaryTypeTrait(UnaryTypeTrait OTT, } QualType Sema::CheckPointerToMemberOperands( - Expr *&lex, Expr *&rex, SourceLocation Loc, bool isIndirect) -{ + Expr *&lex, Expr *&rex, SourceLocation Loc, bool isIndirect) { const char *OpSpelling = isIndirect ? "->*" : ".*"; // C++ 5.5p2 // The binary operator .* [p3: ->*] binds its second operand, which shall @@ -1140,7 +1131,7 @@ QualType Sema::CheckPointerToMemberOperands( Diag(Loc, diag::err_bad_memptr_rhs) << OpSpelling << RType << rex->getSourceRange(); return QualType(); - } + } QualType Class(MemPtr->getClass(), 0); @@ -1214,8 +1205,7 @@ static QualType TargetType(const ImplicitConversionSequence &ICS) { /// conversion. static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, SourceLocation QuestionLoc, - ImplicitConversionSequence &ICS) -{ + ImplicitConversionSequence &ICS) { // C++0x 5.16p3 // The process for determining whether an operand expression E1 of type T1 // can be converted to match an operand expression E2 of type T2 is defined @@ -1262,7 +1252,7 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, // Could still fail if there's no copy constructor. // FIXME: Is this a hard error then, or just a conversion failure? The // standard doesn't say. - ICS = Self.TryCopyInitialization(From, TTy, + ICS = Self.TryCopyInitialization(From, TTy, /*SuppressUserConversions=*/false, /*ForceRValue=*/false, /*InOverloadResolution=*/false); @@ -1274,7 +1264,7 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, // First find the decayed type. if (TTy->isFunctionType()) TTy = Self.Context.getPointerType(TTy); - else if(TTy->isArrayType()) + else if (TTy->isArrayType()) TTy = Self.Context.getArrayDecayedType(TTy); // Now try the implicit conversion. @@ -1339,8 +1329,7 @@ static bool FindConditionalOverload(Sema &Self, Expr *&LHS, Expr *&RHS, /// second part of a standard conversion is ICK_DerivedToBase. This function /// handles the reference binding specially. static bool ConvertForConditional(Sema &Self, Expr *&E, - const ImplicitConversionSequence &ICS) -{ + const ImplicitConversionSequence &ICS) { if (ICS.ConversionKind == ImplicitConversionSequence::StandardConversion && ICS.Standard.ReferenceBinding) { assert(ICS.Standard.DirectBinding && @@ -1583,13 +1572,13 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) { assert(getLangOptions().CPlusPlus && "This function assumes C++"); QualType T1 = E1->getType(), T2 = E2->getType(); - + if (!T1->isPointerType() && !T1->isMemberPointerType() && !T2->isPointerType() && !T2->isMemberPointerType()) return QualType(); // FIXME: Do we need to work on the canonical types? - + // C++0x 5.9p2 // Pointer conversions and qualification conversions are performed on // pointer operands to bring them to their composite pointer type. If @@ -1603,7 +1592,7 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) { ImpCastExprToType(E2, T1); return T1; } - + // Now both have to be pointers or member pointers. if (!T1->isPointerType() && !T1->isMemberPointerType() && !T2->isPointerType() && !T2->isMemberPointerType()) @@ -1633,7 +1622,7 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) { MemberOfClass.push_back(std::make_pair((const Type *)0, (const Type *)0)); continue; } - + const MemberPointerType *MemPtr1, *MemPtr2; if ((MemPtr1 = Composite1->getAs<MemberPointerType>()) && (MemPtr2 = Composite2->getAs<MemberPointerType>())) { @@ -1645,19 +1634,19 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) { MemPtr2->getClass())); continue; } - + // FIXME: block pointer types? - + // Cannot unwrap any more types. break; } while (true); - + // Rewrap the composites as pointers or member pointers with the union CVRs. llvm::SmallVector<std::pair<const Type *, const Type *>, 4>::iterator MOC = MemberOfClass.begin(); - for (llvm::SmallVector<unsigned, 4>::iterator + for (llvm::SmallVector<unsigned, 4>::iterator I = QualifierUnion.begin(), - E = QualifierUnion.end(); + E = QualifierUnion.end(); I != E; (void)++I, ++MOC) { if (MOC->first && MOC->second) { // Rebuild member pointer type @@ -1672,19 +1661,19 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) { } } - ImplicitConversionSequence E1ToC1 = + ImplicitConversionSequence E1ToC1 = TryImplicitConversion(E1, Composite1, /*SuppressUserConversions=*/false, /*AllowExplicit=*/false, /*ForceRValue=*/false, /*InOverloadResolution=*/false); - ImplicitConversionSequence E2ToC1 = + ImplicitConversionSequence E2ToC1 = TryImplicitConversion(E2, Composite1, /*SuppressUserConversions=*/false, /*AllowExplicit=*/false, /*ForceRValue=*/false, /*InOverloadResolution=*/false); - + ImplicitConversionSequence E1ToC2, E2ToC2; E1ToC2.ConversionKind = ImplicitConversionSequence::BadConversion; E2ToC2.ConversionKind = ImplicitConversionSequence::BadConversion; @@ -1726,16 +1715,16 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) { Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) { if (!Context.getLangOptions().CPlusPlus) return Owned(E); - + const RecordType *RT = E->getType()->getAs<RecordType>(); if (!RT) return Owned(E); - + CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl()); if (RD->hasTrivialDestructor()) return Owned(E); - - CXXTemporary *Temp = CXXTemporary::Create(Context, + + CXXTemporary *Temp = CXXTemporary::Create(Context, RD->getDestructor(Context)); ExprTemporaries.push_back(Temp); if (CXXDestructorDecl *Destructor = @@ -1745,40 +1734,40 @@ Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) { return Owned(CXXBindTemporaryExpr::Create(Context, Temp, E)); } -Expr *Sema::MaybeCreateCXXExprWithTemporaries(Expr *SubExpr, +Expr *Sema::MaybeCreateCXXExprWithTemporaries(Expr *SubExpr, bool ShouldDestroyTemps) { assert(SubExpr && "sub expression can't be null!"); - + if (ExprTemporaries.empty()) return SubExpr; - + Expr *E = CXXExprWithTemporaries::Create(Context, SubExpr, - &ExprTemporaries[0], + &ExprTemporaries[0], ExprTemporaries.size(), ShouldDestroyTemps); ExprTemporaries.clear(); - + return E; } -Sema::OwningExprResult +Sema::OwningExprResult Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc, tok::TokenKind OpKind, TypeTy *&ObjectType) { // Since this might be a postfix expression, get rid of ParenListExprs. Base = MaybeConvertParenListExprToParenExpr(S, move(Base)); - + Expr *BaseExpr = (Expr*)Base.get(); assert(BaseExpr && "no record expansion"); - + QualType BaseType = BaseExpr->getType(); if (BaseType->isDependentType()) { // FIXME: member of the current instantiation ObjectType = BaseType.getAsOpaquePtr(); return move(Base); } - + // C++ [over.match.oper]p8: - // [...] When operator->returns, the operator-> is applied to the value + // [...] When operator->returns, the operator-> is applied to the value // returned, with the original second operand. if (OpKind == tok::arrow) { while (BaseType->isRecordType()) { @@ -1789,11 +1778,11 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc, BaseType = BaseExpr->getType(); } } - + if (BaseType->isPointerType()) BaseType = BaseType->getPointeeType(); - - // We could end up with various non-record types here, such as extended + + // We could end up with various non-record types here, such as extended // vector types or Objective-C interfaces. Just return early and let // ActOnMemberReferenceExpr do the work. if (!BaseType->isRecordType()) { @@ -1804,14 +1793,14 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc, ObjectType = 0; return move(Base); } - + // C++ [basic.lookup.classref]p2: - // If the id-expression in a class member access (5.2.5) is an + // If the id-expression in a class member access (5.2.5) is an // unqualified-id, and the type of the object expres- sion is of a class // type C (or of pointer to a class type C), the unqualified-id is looked // up in the scope of class C. [...] ObjectType = BaseType.getAsOpaquePtr(); - return move(Base); + return move(Base); } Sema::OwningExprResult @@ -1832,16 +1821,16 @@ Sema::ActOnDestructorReferenceExpr(Scope *S, ExprArg Base, else { TypeTy *BaseTy = getTypeName(*ClassName, ClassNameLoc, S, &SS); if (!BaseTy) { - Diag(ClassNameLoc, diag::err_ident_in_pseudo_dtor_not_a_type) + Diag(ClassNameLoc, diag::err_ident_in_pseudo_dtor_not_a_type) << ClassName; return ExprError(); } - + BaseType = GetTypeFromParser(BaseTy); } - + CanQualType CanBaseType = Context.getCanonicalType(BaseType); - DeclarationName DtorName = + DeclarationName DtorName = Context.DeclarationNames.getCXXDestructorName(CanBaseType); OwningExprResult Result @@ -1849,8 +1838,8 @@ Sema::ActOnDestructorReferenceExpr(Scope *S, ExprArg Base, DtorName, DeclPtrTy(), &SS); if (Result.isInvalid() || HasTrailingLParen) return move(Result); - - // The only way a reference to a destructor can be used is to + + // The only way a reference to a destructor can be used is to // immediately call them. Since the next token is not a '(', produce a // diagnostic and build the call now. Expr *E = (Expr *)Result.get(); @@ -1858,8 +1847,8 @@ Sema::ActOnDestructorReferenceExpr(Scope *S, ExprArg Base, Diag(E->getLocStart(), diag::err_dtor_expr_without_call) << isa<CXXPseudoDestructorExpr>(E) << CodeModificationHint::CreateInsertion(ExpectedLParenLoc, "()"); - - return ActOnCallExpr(0, move(Result), ExpectedLParenLoc, + + return ActOnCallExpr(0, move(Result), ExpectedLParenLoc, MultiExprArg(*this, 0, 0), 0, ExpectedLParenLoc); } @@ -1903,7 +1892,7 @@ Sema::ActOnConversionOperatorReferenceExpr(Scope *S, ExprArg Base, Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) { Expr *FullExpr = Arg.takeAs<Expr>(); if (FullExpr) - FullExpr = MaybeCreateCXXExprWithTemporaries(FullExpr, + FullExpr = MaybeCreateCXXExprWithTemporaries(FullExpr, /*ShouldDestroyTemps=*/true); |