From: Nikola Smiljanic Date: Thu, 29 May 2014 14:05:12 +0000 (+0000) Subject: Refactoring. Remove Owned method from Sema. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f6cf7c7789744fcba00e5eec9b21e44676b35d0d;p=clang Refactoring. Remove Owned method from Sema. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209812 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 9fcde63811..cf4d383cf2 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1036,10 +1036,6 @@ public: /// \brief Retrieve the module loader associated with the preprocessor. ModuleLoader &getModuleLoader() const; - ExprResult Owned(Expr* E) { return E; } - ExprResult Owned(ExprResult R) { return R; } - StmtResult Owned(Stmt* S) { return S; } - void ActOnEndOfTranslationUnit(); void CheckDelegatingCtorCycles(); @@ -7699,8 +7695,8 @@ public: Expr *E1Tmp = E1.get(), *E2Tmp = E2.get(); QualType Composite = FindCompositePointerType(Loc, E1Tmp, E2Tmp, NonStandardCompositeType); - E1 = Owned(E1Tmp); - E2 = Owned(E2Tmp); + E1 = E1Tmp; + E2 = E2Tmp; return Composite; } diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 636bf896aa..ce0911e2ff 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -328,7 +328,7 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, QualType TypeTy = Context.getCanonicalType(Ty); if (ExprTy == TypeTy) - return Owned(E); + return E; // If this is a derived-to-base cast to a through a virtual base, we // need a vtable. @@ -346,11 +346,11 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) { ImpCast->setType(Ty); ImpCast->setValueKind(VK); - return Owned(E); + return E; } } - return Owned(ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK)); + return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK); } /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp index e752984b93..caaf5e5954 100644 --- a/lib/Sema/SemaCast.cpp +++ b/lib/Sema/SemaCast.cpp @@ -93,7 +93,7 @@ namespace { CK_Dependent, castExpr, nullptr, castExpr->getValueKind()); } - return Self.Owned(castExpr); + return castExpr; } // Internal convenience methods. @@ -239,7 +239,7 @@ ExprResult Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *DestTInfo, Expr *E, SourceRange AngleBrackets, SourceRange Parens) { - ExprResult Ex = Owned(E); + ExprResult Ex = E; QualType DestType = DestTInfo->getType(); // If the type is dependent, we won't do the semantic analysis now. diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index c7312107bc..7c539d530a 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -101,7 +101,7 @@ static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) { if (checkArgCount(S, TheCall, 1)) return true; - ExprResult Arg(S.Owned(TheCall->getArg(0))); + ExprResult Arg(TheCall->getArg(0)); QualType ResultType = S.CheckAddressOfOperand(Arg, TheCall->getLocStart()); if (ResultType.isNull()) return true; @@ -113,7 +113,7 @@ static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) { ExprResult Sema::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { - ExprResult TheCallResult(Owned(TheCall)); + ExprResult TheCallResult(TheCall); // Find out if any arguments are required to be integer constant expressions. unsigned ICEArguments = 0; @@ -1219,7 +1219,7 @@ ExprResult Sema::SemaAtomicOpsOverloaded(ExprResult TheCallResult, Diag(AE->getLocStart(), diag::err_atomic_load_store_uses_lib) << ((Op == AtomicExpr::AO__c11_atomic_load) ? 0 : 1); - return Owned(AE); + return AE; } @@ -1861,9 +1861,9 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) { TheCall->setArg(i, nullptr); } - return Owned(new (Context) ShuffleVectorExpr(Context, exprs, resType, - TheCall->getCallee()->getLocStart(), - TheCall->getRParenLoc())); + return new (Context) ShuffleVectorExpr(Context, exprs, resType, + TheCall->getCallee()->getLocStart(), + TheCall->getRParenLoc()); } /// SemaConvertVectorExpr - Handle __builtin_convertvector @@ -1892,9 +1892,8 @@ ExprResult Sema::SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, << E->getSourceRange()); } - return Owned(new (Context) ConvertVectorExpr(E, TInfo, DstTy, VK, OK, - BuiltinLoc, RParenLoc)); - + return new (Context) + ConvertVectorExpr(E, TInfo, DstTy, VK, OK, BuiltinLoc, RParenLoc); } /// SemaBuiltinPrefetch - Handle __builtin_prefetch. diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 683ccc77e2..9614d0d3c2 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -11453,7 +11453,7 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc, // If the bit-width is type- or value-dependent, don't try to check // it now. if (BitWidth->isValueDependent() || BitWidth->isTypeDependent()) - return Owned(BitWidth); + return BitWidth; llvm::APSInt Value; ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value); @@ -11500,7 +11500,7 @@ ExprResult Sema::VerifyBitField(SourceLocation FieldLoc, } } - return Owned(BitWidth); + return BitWidth; } /// ActOnField - Each field of a C struct/union is passed into this in order diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 2fb3ff79e3..77d5a5bce7 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2833,7 +2833,7 @@ Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, // initializer. However, deconstructing the ASTs is a dicey process, // and this approach is far more likely to get the corner cases right. if (CurContext->isDependentContext()) - DelegationInit = Owned(Init); + DelegationInit = Init; return new (Context) CXXCtorInitializer(Context, TInfo, InitRange.getBegin(), DelegationInit.getAs(), @@ -2962,7 +2962,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, // initializer. However, deconstructing the ASTs is a dicey process, // and this approach is far more likely to get the corner cases right. if (CurContext->isDependentContext()) - BaseInit = Owned(Init); + BaseInit = Init; return new (Context) CXXCtorInitializer(Context, BaseTInfo, BaseSpec->isVirtual(), @@ -9030,7 +9030,7 @@ buildMemcpyForAssignmentOp(Sema &S, SourceLocation Loc, QualType T, Loc, CallArgs, Loc); assert(!Call.isInvalid() && "Call to __builtin_memcpy cannot fail!"); - return S.Owned(Call.getAs()); + return Call.getAs(); } /// \brief Builds a statement that copies/moves the given entity from \p From to @@ -10585,12 +10585,11 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, unsigned ConstructKind, SourceRange ParenRange) { MarkFunctionReferenced(ConstructLoc, Constructor); - return Owned(CXXConstructExpr::Create(Context, DeclInitType, ConstructLoc, - Constructor, Elidable, ExprArgs, - HadMultipleCandidates, - IsListInitialization, RequiresZeroInit, - static_cast(ConstructKind), - ParenRange)); + return CXXConstructExpr::Create( + Context, DeclInitType, ConstructLoc, Constructor, Elidable, ExprArgs, + HadMultipleCandidates, IsListInitialization, RequiresZeroInit, + static_cast(ConstructKind), + ParenRange); } void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) { diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d739b8614b..1d4792e9e0 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -456,7 +456,7 @@ ExprResult Sema::DefaultFunctionArrayConversion(Expr *E) { E = ImpCastExprToType(E, Context.getArrayDecayedType(Ty), CK_ArrayToPointerDecay).get(); } - return Owned(E); + return E; } static void CheckForNullPointerDereference(Sema &S, Expr *E) { @@ -545,7 +545,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { // C++ [conv.lval]p1: // A glvalue of a non-function, non-array type T can be // converted to a prvalue. - if (!E->isGLValue()) return Owned(E); + if (!E->isGLValue()) return E; QualType T = E->getType(); assert(!T.isNull() && "r-value conversion on typeless expression?"); @@ -556,7 +556,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { (E->getType() == Context.OverloadTy || T->isDependentType() || T->isRecordType())) - return Owned(E); + return E; // The C standard is actually really unclear on this point, and // DR106 tells us what the result should be but not why. It's @@ -564,7 +564,7 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { // lvalue-to-rvalue at all. Note that expressions of unqualified // 'void' type are never l-values, but qualified void can be. if (T->isVoidType()) - return Owned(E); + return E; // OpenCL usually rejects direct accesses to values of 'half' type. if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16 && @@ -611,16 +611,16 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) { E->getType().getObjCLifetime() == Qualifiers::OCL_Weak) ExprNeedsCleanups = true; - ExprResult Res = Owned(ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, - E, nullptr, VK_RValue)); + ExprResult Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E, + nullptr, VK_RValue); // C11 6.3.2.1p2: // ... if the lvalue has atomic type, the value has the non-atomic version // of the type of the lvalue ... if (const AtomicType *Atomic = T->getAs()) { T = Atomic->getValueType().getUnqualifiedType(); - Res = Owned(ImplicitCastExpr::Create(Context, T, CK_AtomicToNonAtomic, - Res.get(), nullptr, VK_RValue)); + Res = ImplicitCastExpr::Create(Context, T, CK_AtomicToNonAtomic, Res.get(), + nullptr, VK_RValue); } return Res; @@ -652,7 +652,7 @@ ExprResult Sema::CallExprUnaryConversions(Expr *E) { Res = DefaultLvalueConversion(Res.get()); if (Res.isInvalid()) return ExprError(); - return Owned(Res.get()); + return Res.get(); } /// UsualUnaryConversions - Performs various conversions that are common to most @@ -694,15 +694,15 @@ ExprResult Sema::UsualUnaryConversions(Expr *E) { QualType PTy = Context.isPromotableBitField(E); if (!PTy.isNull()) { E = ImpCastExprToType(E, PTy, CK_IntegralCast).get(); - return Owned(E); + return E; } if (Ty->isPromotableIntegerType()) { QualType PT = Context.getPromotedIntegerType(Ty); E = ImpCastExprToType(E, PT, CK_IntegralCast).get(); - return Owned(E); + return E; } } - return Owned(E); + return E; } /// DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that @@ -739,14 +739,13 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) { if (getLangOpts().CPlusPlus && E->isGLValue() && !isUnevaluatedContext()) { ExprResult Temp = PerformCopyInitialization( InitializedEntity::InitializeTemporary(E->getType()), - E->getExprLoc(), - Owned(E)); + E->getExprLoc(), E); if (Temp.isInvalid()) return ExprError(); E = Temp.get(); } - return Owned(E); + return E; } /// Determine the degree of POD-ness for an expression. @@ -896,7 +895,7 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, diag::err_call_incomplete_argument)) return ExprError(); - return Owned(E); + return E; } /// \brief Converts an integer to complex float type. Helper function of @@ -1386,10 +1385,9 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc, // If we determined that the generic selection is result-dependent, don't // try to compute the result expression. if (IsResultDependent) - return Owned(new (Context) GenericSelectionExpr( - Context, KeyLoc, ControllingExpr, - Types, Exprs, - DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack)); + return new (Context) GenericSelectionExpr( + Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc, + ContainsUnexpandedParameterPack); SmallVector CompatIndices; unsigned DefaultIndex = -1U; @@ -1441,11 +1439,9 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc, unsigned ResultIndex = CompatIndices.size() ? CompatIndices[0] : DefaultIndex; - return Owned(new (Context) GenericSelectionExpr( - Context, KeyLoc, ControllingExpr, - Types, Exprs, - DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack, - ResultIndex)); + return new (Context) GenericSelectionExpr( + Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc, + ContainsUnexpandedParameterPack, ResultIndex); } /// getUDSuffixLoc - Create a SourceLocation for a ud-suffix, given the @@ -1545,7 +1541,7 @@ Sema::ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks, &StringTokLocs[0], StringTokLocs.size()); if (Literal.getUDSuffix().empty()) - return Owned(Lit); + return Lit; // We're building a user-defined literal. IdentifierInfo *UDSuffix = &Context.Idents.get(Literal.getUDSuffix()); @@ -1683,7 +1679,7 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, if (FD && FD->isBitField()) E->setObjectKind(OK_BitField); - return Owned(E); + return E; } /// Decomposes the given name into a DeclarationNameInfo, its location, and @@ -2019,7 +2015,7 @@ ExprResult Sema::ActOnIdExpression(Scope *S, return ExprError(); if (Expr *Ex = E.getAs()) - return Owned(Ex); + return Ex; } } @@ -2059,10 +2055,10 @@ ExprResult Sema::ActOnIdExpression(Scope *S, // Since the 'this' expression is synthesized, we don't need to // perform the double-lookup check. NamedDecl *FirstQualifierInScope = nullptr; - return Owned(CXXDependentScopeMemberExpr::Create( + return CXXDependentScopeMemberExpr::Create( Context, /*This=*/nullptr, ThisType, /*IsArrow=*/true, /*Op=*/SourceLocation(), SS.getWithLocInContext(Context), - TemplateKWLoc, FirstQualifierInScope, NameInfo, TemplateArgs)); + TemplateKWLoc, FirstQualifierInScope, NameInfo, TemplateArgs); } } @@ -2304,7 +2300,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, << FixItHint::CreateInsertion(Loc, "self->"); } - return Owned(Result); + return Result; } } else if (CurMethod->isInstanceMethod()) { // We should warn if a local variable hides an ivar. @@ -2337,7 +2333,7 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, } } // Sentinel value saying that we didn't do anything special. - return Owned((Expr*) nullptr); + return ExprResult((Expr *)nullptr); } /// \brief Cast a base object to a member's actual type. @@ -2364,7 +2360,7 @@ Sema::PerformObjectMemberConversion(Expr *From, NamedDecl *Member) { CXXRecordDecl *RD = dyn_cast(Member->getDeclContext()); if (!RD) - return Owned(From); + return From; QualType DestRecordType; QualType DestType; @@ -2384,7 +2380,7 @@ Sema::PerformObjectMemberConversion(Expr *From, } } else if (CXXMethodDecl *Method = dyn_cast(Member)) { if (Method->isStatic()) - return Owned(From); + return From; DestType = Method->getThisType(Context); DestRecordType = DestType->getPointeeType(); @@ -2398,15 +2394,15 @@ Sema::PerformObjectMemberConversion(Expr *From, } } else { // No conversion necessary. - return Owned(From); + return From; } if (DestType->isDependentType() || FromType->isDependentType()) - return Owned(From); + return From; // If the unqualified types are the same, no conversion is necessary. if (Context.hasSameUnqualifiedType(FromRecordType, DestRecordType)) - return Owned(From); + return From; SourceRange FromRange = From->getSourceRange(); SourceLocation FromLoc = FromRange.getBegin(); @@ -2457,7 +2453,7 @@ Sema::PerformObjectMemberConversion(Expr *From, // If the qualifier type was the same as the destination type, // we're done. if (Context.hasSameUnqualifiedType(FromRecordType, DestRecordType)) - return Owned(From); + return From; } } @@ -2614,7 +2610,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, NeedsADL, R.isOverloadedResult(), R.begin(), R.end()); - return Owned(ULE); + return ULE; } /// \brief Complete semantic analysis for a reference to the given declaration. @@ -2861,7 +2857,7 @@ ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc, ResTy = Context.getConstantArrayType(ResTy, LengthI, ArrayType::Normal, 0); } - return Owned(new (Context) PredefinedExpr(Loc, ResTy, IT)); + return new (Context) PredefinedExpr(Loc, ResTy, IT); } ExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind) { @@ -2916,7 +2912,7 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) { Tok.getLocation()); if (Literal.getUDSuffix().empty()) - return Owned(Lit); + return Lit; // We're building a user-defined literal. IdentifierInfo *UDSuffix = &Context.Idents.get(Literal.getUDSuffix()); @@ -2935,8 +2931,8 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) { ExprResult Sema::ActOnIntegerConstant(SourceLocation Loc, uint64_t Val) { unsigned IntSize = Context.getTargetInfo().getIntWidth(); - return Owned(IntegerLiteral::Create(Context, llvm::APInt(IntSize, Val), - Context.IntTy, Loc)); + return IntegerLiteral::Create(Context, llvm::APInt(IntSize, Val), + Context.IntTy, Loc); } static Expr *BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, @@ -3227,12 +3223,12 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { Res = new (Context) ImaginaryLiteral(Res, Context.getComplexType(Res->getType())); - return Owned(Res); + return Res; } ExprResult Sema::ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E) { assert(E && "ActOnParenExpr() missing expr"); - return Owned(new (Context) ParenExpr(L, R, E)); + return new (Context) ParenExpr(L, R, E); } static bool CheckVecStepTraitOperandType(Sema &S, QualType T, @@ -3532,9 +3528,8 @@ Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, return ExprError(); // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t. - return Owned(new (Context) UnaryExprOrTypeTraitExpr(ExprKind, TInfo, - Context.getSizeType(), - OpLoc, R.getEnd())); + return new (Context) UnaryExprOrTypeTraitExpr( + ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd()); } /// \brief Build a sizeof or alignof expression given an expression @@ -3573,9 +3568,8 @@ Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc, } // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t. - return Owned(new (Context) UnaryExprOrTypeTraitExpr( - ExprKind, E, Context.getSizeType(), OpLoc, - E->getSourceRange().getEnd())); + return new (Context) UnaryExprOrTypeTraitExpr( + ExprKind, E, Context.getSizeType(), OpLoc, E->getSourceRange().getEnd()); } /// ActOnUnaryExprOrTypeTraitExpr - Handle @c sizeof(type) and @c sizeof @c @@ -3699,10 +3693,8 @@ Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, SourceLocation lbLoc, // Build an unanalyzed expression if either operand is type-dependent. if (getLangOpts().CPlusPlus && (base->isTypeDependent() || idx->isTypeDependent())) { - return Owned(new (Context) ArraySubscriptExpr(base, idx, - Context.DependentTy, - VK_LValue, OK_Ordinary, - rbLoc)); + return new (Context) ArraySubscriptExpr(base, idx, Context.DependentTy, + VK_LValue, OK_Ordinary, rbLoc); } // Use C++ overloaded-operator rules if either operand has record @@ -3862,8 +3854,8 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, assert(VK == VK_RValue || LangOpts.CPlusPlus || !ResultType.isCForbiddenLValueType()); - return Owned(new (Context) ArraySubscriptExpr(LHSExp, RHSExp, - ResultType, VK, OK, RLoc)); + return new (Context) + ArraySubscriptExpr(LHSExp, RHSExp, ResultType, VK, OK, RLoc); } ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, @@ -3922,7 +3914,7 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, Expr *Arg = Result.getAs(); CheckCompletedExpr(Arg, Param->getOuterLocStart()); // Build the default argument expression. - return Owned(CXXDefaultArgExpr::Create(Context, CallLoc, Param, Arg)); + return CXXDefaultArgExpr::Create(Context, CallLoc, Param, Arg); } // If the default expression creates temporaries, we need to @@ -3949,7 +3941,7 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, // as being "referenced". MarkDeclarationsReferencedInExpr(Param->getDefaultArg(), /*SkipLocalVariables=*/true); - return Owned(CXXDefaultArgExpr::Create(Context, CallLoc, Param)); + return CXXDefaultArgExpr::Create(Context, CallLoc, Param); } @@ -4201,11 +4193,8 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, if (CFAudited) Entity.setParameterCFAudited(); - ExprResult ArgE = PerformCopyInitialization(Entity, - SourceLocation(), - Owned(Arg), - IsListInitialization, - AllowExplicit); + ExprResult ArgE = PerformCopyInitialization( + Entity, SourceLocation(), Arg, IsListInitialization, AllowExplicit); if (ArgE.isInvalid()) return true; @@ -4405,9 +4394,8 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, ArgExprs.back()->getLocEnd())); } - return Owned(new (Context) CallExpr(Context, Fn, None, - Context.VoidTy, VK_RValue, - RParenLoc)); + return new (Context) + CallExpr(Context, Fn, None, Context.VoidTy, VK_RValue, RParenLoc); } if (Fn->getType() == Context.PseudoObjectTy) { ExprResult result = CheckPlaceholderExpr(Fn); @@ -4427,20 +4415,19 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, if (Dependent) { if (ExecConfig) { - return Owned(new (Context) CUDAKernelCallExpr( + return new (Context) CUDAKernelCallExpr( Context, Fn, cast(ExecConfig), ArgExprs, - Context.DependentTy, VK_RValue, RParenLoc)); + Context.DependentTy, VK_RValue, RParenLoc); } else { - return Owned(new (Context) CallExpr(Context, Fn, ArgExprs, - Context.DependentTy, VK_RValue, - RParenLoc)); + return new (Context) CallExpr( + Context, Fn, ArgExprs, Context.DependentTy, VK_RValue, RParenLoc); } } // Determine whether this is a call to an object (C++ [over.call.object]). if (Fn->getType()->isRecordType()) - return Owned(BuildCallToObjectOfClassType(S, Fn, LParenLoc, - ArgExprs, RParenLoc)); + return BuildCallToObjectOfClassType(S, Fn, LParenLoc, ArgExprs, + RParenLoc); if (Fn->getType() == Context.UnknownAnyTy) { ExprResult result = rebuildUnknownAnyFunction(*this, Fn); @@ -4543,8 +4530,7 @@ ExprResult Sema::ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, << DstTy << SrcTy << E->getSourceRange()); - return Owned(new (Context) AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, - RParenLoc)); + return new (Context) AsTypeExpr(E, DstTy, VK, OK, BuiltinLoc, RParenLoc); } /// ActOnConvertVectorExpr - create a new convert-vector expression from the @@ -4692,9 +4678,8 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, if (Proto && i < Proto->getNumParams()) { InitializedEntity Entity = InitializedEntity::InitializeParameter( Context, Proto->getParamType(i), Proto->isParamConsumed(i)); - ExprResult ArgE = PerformCopyInitialization(Entity, - SourceLocation(), - Owned(Arg)); + ExprResult ArgE = + PerformCopyInitialization(Entity, SourceLocation(), Arg); if (ArgE.isInvalid()) return true; @@ -4833,7 +4818,7 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, InitListExpr *E = new (Context) InitListExpr(Context, LBraceLoc, InitArgList, RBraceLoc); E->setType(Context.VoidTy); // FIXME: just a place holder for now. - return Owned(E); + return E; } /// Do an explicit extend of the given block pointer if we're in ARC. @@ -5115,7 +5100,7 @@ ExprResult Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, return ExprError(); } Kind = CK_BitCast; - return Owned(CastExpr); + return CastExpr; } // All non-pointer scalars can be cast to ExtVector type. The appropriate @@ -5127,14 +5112,14 @@ ExprResult Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, << DestTy << SrcTy << R; QualType DestElemTy = DestTy->getAs()->getElementType(); - ExprResult CastExprRes = Owned(CastExpr); + ExprResult CastExprRes = CastExpr; CastKind CK = PrepareScalarCast(CastExprRes, DestElemTy); if (CastExprRes.isInvalid()) return ExprError(); CastExpr = ImpCastExprToType(CastExprRes.get(), DestElemTy, CK).get(); Kind = CK_VectorSplat; - return Owned(CastExpr); + return CastExpr; } ExprResult @@ -5288,7 +5273,7 @@ ExprResult Sema::MaybeConvertParenListExprToParenExpr(Scope *S, Expr *OrigExpr) { ParenListExpr *E = dyn_cast(OrigExpr); if (!E) - return Owned(OrigExpr); + return OrigExpr; ExprResult Result(E->getExpr(0)); @@ -5305,7 +5290,7 @@ ExprResult Sema::ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val) { Expr *expr = new (Context) ParenListExpr(Context, L, Val, R); - return Owned(expr); + return expr; } /// \brief Emit a specialized diagnostic when one expression is a null pointer @@ -5999,7 +5984,7 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, ExprValueKind VK = VK_RValue; ExprObjectKind OK = OK_Ordinary; - ExprResult Cond = Owned(CondExpr), LHS = Owned(LHSExpr), RHS = Owned(RHSExpr); + ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr; QualType result = CheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc); if (result.isNull() || Cond.isInvalid() || LHS.isInvalid() || @@ -6010,14 +5995,13 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, RHS.get()); if (!commonExpr) - return Owned(new (Context) ConditionalOperator(Cond.get(), QuestionLoc, - LHS.get(), ColonLoc, - RHS.get(), result, VK, OK)); + return new (Context) + ConditionalOperator(Cond.get(), QuestionLoc, LHS.get(), ColonLoc, + RHS.get(), result, VK, OK); - return Owned(new (Context) - BinaryConditionalOperator(commonExpr, opaqueValue, Cond.get(), LHS.get(), - RHS.get(), QuestionLoc, ColonLoc, result, VK, - OK)); + return new (Context) BinaryConditionalOperator( + commonExpr, opaqueValue, Cond.get(), LHS.get(), RHS.get(), QuestionLoc, + ColonLoc, result, VK, OK); } // checkPointerTypesForAssignment - This is a very tricky routine (despite @@ -6522,9 +6506,8 @@ static void ConstructTransparentUnion(Sema &S, ASTContext &C, // Build a compound literal constructing a value of the transparent // union type from this initializer list. TypeSourceInfo *unionTInfo = C.getTrivialTypeSourceInfo(UnionType); - EResult = S.Owned( - new (C) CompoundLiteralExpr(SourceLocation(), unionTInfo, UnionType, - VK_RValue, Initializer, false)); + EResult = new (C) CompoundLiteralExpr(SourceLocation(), unionTInfo, UnionType, + VK_RValue, Initializer, false); } Sema::AssignConvertType @@ -6667,7 +6650,7 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, (CheckObjCBridgeRelatedConversions(E->getLocStart(), LHSType, E->getType(), E) || ConversionToObjCStringLiteralCheck(LHSType, E))) { - RHS = Owned(E); + RHS = E; return Compatible; } @@ -8227,7 +8210,7 @@ inline QualType Sema::CheckBitwiseOperands( return InvalidOperands(Loc, LHS, RHS); } - ExprResult LHSResult = Owned(LHS), RHSResult = Owned(RHS); + ExprResult LHSResult = LHS, RHSResult = RHS; QualType compType = UsualArithmeticConversions(LHSResult, RHSResult, IsCompAssign); if (LHSResult.isInvalid() || RHSResult.isInvalid()) @@ -9220,7 +9203,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, RHSExpr = Init.get(); } - ExprResult LHS = Owned(LHSExpr), RHS = Owned(RHSExpr); + ExprResult LHS = LHSExpr, RHS = RHSExpr; QualType ResultTy; // Result type of the binary operator. // The following two variables are used for compound assignment operators QualType CompLHSTy; // Type of LHS after promotions for computation @@ -9355,18 +9338,16 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, DiagnoseDirectIsaAccess(*this, OIRE, OpLoc, RHS.get()); if (CompResultTy.isNull()) - return Owned(new (Context) BinaryOperator(LHS.get(), RHS.get(), Opc, - ResultTy, VK, OK, OpLoc, - FPFeatures.fp_contract)); + return new (Context) BinaryOperator(LHS.get(), RHS.get(), Opc, ResultTy, VK, + OK, OpLoc, FPFeatures.fp_contract); if (getLangOpts().CPlusPlus && LHS.get()->getObjectKind() != OK_ObjCProperty) { VK = VK_LValue; OK = LHS.get()->getObjectKind(); } - return Owned(new (Context) CompoundAssignOperator(LHS.get(), RHS.get(), Opc, - ResultTy, VK, OK, CompLHSTy, - CompResultTy, OpLoc, - FPFeatures.fp_contract)); + return new (Context) CompoundAssignOperator( + LHS.get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy, + OpLoc, FPFeatures.fp_contract); } /// DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison @@ -9694,7 +9675,7 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc, ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr) { - ExprResult Input = Owned(InputExpr); + ExprResult Input = InputExpr; ExprValueKind VK = VK_RValue; ExprObjectKind OK = OK_Ordinary; QualType resultType; @@ -9848,8 +9829,8 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, if (Opc != UO_AddrOf && Opc != UO_Deref) CheckArrayAccess(Input.get()); - return Owned(new (Context) UnaryOperator(Input.get(), Opc, resultType, - VK, OK, OpLoc)); + return new (Context) + UnaryOperator(Input.get(), Opc, resultType, VK, OK, OpLoc); } /// \brief Determine whether the given expression is a qualified member @@ -9952,8 +9933,8 @@ ExprResult Sema::ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl) { TheDecl->markUsed(Context); // Create the AST node. The address of a label always has type 'void*'. - return Owned(new (Context) AddrLabelExpr(OpLoc, LabLoc, TheDecl, - Context.getPointerType(Context.VoidTy))); + return new (Context) AddrLabelExpr(OpLoc, LabLoc, TheDecl, + Context.getPointerType(Context.VoidTy)); } /// Given the last statement in a statement-expression, check whether @@ -10069,7 +10050,7 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, Expr *ResStmtExpr = new (Context) StmtExpr(Compound, Ty, LPLoc, RPLoc); if (StmtExprMayBindToTemp) return MaybeBindToTemporary(ResStmtExpr); - return Owned(ResStmtExpr); + return ResStmtExpr; } ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, @@ -10242,8 +10223,8 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, CurrentType = MemberDecl->getType().getNonReferenceType(); } - return Owned(OffsetOfExpr::Create(Context, Context.getSizeType(), BuiltinLoc, - TInfo, Comps, Exprs, RParenLoc)); + return OffsetOfExpr::Create(Context, Context.getSizeType(), BuiltinLoc, TInfo, + Comps, Exprs, RParenLoc); } ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, @@ -10301,10 +10282,9 @@ ExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc, OK = ActiveExpr->getObjectKind(); } - return Owned(new (Context) ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, - resType, VK, OK, RPLoc, CondIsTrue, - resType->isDependentType(), - ValueDependent)); + return new (Context) + ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc, + CondIsTrue, resType->isDependentType(), ValueDependent); } //===----------------------------------------------------------------------===// @@ -10584,7 +10564,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, } } - return Owned(Result); + return Result; } ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, @@ -10677,7 +10657,7 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc, } QualType T = TInfo->getType().getNonLValueExprType(Context); - return Owned(new (Context) VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T)); + return new (Context) VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T); } ExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) { @@ -10695,7 +10675,7 @@ ExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) { llvm_unreachable("I don't know size of pointer!"); } - return Owned(new (Context) GNUNullExpr(Ty, TokenLoc)); + return new (Context) GNUNullExpr(Ty, TokenLoc); } bool @@ -11018,7 +10998,7 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, if (!getLangOpts().CPlusPlus11 && E->isIntegerConstantExpr(Context)) { if (Result) *Result = E->EvaluateKnownConstInt(Context); - return Owned(E); + return E; } Expr::EvalResult EvalResult; @@ -11036,7 +11016,7 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, if (Folded && getLangOpts().CPlusPlus11 && Notes.empty()) { if (Result) *Result = EvalResult.Val.getInt(); - return Owned(E); + return E; } // If our only note is the usual "invalid subexpression" note, just point @@ -11064,7 +11044,7 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, if (Result) *Result = EvalResult.Val.getInt(); - return Owned(E); + return E; } namespace { @@ -11646,7 +11626,7 @@ static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, = S.PerformCopyInitialization( InitializedEntity::InitializeBlock(Var->getLocation(), CaptureType, false), - Loc, S.Owned(DeclRef)); + Loc, DeclRef); // Build a full-expression copy expression if initialization // succeeded and used a non-trivial constructor. Recover from @@ -12709,7 +12689,7 @@ ExprResult Sema::CheckBooleanCondition(Expr *E, SourceLocation Loc) { } } - return Owned(E); + return E; } ExprResult Sema::ActOnBooleanCondition(Scope *S, SourceLocation Loc, @@ -13035,7 +13015,7 @@ ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) { if (!Result.isUsable()) return ExprError(); E->setSubExpr(Result.get()); - return S.Owned(E); + return E; } else if (E->getCastKind() == CK_LValueToRValue) { assert(E->getValueKind() == VK_RValue); assert(E->getObjectKind() == OK_Ordinary); @@ -13051,7 +13031,7 @@ ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) { if (!Result.isUsable()) return ExprError(); E->setSubExpr(Result.get()); - return S.Owned(E); + return E; } else { llvm_unreachable("Unhandled cast type!"); } @@ -13111,7 +13091,7 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) { VD->setType(DestType); E->setType(Type); E->setValueKind(ValueKind); - return S.Owned(E); + return E; } /// Check a cast of an unknown-any type. We intentionally only @@ -13154,7 +13134,7 @@ ExprResult Sema::checkUnknownAnyArg(SourceLocation callLoc, InitializedEntity entity = InitializedEntity::InitializeParameter(Context, paramType, /*consumed*/ false); - return PerformCopyInitialization(entity, callLoc, Owned(arg)); + return PerformCopyInitialization(entity, callLoc, arg); } static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E) { @@ -13204,7 +13184,7 @@ static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E) { /// Returns true if there was an error and no recovery was possible. ExprResult Sema::CheckPlaceholderExpr(Expr *E) { const BuiltinType *placeholderType = E->getType()->getAsPlaceholderType(); - if (!placeholderType) return Owned(E); + if (!placeholderType) return E; switch (placeholderType->getKind()) { @@ -13212,7 +13192,7 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) { case BuiltinType::Overload: { // Try to resolve a single function template specialization. // This is obligatory. - ExprResult result = Owned(E); + ExprResult result = E; if (ResolveAndFixSingleFunctionTemplateSpecialization(result, false)) { return result; @@ -13226,7 +13206,7 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) { // Bound member functions. case BuiltinType::BoundMember: { - ExprResult result = Owned(E); + ExprResult result = E; tryToRecoverWithCall(result, PDiag(diag::err_bound_member_function), /*complain*/ true); return result; @@ -13236,7 +13216,7 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) { case BuiltinType::ARCUnbridgedCast: { Expr *realCast = stripARCUnbridgedCast(E); diagnoseARCUnbridgedCast(realCast); - return Owned(realCast); + return realCast; } // Expressions of unknown type. @@ -13287,6 +13267,6 @@ Sema::ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind) { } if (Context.getBOOLDecl()) BoolT = Context.getBOOLType(); - return Owned(new (Context) ObjCBoolLiteralExpr(Kind == tok::kw___objc_yes, - BoolT, OpLoc)); + return new (Context) + ObjCBoolLiteralExpr(Kind == tok::kw___objc_yes, BoolT, OpLoc); } diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index e2debb10bc..6ebe974875 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -379,9 +379,8 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, RequireCompleteType(TypeidLoc, T, diag::err_incomplete_typeid)) return ExprError(); - return Owned(new (Context) CXXTypeidExpr(TypeInfoType.withConst(), - Operand, - SourceRange(TypeidLoc, RParenLoc))); + return new (Context) CXXTypeidExpr(TypeInfoType.withConst(), Operand, + SourceRange(TypeidLoc, RParenLoc)); } /// \brief Build a C++ typeid expression with an expression operand. @@ -434,9 +433,8 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, } } - return Owned(new (Context) CXXTypeidExpr(TypeInfoType.withConst(), - E, - SourceRange(TypeidLoc, RParenLoc))); + return new (Context) CXXTypeidExpr(TypeInfoType.withConst(), E, + SourceRange(TypeidLoc, RParenLoc)); } /// ActOnCXXTypeidOfType - Parse typeid( type-id ) or typeid (expression); @@ -502,9 +500,8 @@ ExprResult Sema::BuildCXXUuidof(QualType TypeInfoType, } } - return Owned(new (Context) CXXUuidofExpr(TypeInfoType.withConst(), - Operand, - SourceRange(TypeidLoc, RParenLoc))); + return new (Context) CXXUuidofExpr(TypeInfoType.withConst(), Operand, + SourceRange(TypeidLoc, RParenLoc)); } /// \brief Build a Microsoft __uuidof expression with an expression operand. @@ -523,9 +520,8 @@ ExprResult Sema::BuildCXXUuidof(QualType TypeInfoType, } } - return Owned(new (Context) CXXUuidofExpr(TypeInfoType.withConst(), - E, - SourceRange(TypeidLoc, RParenLoc))); + return new (Context) CXXUuidofExpr(TypeInfoType.withConst(), E, + SourceRange(TypeidLoc, RParenLoc)); } /// ActOnCXXUuidof - Parse __uuidof( type-id ) or __uuidof (expression); @@ -567,14 +563,14 @@ ExprResult Sema::ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind) { assert((Kind == tok::kw_true || Kind == tok::kw_false) && "Unknown C++ Boolean value!"); - return Owned(new (Context) CXXBoolLiteralExpr(Kind == tok::kw_true, - Context.BoolTy, OpLoc)); + return new (Context) + CXXBoolLiteralExpr(Kind == tok::kw_true, Context.BoolTy, OpLoc); } /// ActOnCXXNullPtrLiteral - Parse 'nullptr'. ExprResult Sema::ActOnCXXNullPtrLiteral(SourceLocation Loc) { - return Owned(new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc)); + return new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc); } /// ActOnCXXThrow - Parse throw expressions. @@ -629,8 +625,8 @@ ExprResult Sema::BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, Ex = ExRes.get(); } - return Owned(new (Context) CXXThrowExpr(Ex, Context.VoidTy, OpLoc, - IsThrownVarInScope)); + return new (Context) + CXXThrowExpr(Ex, Context.VoidTy, OpLoc, IsThrownVarInScope); } /// CheckCXXThrowOperand - Validate the operand of a throw. @@ -702,7 +698,7 @@ ExprResult Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *E, // If the exception has class type, we need additional handling. const RecordType *RecordTy = Ty->getAs(); if (!RecordTy) - return Owned(E); + return E; CXXRecordDecl *RD = cast(RecordTy->getDecl()); // If we are throwing a polymorphic class type or pointer thereof, @@ -711,22 +707,22 @@ ExprResult Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *E, // If a pointer is thrown, the referenced object will not be destroyed. if (isPointer) - return Owned(E); + return E; // If the class has a destructor, we must be able to call it. if (RD->hasIrrelevantDestructor()) - return Owned(E); + return E; CXXDestructorDecl *Destructor = LookupDestructor(RD); if (!Destructor) - return Owned(E); + return E; MarkFunctionReferenced(E->getExprLoc(), Destructor); CheckDestructorAccess(E->getExprLoc(), Destructor, PDiag(diag::err_access_dtor_exception) << Ty); if (DiagnoseUseOfDecl(Destructor, E->getExprLoc())) return ExprError(); - return Owned(E); + return E; } QualType Sema::getCurrentThisType() { @@ -853,7 +849,7 @@ ExprResult Sema::ActOnCXXThis(SourceLocation Loc) { if (ThisTy.isNull()) return Diag(Loc, diag::err_invalid_this_use); CheckCXXThisCapture(Loc); - return Owned(new (Context) CXXThisExpr(Loc, ThisTy, /*isImplicit=*/false)); + return new (Context) CXXThisExpr(Loc, ThisTy, /*isImplicit=*/false); } bool Sema::isThisOutsideMemberFunctionBody(QualType BaseType) { @@ -897,10 +893,8 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, SourceLocation TyBeginLoc = TInfo->getTypeLoc().getBeginLoc(); if (Ty->isDependentType() || CallExpr::hasAnyTypeDependentArguments(Exprs)) { - return Owned(CXXUnresolvedConstructExpr::Create(Context, TInfo, - LParenLoc, - Exprs, - RParenLoc)); + return CXXUnresolvedConstructExpr::Create(Context, TInfo, LParenLoc, Exprs, + RParenLoc); } bool ListInitialization = LParenLoc.isInvalid(); @@ -956,9 +950,9 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, // want, since it will be treated as an initializer list in further // processing. Explicitly insert a cast here. QualType ResultType = Result.get()->getType(); - Result = Owned(CXXFunctionalCastExpr::Create( + Result = CXXFunctionalCastExpr::Create( Context, ResultType, Expr::getValueKindForType(TInfo->getType()), TInfo, - CK_NoOp, Result.get(), /*Path=*/ nullptr, LParenLoc, RParenLoc)); + CK_NoOp, Result.get(), /*Path=*/nullptr, LParenLoc, RParenLoc); } // FIXME: Improve AST representation? @@ -1501,7 +1495,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, // we don't want the initialized object to be destructed. if (CXXBindTemporaryExpr *Binder = dyn_cast_or_null(FullInit.get())) - FullInit = Owned(Binder->getSubExpr()); + FullInit = Binder->getSubExpr(); Initializer = FullInit.get(); } @@ -1536,13 +1530,11 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, } } - return Owned(new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew, - OperatorDelete, - UsualArrayDeleteWantsSize, - PlacementArgs, TypeIdParens, - ArraySize, initStyle, Initializer, - ResultType, AllocTypeInfo, - Range, DirectInitRange)); + return new (Context) + CXXNewExpr(Context, UseGlobal, OperatorNew, OperatorDelete, + UsualArrayDeleteWantsSize, PlacementArgs, TypeIdParens, + ArraySize, initStyle, Initializer, ResultType, AllocTypeInfo, + Range, DirectInitRange); } /// \brief Checks that a type is suitable as the allocated type @@ -2241,7 +2233,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // // DR599 amends "pointer type" to "pointer to object type" in both cases. - ExprResult Ex = Owned(ExE); + ExprResult Ex = ExE; FunctionDecl *OperatorDelete = nullptr; bool ArrayFormAsWritten = ArrayForm; bool UsualArrayDeleteWantsSize = false; @@ -2432,10 +2424,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, } } - return Owned(new (Context) CXXDeleteExpr(Context.VoidTy, UseGlobal, ArrayForm, - ArrayFormAsWritten, - UsualArrayDeleteWantsSize, - OperatorDelete, Ex.get(), StartLoc)); + return new (Context) CXXDeleteExpr( + Context.VoidTy, UseGlobal, ArrayForm, ArrayFormAsWritten, + UsualArrayDeleteWantsSize, OperatorDelete, Ex.get(), StartLoc); } /// \brief Check the use of the given variable as a C++ condition in an if, @@ -2459,14 +2450,10 @@ ExprResult Sema::CheckConditionVariable(VarDecl *ConditionVar, diag::err_invalid_use_of_array_type) << ConditionVar->getSourceRange()); - ExprResult Condition = - Owned(DeclRefExpr::Create(Context, NestedNameSpecifierLoc(), - SourceLocation(), - ConditionVar, - /*enclosing*/ false, - ConditionVar->getLocation(), - ConditionVar->getType().getNonReferenceType(), - VK_LValue)); + ExprResult Condition = DeclRefExpr::Create( + Context, NestedNameSpecifierLoc(), SourceLocation(), ConditionVar, + /*enclosing*/ false, ConditionVar->getLocation(), + ConditionVar->getType().getNonReferenceType(), VK_LValue); MarkDeclRefReferenced(cast(Condition.get())); @@ -2577,11 +2564,9 @@ static ExprResult BuildCXXCastArgument(Sema &S, if (Result.isInvalid()) return ExprError(); // Record usage of conversion in an implicit cast. - Result = S.Owned(ImplicitCastExpr::Create(S.Context, - Result.get()->getType(), - CK_UserDefinedConversion, - Result.get(), nullptr, - Result.get()->getValueKind())); + Result = ImplicitCastExpr::Create(S.Context, Result.get()->getType(), + CK_UserDefinedConversion, Result.get(), + nullptr, Result.get()->getValueKind()); S.CheckMemberOperatorAccess(CastLoc, From, /*arg*/ nullptr, FoundDecl); @@ -2677,7 +2662,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, } // Everything went well. - return Owned(From); + return From; } /// PerformImplicitConversion - Perform an implicit conversion of the @@ -3011,7 +2996,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, } case ICK_TransparentUnionConversion: { - ExprResult FromRes = Owned(From); + ExprResult FromRes = From; Sema::AssignConvertType ConvTy = CheckTransparentUnionArgumentConstraints(ToType, FromRes); if (FromRes.isInvalid()) @@ -3074,7 +3059,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, VK_RValue, nullptr, CCK).get(); } - return Owned(From); + return From; } /// \brief Check the completeness of a type in a unary type trait. @@ -4002,9 +3987,8 @@ ExprResult Sema::BuildArrayTypeTrait(ArrayTypeTrait ATT, // returns 'size_t'. On Windows, the primary platform for the Embarcadero // compiler, there is no difference. On several other platforms this is an // important distinction. - return Owned(new (Context) ArrayTypeTraitExpr(KWLoc, ATT, TSInfo, Value, - DimExpr, RParen, - Context.getSizeType())); + return new (Context) ArrayTypeTraitExpr(KWLoc, ATT, TSInfo, Value, DimExpr, + RParen, Context.getSizeType()); } ExprResult Sema::ActOnExpressionTrait(ExpressionTrait ET, @@ -4042,8 +4026,8 @@ ExprResult Sema::BuildExpressionTrait(ExpressionTrait ET, bool Value = EvaluateExpressionTrait(ET, Queried); - return Owned(new (Context) ExpressionTraitExpr(KWLoc, ET, Queried, Value, - RParen, Context.BoolTy)); + return new (Context) + ExpressionTraitExpr(KWLoc, ET, Queried, Value, RParen, Context.BoolTy); } QualType Sema::CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, @@ -4845,7 +4829,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { // If the result is a glvalue, we shouldn't bind it. if (!E->isRValue()) - return Owned(E); + return E; // In ARC, calls that return a retainable type can return retained, // in which case we have to insert a consuming cast. @@ -4888,7 +4872,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { // we don't want any extra casts here. } else if (isa(E) && isa(cast(E)->getSubExpr())) { - return Owned(E); + return E; // For message sends and property references, we try to find an // actual method. FIXME: we should infer retention by selector in @@ -4913,23 +4897,23 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { // return an object. if (!ReturnsRetained && D && D->getMethodFamily() == OMF_performSelector) - return Owned(E); + return E; } // Don't reclaim an object of Class type. if (!ReturnsRetained && E->getType()->isObjCARCImplicitlyUnretainedType()) - return Owned(E); + return E; ExprNeedsCleanups = true; CastKind ck = (ReturnsRetained ? CK_ARCConsumeObject : CK_ARCReclaimReturnedObject); - return Owned(ImplicitCastExpr::Create(Context, E->getType(), ck, E, nullptr, - VK_RValue)); + return ImplicitCastExpr::Create(Context, E->getType(), ck, E, nullptr, + VK_RValue); } if (!getLangOpts().CPlusPlus) - return Owned(E); + return E; // Search for the base element type (cf. ASTContext::getBaseElementType) with // a fast path for the common case that the type is directly a RecordType. @@ -4947,7 +4931,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { T = cast(T)->getElementType().getTypePtr(); break; default: - return Owned(E); + return E; } } @@ -4955,7 +4939,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { // not processing a decltype expression. CXXRecordDecl *RD = cast(RT->getDecl()); if (RD->isInvalidDecl() || RD->isDependentContext()) - return Owned(E); + return E; bool IsDecltype = ExprEvalContexts.back().IsDecltype; CXXDestructorDecl *Destructor = IsDecltype ? nullptr : LookupDestructor(RD); @@ -4970,7 +4954,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { // If destructor is trivial, we can avoid the extra copy. if (Destructor->isTrivial()) - return Owned(E); + return E; // We need a cleanup, but we don't need to remember the temporary. ExprNeedsCleanups = true; @@ -4982,7 +4966,7 @@ ExprResult Sema::MaybeBindToTemporary(Expr *E) { if (IsDecltype) ExprEvalContexts.back().DelayedDecltypeBinds.push_back(Bind); - return Owned(Bind); + return Bind; } ExprResult @@ -4990,7 +4974,7 @@ Sema::MaybeCreateExprWithCleanups(ExprResult SubExpr) { if (SubExpr.isInvalid()) return ExprError(); - return Owned(MaybeCreateExprWithCleanups(SubExpr.get())); + return MaybeCreateExprWithCleanups(SubExpr.get()); } Expr *Sema::MaybeCreateExprWithCleanups(Expr *SubExpr) { @@ -5056,7 +5040,7 @@ ExprResult Sema::ActOnDecltypeExpression(Expr *E) { if (SubExpr.isInvalid()) return ExprError(); if (SubExpr.get() == PE->getSubExpr()) - return Owned(E); + return E; return ActOnParenExpr(PE->getLParen(), PE->getRParen(), SubExpr.get()); } if (BinaryOperator *BO = dyn_cast(E)) { @@ -5065,13 +5049,10 @@ ExprResult Sema::ActOnDecltypeExpression(Expr *E) { if (RHS.isInvalid()) return ExprError(); if (RHS.get() == BO->getRHS()) - return Owned(E); - return Owned(new (Context) BinaryOperator(BO->getLHS(), RHS.get(), - BO_Comma, BO->getType(), - BO->getValueKind(), - BO->getObjectKind(), - BO->getOperatorLoc(), - BO->isFPContractable())); + return E; + return new (Context) BinaryOperator( + BO->getLHS(), RHS.get(), BO_Comma, BO->getType(), BO->getValueKind(), + BO->getObjectKind(), BO->getOperatorLoc(), BO->isFPContractable()); } } @@ -5089,7 +5070,7 @@ ExprResult Sema::ActOnDecltypeExpression(Expr *E) { // In MS mode, don't perform any extra checking of call return types within a // decltype expression. if (getLangOpts().MSVCCompat) - return Owned(E); + return E; // Perform the semantic checks we delayed until this point. for (unsigned I = 0, N = ExprEvalContexts.back().DelayedDecltypeCalls.size(); @@ -5132,7 +5113,7 @@ ExprResult Sema::ActOnDecltypeExpression(Expr *E) { } // Possibly strip off the top CXXBindTemporaryExpr. - return Owned(E); + return E; } /// Note a set of 'operator->' functions that were used for a member access. @@ -5186,7 +5167,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, ObjectType = ParsedType::make(BaseType); MayBePseudoDestructor = true; - return Owned(Base); + return Base; } // C++ [over.match.oper]p8: @@ -5276,7 +5257,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, } else if (!BaseType->isRecordType()) { ObjectType = ParsedType(); MayBePseudoDestructor = true; - return Owned(Base); + return Base; } // The object type must be complete (or dependent), or @@ -5442,7 +5423,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, Destructed); if (HasTrailingLParen) - return Owned(Result); + return Result; return DiagnoseDtorReference(Destructed.getLocation(), Result); } @@ -5664,8 +5645,8 @@ ExprResult Sema::BuildCXXMemberCallExpr(Expr *E, NamedDecl *FoundDecl, ExprResult Sema::BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen) { CanThrowResult CanThrow = canThrow(Operand); - return Owned(new (Context) CXXNoexceptExpr(Context.BoolTy, Operand, - CanThrow, KeyLoc, RParen)); + return new (Context) + CXXNoexceptExpr(Context.BoolTy, Operand, CanThrow, KeyLoc, RParen); } ExprResult Sema::ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation, @@ -5733,7 +5714,7 @@ static bool IsSpecialDiscardedValue(Expr *E) { ExprResult Sema::IgnoredValueConversions(Expr *E) { if (E->hasPlaceholderType()) { ExprResult result = CheckPlaceholderExpr(E); - if (result.isInvalid()) return Owned(E); + if (result.isInvalid()) return E; E = result.get(); } @@ -5749,7 +5730,7 @@ ExprResult Sema::IgnoredValueConversions(Expr *E) { if (!getLangOpts().CPlusPlus && E->getType()->isFunctionType()) return DefaultFunctionArrayConversion(E); - return Owned(E); + return E; } if (getLangOpts().CPlusPlus) { @@ -5762,10 +5743,10 @@ ExprResult Sema::IgnoredValueConversions(Expr *E) { IsSpecialDiscardedValue(E)) { ExprResult Res = DefaultLvalueConversion(E); if (Res.isInvalid()) - return Owned(E); + return E; E = Res.get(); } - return Owned(E); + return E; } // GCC seems to also exclude expressions of incomplete enum type. @@ -5773,19 +5754,19 @@ ExprResult Sema::IgnoredValueConversions(Expr *E) { if (!T->getDecl()->isComplete()) { // FIXME: stupid workaround for a codegen bug! E = ImpCastExprToType(E, Context.VoidTy, CK_ToVoid).get(); - return Owned(E); + return E; } } ExprResult Res = DefaultFunctionArrayLvalueConversion(E); if (Res.isInvalid()) - return Owned(E); + return E; E = Res.get(); if (!E->getType()->isVoidType()) RequireCompleteType(E->getExprLoc(), E->getType(), diag::err_incomplete_type); - return Owned(E); + return E; } // If we can unambiguously determine whether Var can never be used @@ -5924,7 +5905,7 @@ ExprResult Sema::ActOnFinishFullExpr(Expr *FE, SourceLocation CC, bool DiscardedValue, bool IsConstexpr, bool IsLambdaInitCaptureInitializer) { - ExprResult FullExpr = Owned(FE); + ExprResult FullExpr = FE; if (!FullExpr.get()) return ExprError(); diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp index d7e2de0297..e91ace36aa 100644 --- a/lib/Sema/SemaExprMember.cpp +++ b/lib/Sema/SemaExprMember.cpp @@ -455,12 +455,10 @@ Sema::ActOnDependentMemberExpr(Expr *BaseExpr, QualType BaseType, // Get the type being accessed in BaseType. If this is an arrow, the BaseExpr // must have pointer type, and the accessed type is the pointee. - return Owned(CXXDependentScopeMemberExpr::Create(Context, BaseExpr, BaseType, - IsArrow, OpLoc, - SS.getWithLocInContext(Context), - TemplateKWLoc, - FirstQualifierInScope, - NameInfo, TemplateArgs)); + return CXXDependentScopeMemberExpr::Create( + Context, BaseExpr, BaseType, IsArrow, OpLoc, + SS.getWithLocInContext(Context), TemplateKWLoc, FirstQualifierInScope, + NameInfo, TemplateArgs); } /// We know that the given qualified member reference points only to @@ -683,7 +681,7 @@ Sema::BuildMemberReferenceExpr(Expr *Base, QualType BaseType, // Explicit member accesses. } else { - ExprResult BaseResult = Owned(Base); + ExprResult BaseResult = Base; ExprResult Result = LookupMemberExpr(R, BaseResult, IsArrow, OpLoc, SS, /*ObjCImpDecl*/ nullptr, TemplateArgs != nullptr); @@ -692,10 +690,8 @@ Sema::BuildMemberReferenceExpr(Expr *Base, QualType BaseType, return ExprError(); Base = BaseResult.get(); - if (Result.isInvalid()) { - Owned(Base); + if (Result.isInvalid()) return ExprError(); - } if (Result.get()) return Result; @@ -825,7 +821,7 @@ Sema::BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, fakeFoundDecl, memberNameInfo).get(); } - return Owned(result); + return result; } static ExprResult @@ -996,7 +992,7 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, TemplateKWLoc, MemberNameInfo, TemplateArgs, R.begin(), R.end()); - return Owned(MemExpr); + return MemExpr; } assert(R.isSingleResult()); @@ -1033,10 +1029,8 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, } // Check the use of this member. - if (ShouldCheckUse && DiagnoseUseOfDecl(MemberDecl, MemberLoc)) { - Owned(BaseExpr); + if (ShouldCheckUse && DiagnoseUseOfDecl(MemberDecl, MemberLoc)) return ExprError(); - } if (FieldDecl *FD = dyn_cast(MemberDecl)) return BuildFieldReferenceExpr(*this, BaseExpr, IsArrow, @@ -1054,10 +1048,10 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, OpLoc); if (VarDecl *Var = dyn_cast(MemberDecl)) { - return Owned(BuildMemberExpr(*this, Context, BaseExpr, IsArrow, SS, - TemplateKWLoc, Var, FoundDecl, MemberNameInfo, - Var->getType().getNonReferenceType(), - VK_LValue, OK_Ordinary)); + return BuildMemberExpr(*this, Context, BaseExpr, IsArrow, SS, TemplateKWLoc, + Var, FoundDecl, MemberNameInfo, + Var->getType().getNonReferenceType(), VK_LValue, + OK_Ordinary); } if (CXXMethodDecl *MemberFn = dyn_cast(MemberDecl)) { @@ -1071,21 +1065,18 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, type = MemberFn->getType(); } - return Owned(BuildMemberExpr(*this, Context, BaseExpr, IsArrow, SS, - TemplateKWLoc, MemberFn, FoundDecl, - MemberNameInfo, type, valueKind, - OK_Ordinary)); + return BuildMemberExpr(*this, Context, BaseExpr, IsArrow, SS, TemplateKWLoc, + MemberFn, FoundDecl, MemberNameInfo, type, valueKind, + OK_Ordinary); } assert(!isa(MemberDecl) && "member function not C++ method?"); if (EnumConstantDecl *Enum = dyn_cast(MemberDecl)) { - return Owned(BuildMemberExpr(*this, Context, BaseExpr, IsArrow, SS, - TemplateKWLoc, Enum, FoundDecl, MemberNameInfo, - Enum->getType(), VK_RValue, OK_Ordinary)); + return BuildMemberExpr(*this, Context, BaseExpr, IsArrow, SS, TemplateKWLoc, + Enum, FoundDecl, MemberNameInfo, Enum->getType(), + VK_RValue, OK_Ordinary); } - Owned(BaseExpr); - // We found something that we didn't expect. Complain. if (isa(MemberDecl)) Diag(MemberLoc, diag::err_typecheck_member_reference_type) @@ -1219,7 +1210,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, // Returning valid-but-null is how we indicate to the caller that // the lookup result was filled in. - return Owned((Expr*) nullptr); + return ExprResult((Expr *)nullptr); } // Handle ivar access to Objective-C objects. @@ -1246,9 +1237,8 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, // But we only actually find it this way on objects of type 'id', // apparently. if (OTy->isObjCId() && Member->isStr("isa")) - return Owned(new (Context) ObjCIsaExpr(BaseExpr.get(), IsArrow, MemberLoc, - OpLoc, - Context.getObjCClassType())); + return new (Context) ObjCIsaExpr(BaseExpr.get(), IsArrow, MemberLoc, + OpLoc, Context.getObjCClassType()); if (ShouldTryAgainWithRedefinitionType(*this, BaseExpr)) return LookupMemberExpr(R, BaseExpr, IsArrow, OpLoc, SS, ObjCImpDecl, HasTemplateArgs); @@ -1378,7 +1368,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, } } - return Owned(Result); + return Result; } // Objective-C property access. @@ -1412,12 +1402,9 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, if (DiagnoseUseOfDecl(PD, MemberLoc)) return ExprError(); - return Owned(new (Context) ObjCPropertyRefExpr(PD, - Context.PseudoObjectTy, - VK_LValue, - OK_ObjCProperty, - MemberLoc, - BaseExpr.get())); + return new (Context) + ObjCPropertyRefExpr(PD, Context.PseudoObjectTy, VK_LValue, + OK_ObjCProperty, MemberLoc, BaseExpr.get()); } if (ObjCMethodDecl *OMD = dyn_cast(PMDecl)) { @@ -1434,10 +1421,9 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, SetterSel, Context)) SMD = dyn_cast(SDecl); - return Owned(new (Context) ObjCPropertyRefExpr(OMD, SMD, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, - MemberLoc, BaseExpr.get())); + return new (Context) + ObjCPropertyRefExpr(OMD, SMD, Context.PseudoObjectTy, VK_LValue, + OK_ObjCProperty, MemberLoc, BaseExpr.get()); } } // Use of id.member can only be for a property reference. Do not @@ -1489,10 +1475,9 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, return ExprError(); if (Getter || Setter) { - return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, - MemberLoc, BaseExpr.get())); + return new (Context) ObjCPropertyRefExpr( + Getter, Setter, Context.PseudoObjectTy, VK_LValue, OK_ObjCProperty, + MemberLoc, BaseExpr.get()); } if (ShouldTryAgainWithRedefinitionType(*this, BaseExpr)) @@ -1519,8 +1504,8 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr, if (ret.isNull()) return ExprError(); - return Owned(new (Context) ExtVectorElementExpr(ret, VK, BaseExpr.get(), - *Member, MemberLoc)); + return new (Context) + ExtVectorElementExpr(ret, VK, BaseExpr.get(), *Member, MemberLoc); } // Adjust builtin-sel to the appropriate redefinition type if that's @@ -1635,17 +1620,15 @@ ExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr *Base, NameInfo, TemplateArgs); } else { LookupResult R(*this, NameInfo, LookupMemberName); - ExprResult BaseResult = Owned(Base); + ExprResult BaseResult = Base; Result = LookupMemberExpr(R, BaseResult, IsArrow, OpLoc, SS, ObjCImpDecl, TemplateArgs != nullptr); if (BaseResult.isInvalid()) return ExprError(); Base = BaseResult.get(); - if (Result.isInvalid()) { - Owned(Base); + if (Result.isInvalid()) return ExprError(); - } if (Result.get()) { // The only way a reference to a destructor can be used is to @@ -1725,10 +1708,9 @@ BuildFieldReferenceExpr(Sema &S, Expr *BaseExpr, bool IsArrow, FoundDecl, Field); if (Base.isInvalid()) return ExprError(); - return S.Owned(BuildMemberExpr(S, S.Context, Base.get(), IsArrow, SS, - /*TemplateKWLoc=*/SourceLocation(), - Field, FoundDecl, MemberNameInfo, - MemberType, VK, OK)); + return BuildMemberExpr(S, S.Context, Base.get(), IsArrow, SS, + /*TemplateKWLoc=*/SourceLocation(), Field, FoundDecl, + MemberNameInfo, MemberType, VK, OK); } /// Builds an implicit member access expression. The current context diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 99905bed34..ced1555588 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -296,7 +296,7 @@ ExprResult Sema::BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number) { ParamDecl); ExprResult ConvertedNumber = PerformCopyInitialization(Entity, SourceLocation(), - Owned(Number)); + Number); if (ConvertedNumber.isInvalid()) return ExprError(); Number = ConvertedNumber.get(); @@ -445,7 +445,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { if (ValueExpr->isTypeDependent()) { ObjCBoxedExpr *BoxedExpr = new (Context) ObjCBoxedExpr(ValueExpr, Context.DependentTy, nullptr, SR); - return Owned(BoxedExpr); + return BoxedExpr; } ObjCMethodDecl *BoxingMethod = nullptr; QualType BoxedType; @@ -586,7 +586,7 @@ ExprResult Sema::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { ParamDecl); ExprResult ConvertedValueExpr = PerformCopyInitialization(Entity, SourceLocation(), - Owned(ValueExpr)); + ValueExpr); if (ConvertedValueExpr.isInvalid()) return ExprError(); ValueExpr = ConvertedValueExpr.get(); @@ -624,13 +624,9 @@ ExprResult Sema::BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, BaseExpr = Result.get(); // Build the pseudo-object expression. - return Owned(ObjCSubscriptRefExpr::Create(Context, - BaseExpr, - IndexExpr, - Context.PseudoObjectTy, - getterMethod, - setterMethod, RB)); - + return ObjCSubscriptRefExpr::Create(Context, BaseExpr, IndexExpr, + Context.PseudoObjectTy, getterMethod, + setterMethod, RB); } ExprResult Sema::BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements) { @@ -1398,7 +1394,7 @@ bool Sema::CheckMessageArgumentTypes(QualType ReceiverType, InitializedEntity Entity = InitializedEntity::InitializeParameter(Context, param); - ExprResult ArgE = PerformCopyInitialization(Entity, SelLoc, Owned(argExpr)); + ExprResult ArgE = PerformCopyInitialization(Entity, SelLoc, argExpr); if (ArgE.isInvalid()) IsError = true; else @@ -1583,14 +1579,13 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, if (DiagnoseUseOfDecl(PD, MemberLoc)) return ExprError(); if (Super) - return Owned(new (Context) ObjCPropertyRefExpr(PD, Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, - MemberLoc, - SuperLoc, SuperType)); + return new (Context) + ObjCPropertyRefExpr(PD, Context.PseudoObjectTy, VK_LValue, + OK_ObjCProperty, MemberLoc, SuperLoc, SuperType); else - return Owned(new (Context) ObjCPropertyRefExpr(PD, Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, - MemberLoc, BaseExpr)); + return new (Context) + ObjCPropertyRefExpr(PD, Context.PseudoObjectTy, VK_LValue, + OK_ObjCProperty, MemberLoc, BaseExpr); } // Check protocols on qualified interfaces. for (const auto *I : OPT->quals()) @@ -1600,19 +1595,13 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, return ExprError(); if (Super) - return Owned(new (Context) ObjCPropertyRefExpr(PD, - Context.PseudoObjectTy, - VK_LValue, - OK_ObjCProperty, - MemberLoc, - SuperLoc, SuperType)); + return new (Context) ObjCPropertyRefExpr( + PD, Context.PseudoObjectTy, VK_LValue, OK_ObjCProperty, MemberLoc, + SuperLoc, SuperType); else - return Owned(new (Context) ObjCPropertyRefExpr(PD, - Context.PseudoObjectTy, - VK_LValue, - OK_ObjCProperty, - MemberLoc, - BaseExpr)); + return new (Context) + ObjCPropertyRefExpr(PD, Context.PseudoObjectTy, VK_LValue, + OK_ObjCProperty, MemberLoc, BaseExpr); } // If that failed, look for an "implicit" property by seeing if the nullary // selector is implemented. @@ -1658,16 +1647,13 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, if (Getter || Setter) { if (Super) - return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, - MemberLoc, - SuperLoc, SuperType)); + return new (Context) + ObjCPropertyRefExpr(Getter, Setter, Context.PseudoObjectTy, VK_LValue, + OK_ObjCProperty, MemberLoc, SuperLoc, SuperType); else - return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, - MemberLoc, BaseExpr)); + return new (Context) + ObjCPropertyRefExpr(Getter, Setter, Context.PseudoObjectTy, VK_LValue, + OK_ObjCProperty, MemberLoc, BaseExpr); } @@ -1798,18 +1784,14 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, if (Getter || Setter) { if (IsSuper) - return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, - propertyNameLoc, - receiverNameLoc, - Context.getObjCInterfaceType(IFace))); - - return Owned(new (Context) ObjCPropertyRefExpr(Getter, Setter, - Context.PseudoObjectTy, - VK_LValue, OK_ObjCProperty, - propertyNameLoc, - receiverNameLoc, IFace)); + return new (Context) + ObjCPropertyRefExpr(Getter, Setter, Context.PseudoObjectTy, VK_LValue, + OK_ObjCProperty, propertyNameLoc, receiverNameLoc, + Context.getObjCInterfaceType(IFace)); + + return new (Context) ObjCPropertyRefExpr( + Getter, Setter, Context.PseudoObjectTy, VK_LValue, OK_ObjCProperty, + propertyNameLoc, receiverNameLoc, IFace); } return ExprError(Diag(propertyNameLoc, diag::err_property_not_found) << &propertyName << Context.getObjCInterfaceType(IFace)); @@ -2103,11 +2085,10 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, unsigned NumArgs = ArgsIn.size(); Expr **Args = ArgsIn.data(); assert(SuperLoc.isInvalid() && "Message to super with dependent type"); - return Owned(ObjCMessageExpr::Create(Context, ReceiverType, - VK_RValue, LBracLoc, ReceiverTypeInfo, - Sel, SelectorLocs, /*Method=*/nullptr, - makeArrayRef(Args, NumArgs),RBracLoc, - isImplicit)); + return ObjCMessageExpr::Create( + Context, ReceiverType, VK_RValue, LBracLoc, ReceiverTypeInfo, Sel, + SelectorLocs, /*Method=*/nullptr, makeArrayRef(Args, NumArgs), RBracLoc, + isImplicit); } // Find the class to which we are sending this message. @@ -2297,11 +2278,10 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, unsigned NumArgs = ArgsIn.size(); Expr **Args = ArgsIn.data(); assert(SuperLoc.isInvalid() && "Message to super with dependent type"); - return Owned(ObjCMessageExpr::Create(Context, Context.DependentTy, - VK_RValue, LBracLoc, Receiver, Sel, - SelectorLocs, /*Method=*/nullptr, - makeArrayRef(Args, NumArgs), - RBracLoc, isImplicit)); + return ObjCMessageExpr::Create( + Context, Context.DependentTy, VK_RValue, LBracLoc, Receiver, Sel, + SelectorLocs, /*Method=*/nullptr, makeArrayRef(Args, NumArgs), + RBracLoc, isImplicit); } // If necessary, apply function/array conversion to the receiver. @@ -2674,7 +2654,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, // The implicit assignment to self means we also don't want to // consume the result. Result->setDelegateInitCall(true); - return Owned(Result); + return Result; } } diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 51f14e233b..9ef43cc81f 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -894,7 +894,7 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, // compatible structure or union type. In the latter case, the // initial value of the object, including unnamed members, is // that of the expression. - ExprResult ExprRes = SemaRef.Owned(expr); + ExprResult ExprRes = expr; if ((ElemType->isRecordType() || ElemType->isVectorType()) && SemaRef.CheckSingleAssignmentConstraints(ElemType, ExprRes, !VerifyOnly) @@ -930,8 +930,7 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, if (!VerifyOnly) { // We cannot initialize this element, so let // PerformCopyInitialization produce the appropriate diagnostic. - SemaRef.PerformCopyInitialization(Entity, SourceLocation(), - SemaRef.Owned(expr), + SemaRef.PerformCopyInitialization(Entity, SourceLocation(), expr, /*TopLevelOfInitList=*/true); } hadError = true; @@ -1019,15 +1018,14 @@ void InitListChecker::CheckScalarType(const InitializedEntity &Entity, } if (VerifyOnly) { - if (!SemaRef.CanPerformCopyInitialization(Entity, SemaRef.Owned(expr))) + if (!SemaRef.CanPerformCopyInitialization(Entity,expr)) hadError = true; ++Index; return; } ExprResult Result = - SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(), - SemaRef.Owned(expr), + SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(), expr, /*TopLevelOfInitList=*/true); Expr *ResultExpr = nullptr; @@ -1082,16 +1080,15 @@ void InitListChecker::CheckReferenceType(const InitializedEntity &Entity, } if (VerifyOnly) { - if (!SemaRef.CanPerformCopyInitialization(Entity, SemaRef.Owned(expr))) + if (!SemaRef.CanPerformCopyInitialization(Entity,expr)) hadError = true; ++Index; return; } ExprResult Result = - SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(), - SemaRef.Owned(expr), - /*TopLevelOfInitList=*/true); + SemaRef.PerformCopyInitialization(Entity, expr->getLocStart(), expr, + /*TopLevelOfInitList=*/true); if (Result.isInvalid()) hadError = true; @@ -1130,16 +1127,15 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity, Expr *Init = IList->getInit(Index); if (!isa(Init) && Init->getType()->isVectorType()) { if (VerifyOnly) { - if (!SemaRef.CanPerformCopyInitialization(Entity, SemaRef.Owned(Init))) + if (!SemaRef.CanPerformCopyInitialization(Entity, Init)) hadError = true; ++Index; return; } - ExprResult Result = - SemaRef.PerformCopyInitialization(Entity, Init->getLocStart(), - SemaRef.Owned(Init), - /*TopLevelOfInitList=*/true); + ExprResult Result = + SemaRef.PerformCopyInitialization(Entity, Init->getLocStart(), Init, + /*TopLevelOfInitList=*/true); Expr *ResultExpr = nullptr; if (Result.isInvalid()) @@ -2446,7 +2442,7 @@ ExprResult Sema::ActOnDesignatedInitializer(Designation &Desig, Diag(DIE->getLocStart(), diag::ext_designated_init) << DIE->getSourceRange(); - return Owned(DIE); + return DIE; } //===----------------------------------------------------------------------===// @@ -5010,7 +5006,7 @@ static ExprResult CopyObject(Sema &S, S.BuildCXXDefaultArgExpr(Loc, Constructor, Parm); } - return S.Owned(CurInitExpr); + return CurInitExpr; } // Determine the arguments required to actually perform the @@ -5169,7 +5165,7 @@ PerformConstructorInitialization(Sema &S, S.DefineImplicitDefaultConstructor(Loc, Constructor); } - ExprResult CurInit = S.Owned((Expr *)nullptr); + ExprResult CurInit((Expr *)nullptr); // C++ [over.match.copy]p1: // - When initializing a temporary to be bound to the first parameter @@ -5204,13 +5200,10 @@ PerformConstructorInitialization(Sema &S, ? SourceRange(LBraceLoc, RBraceLoc) : Kind.getParenRange(); - CurInit = S.Owned( - new (S.Context) CXXTemporaryObjectExpr(S.Context, Constructor, - TSInfo, ConstructorArgs, - ParenOrBraceRange, - HadMultipleCandidates, - IsListInitialization, - ConstructorInitRequiresZeroInit)); + CurInit = new (S.Context) CXXTemporaryObjectExpr( + S.Context, Constructor, TSInfo, ConstructorArgs, ParenOrBraceRange, + HadMultipleCandidates, IsListInitialization, + ConstructorInitRequiresZeroInit); } else { CXXConstructExpr::ConstructionKind ConstructKind = CXXConstructExpr::CK_Complete; @@ -5589,7 +5582,7 @@ InitializationSequence::Perform(Sema &S, // No steps means no initialization. if (Steps.empty()) - return S.Owned((Expr *)nullptr); + return ExprResult((Expr *)nullptr); if (S.getLangOpts().CPlusPlus11 && Entity.getType()->isReferenceType() && Args.size() == 1 && isa(Args[0]) && @@ -5622,7 +5615,7 @@ InitializationSequence::Perform(Sema &S, *ResultType = Entity.getDecl() ? Entity.getDecl()->getType() : Entity.getType(); - ExprResult CurInit = S.Owned((Expr *)nullptr); + ExprResult CurInit((Expr *)nullptr); // For initialization steps that start with a single initializer, // grab the only argument out the Args and place it into the "current" @@ -5721,11 +5714,9 @@ InitializationSequence::Perform(Sema &S, (Step->Kind == SK_CastDerivedToBaseXValue ? VK_XValue : VK_RValue); - CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, - Step->Type, - CK_DerivedToBase, - CurInit.get(), - &BasePath, VK)); + CurInit = + ImplicitCastExpr::Create(S.Context, Step->Type, CK_DerivedToBase, + CurInit.get(), &BasePath, VK); break; } @@ -5803,7 +5794,7 @@ InitializationSequence::Perform(Sema &S, MTE->getType().isDestructedType())) S.ExprNeedsCleanups = true; - CurInit = S.Owned(MTE); + CurInit = MTE; break; } @@ -5904,11 +5895,9 @@ InitializationSequence::Perform(Sema &S, } } - CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, - CurInit.get()->getType(), - CastKind, CurInit.get(), - nullptr, - CurInit.get()->getValueKind())); + CurInit = ImplicitCastExpr::Create(S.Context, CurInit.get()->getType(), + CastKind, CurInit.get(), nullptr, + CurInit.get()->getValueKind()); if (MaybeBindToTemp) CurInit = S.MaybeBindToTemporary(CurInit.getAs()); if (RequiresCopy) @@ -5933,11 +5922,9 @@ InitializationSequence::Perform(Sema &S, case SK_LValueToRValue: { assert(CurInit.get()->isGLValue() && "cannot load from a prvalue"); - CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, Step->Type, - CK_LValueToRValue, - CurInit.get(), - /*BasePath=*/nullptr, - VK_RValue)); + CurInit = ImplicitCastExpr::Create(S.Context, Step->Type, + CK_LValueToRValue, CurInit.get(), + /*BasePath=*/nullptr, VK_RValue); break; } @@ -5993,7 +5980,7 @@ InitializationSequence::Perform(Sema &S, CurInit.get(); CurInit = shouldBindAsTemporary(InitEntity) ? S.MaybeBindToTemporary(StructuredInitList) - : S.Owned(StructuredInitList); + : StructuredInitList; break; } @@ -6023,7 +6010,7 @@ InitializationSequence::Perform(Sema &S, } case SK_UnwrapInitList: - CurInit = S.Owned(cast(CurInit.get())->getInit(0)); + CurInit = cast(CurInit.get())->getInit(0); break; case SK_RewrapInitList: { @@ -6034,7 +6021,7 @@ InitializationSequence::Perform(Sema &S, ILE->setSyntacticForm(Syntactic); ILE->setType(E->getType()); ILE->setValueKind(E->getValueKind()); - CurInit = S.Owned(ILE); + CurInit = ILE; break; } @@ -6075,12 +6062,11 @@ InitializationSequence::Perform(Sema &S, TSInfo = S.Context.getTrivialTypeSourceInfo(Step->Type, Kind.getRange().getBegin()); - CurInit = S.Owned(new (S.Context) CXXScalarValueInitExpr( - TSInfo->getType().getNonLValueExprType(S.Context), - TSInfo, - Kind.getRange().getEnd())); + CurInit = new (S.Context) CXXScalarValueInitExpr( + TSInfo->getType().getNonLValueExprType(S.Context), TSInfo, + Kind.getRange().getEnd()); } else { - CurInit = S.Owned(new (S.Context) ImplicitValueInitExpr(Step->Type)); + CurInit = new (S.Context) ImplicitValueInitExpr(Step->Type); } break; } @@ -6165,16 +6151,15 @@ InitializationSequence::Perform(Sema &S, case SK_PassByIndirectCopyRestore: case SK_PassByIndirectRestore: checkIndirectCopyRestoreSource(S, CurInit.get()); - CurInit = S.Owned(new (S.Context) - ObjCIndirectCopyRestoreExpr(CurInit.get(), Step->Type, - Step->Kind == SK_PassByIndirectCopyRestore)); + CurInit = new (S.Context) ObjCIndirectCopyRestoreExpr( + CurInit.get(), Step->Type, + Step->Kind == SK_PassByIndirectCopyRestore); break; case SK_ProduceObjCObject: - CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, Step->Type, - CK_ARCProduceObject, - CurInit.get(), nullptr, - VK_RValue)); + CurInit = + ImplicitCastExpr::Create(S.Context, Step->Type, CK_ARCProduceObject, + CurInit.get(), nullptr, VK_RValue); break; case SK_StdInitializerList: { @@ -6197,8 +6182,7 @@ InitializationSequence::Perform(Sema &S, ExtendingEntity->getDecl()); // Wrap it in a construction of a std::initializer_list. - CurInit = S.Owned( - new (S.Context) CXXStdInitializerListExpr(Step->Type, MTE)); + CurInit = new (S.Context) CXXStdInitializerListExpr(Step->Type, MTE); // Bind the result, in case the library has given initializer_list a // non-trivial destructor. diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 5dea07b71e..8eb806ba30 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1156,7 +1156,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, InitializedEntity::InitializeResult(PropertyDiagLoc, getterMethod->getReturnType(), /*NRVO=*/false), - PropertyDiagLoc, Owned(IvarRefExpr)); + PropertyDiagLoc, IvarRefExpr); if (!Res.isInvalid()) { Expr *ResExpr = Res.getAs(); if (ResExpr) diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index f4f764c1fb..3a42332b40 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -806,8 +806,8 @@ StmtResult Sema::ActOnOpenMPParallelDirective(ArrayRef Clauses, getCurFunction()->setHasBranchProtectedScope(); - return Owned( - OMPParallelDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt)); + return OMPParallelDirective::Create(Context, StartLoc, EndLoc, Clauses, + AStmt); } StmtResult Sema::ActOnOpenMPSimdDirective(ArrayRef Clauses, @@ -828,8 +828,7 @@ StmtResult Sema::ActOnOpenMPSimdDirective(ArrayRef Clauses, // FIXME: Checking loop canonical form, collapsing etc. getCurFunction()->setHasBranchProtectedScope(); - return Owned( - OMPSimdDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt)); + return OMPSimdDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt); } OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, @@ -963,7 +962,7 @@ ExprResult Sema::VerifyPositiveIntegerConstantInClause(Expr *E, return ExprError(); if (E->isValueDependent() || E->isTypeDependent() || E->isInstantiationDependent() || E->containsUnexpandedParameterPack()) - return Owned(E); + return E; llvm::APSInt Result; ExprResult ICE = VerifyIntegerConstantExpression(E, &Result); if (ICE.isInvalid()) diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 7376d3a4f9..bfdf94ce42 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -61,7 +61,7 @@ CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn, NamedDecl *FoundDecl, S.MarkDeclRefReferenced(DRE); - ExprResult E = S.Owned(DRE); + ExprResult E = DRE; E = S.DefaultFunctionArrayConversion(E.get()); if (E.isInvalid()) return ExprError(); @@ -4557,7 +4557,7 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType, InitializedEntity Entity = InitializedEntity::InitializeParameter(S.Context, ToType, /*Consumed=*/false); - if (S.CanPerformCopyInitialization(Entity, S.Owned(From))) { + if (S.CanPerformCopyInitialization(Entity, From)) { Result.setUserDefined(); Result.UserDefined.Before.setAsIdentityConversion(); // Initializer lists don't have a type. @@ -4884,7 +4884,7 @@ Sema::PerformObjectArgumentInitialization(Expr *From, if (!Context.hasSameType(From->getType(), DestType)) From = ImpCastExprToType(From, DestType, CK_NoOp, From->getValueKind()).get(); - return Owned(From); + return From; } /// TryContextuallyConvertToBool - Attempt to contextually convert the @@ -5166,7 +5166,7 @@ diagnoseAmbiguousConversion(Sema &SemaRef, SourceLocation Loc, Expr *From, QualType ConvTy = Conv->getConversionType().getNonReferenceType(); Converter.noteAmbiguous(SemaRef, Conv, ConvTy); } - return SemaRef.Owned(From); + return From; } static bool @@ -5299,7 +5299,7 @@ ExprResult Sema::PerformContextualImplicitConversion( SourceLocation Loc, Expr *From, ContextualImplicitConverter &Converter) { // We can't perform any more checking for type-dependent expressions. if (From->isTypeDependent()) - return Owned(From); + return From; // Process placeholders immediately. if (From->hasPlaceholderType()) { @@ -5322,7 +5322,7 @@ ExprResult Sema::PerformContextualImplicitConversion( if (!RecordTy || !getLangOpts().CPlusPlus) { if (!Converter.Suppress) Converter.diagnoseNoMatch(*this, Loc, T) << From->getSourceRange(); - return Owned(From); + return From; } // We must have a complete class type. @@ -5339,7 +5339,7 @@ ExprResult Sema::PerformContextualImplicitConversion( } IncompleteDiagnoser(Converter, From); if (RequireCompleteType(Loc, T, IncompleteDiagnoser)) - return Owned(From); + return From; // Look for a conversion to an integral or enumeration type. UnresolvedSet<4> @@ -10153,7 +10153,7 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization( // Fix the expression to refer to 'fn'. SingleFunctionExpression = - Owned(FixOverloadedFunctionReference(SrcExpr.get(), found, fn)); + FixOverloadedFunctionReference(SrcExpr.get(), found, fn); // If desired, do function-to-pointer decay. if (doFunctionPointerConverion) { @@ -10546,7 +10546,7 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn, Context.DependentTy, VK_RValue, RParenLoc); CE->setTypeDependent(true); - *Result = Owned(CE); + *Result = CE; return true; } return false; @@ -10713,11 +10713,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, if (Input->isTypeDependent()) { if (Fns.empty()) - return Owned(new (Context) UnaryOperator(Input, - Opc, - Context.DependentTy, - VK_RValue, OK_Ordinary, - OpLoc)); + return new (Context) UnaryOperator(Input, Opc, Context.DependentTy, + VK_RValue, OK_Ordinary, OpLoc); CXXRecordDecl *NamingClass = nullptr; // lookup ignores member operators UnresolvedLookupExpr *Fn @@ -10725,10 +10722,9 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, NestedNameSpecifierLoc(), OpNameInfo, /*ADL*/ true, IsOverloaded(Fns), Fns.begin(), Fns.end()); - return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn, ArgsArray, - Context.DependentTy, - VK_RValue, - OpLoc, false)); + return new (Context) + CXXOperatorCallExpr(Context, Op, Fn, ArgsArray, Context.DependentTy, + VK_RValue, OpLoc, false); } // Build an empty overload set. @@ -10892,20 +10888,14 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // 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, - FPFeatures.fp_contract)); - - return Owned(new (Context) CompoundAssignOperator(Args[0], Args[1], Opc, - Context.DependentTy, - VK_LValue, - OK_Ordinary, - Context.DependentTy, - Context.DependentTy, - OpLoc, - FPFeatures.fp_contract)); + return new (Context) BinaryOperator( + Args[0], Args[1], Opc, Context.DependentTy, VK_RValue, OK_Ordinary, + OpLoc, FPFeatures.fp_contract); + + return new (Context) CompoundAssignOperator( + Args[0], Args[1], Opc, Context.DependentTy, VK_LValue, OK_Ordinary, + Context.DependentTy, Context.DependentTy, OpLoc, + FPFeatures.fp_contract); } // FIXME: save results of ADL from here? @@ -10917,9 +10907,9 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, NestedNameSpecifierLoc(), OpNameInfo, /*ADL*/ true, IsOverloaded(Fns), Fns.begin(), Fns.end()); - return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn, Args, - Context.DependentTy, VK_RValue, - OpLoc, FPFeatures.fp_contract)); + return new (Context) + CXXOperatorCallExpr(Context, Op, Fn, Args, Context.DependentTy, + VK_RValue, OpLoc, FPFeatures.fp_contract); } // Always do placeholder-like conversions on the RHS. @@ -10985,7 +10975,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, PerformCopyInitialization( InitializedEntity::InitializeParameter(Context, FnDecl->getParamDecl(0)), - SourceLocation(), Owned(Args[1])); + SourceLocation(), Args[1]); if (Arg1.isInvalid()) return ExprError(); @@ -11001,7 +10991,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, ExprResult Arg0 = PerformCopyInitialization( InitializedEntity::InitializeParameter(Context, FnDecl->getParamDecl(0)), - SourceLocation(), Owned(Args[0])); + SourceLocation(), Args[0]); if (Arg0.isInvalid()) return ExprError(); @@ -11009,7 +10999,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, PerformCopyInitialization( InitializedEntity::InitializeParameter(Context, FnDecl->getParamDecl(1)), - SourceLocation(), Owned(Args[1])); + SourceLocation(), Args[1]); if (Arg1.isInvalid()) return ExprError(); Args[0] = LHS = Arg0.getAs(); @@ -11168,11 +11158,9 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, UnresolvedSetIterator()); // Can't add any actual overloads yet - return Owned(new (Context) CXXOperatorCallExpr(Context, OO_Subscript, Fn, - Args, - Context.DependentTy, - VK_RValue, - RLoc, false)); + return new (Context) + CXXOperatorCallExpr(Context, OO_Subscript, Fn, Args, + Context.DependentTy, VK_RValue, RLoc, false); } // Handle placeholders on both operands. @@ -11222,7 +11210,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, Context, FnDecl->getParamDecl(0)), SourceLocation(), - Owned(Args[1])); + Args[1]); if (InputInit.isInvalid()) return ExprError(); @@ -11574,7 +11562,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, SourceLocation RParenLoc) { if (checkPlaceholderForOverload(*this, Obj)) return ExprError(); - ExprResult Object = Owned(Obj); + ExprResult Object = Obj; UnbridgedCastsSet UnbridgedCasts; if (checkArgPlaceholdersForOverload(*this, Args, UnbridgedCasts)) @@ -11728,9 +11716,9 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, if (Call.isInvalid()) return ExprError(); // Record usage of conversion in an implicit cast. - Call = Owned(ImplicitCastExpr::Create(Context, Call.get()->getType(), - CK_UserDefinedConversion, - Call.get(), nullptr, VK_RValue)); + Call = ImplicitCastExpr::Create(Context, Call.get()->getType(), + CK_UserDefinedConversion, Call.get(), + nullptr, VK_RValue); return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc); } @@ -12282,7 +12270,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, ExprResult Sema::FixOverloadedFunctionReference(ExprResult E, DeclAccessPair Found, FunctionDecl *Fn) { - return Owned(FixOverloadedFunctionReference((Expr *)E.get(), Found, Fn)); + return FixOverloadedFunctionReference(E.get(), Found, Fn); } } // end namespace clang diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 6aed635e5d..ec11daddf8 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -49,7 +49,7 @@ StmtResult Sema::ActOnExprStmt(ExprResult FE) { // operand, even incomplete types. // Same thing in for stmt first clause (when expr) and third clause. - return Owned(static_cast(FE.get())); + return StmtResult(FE.getAs()); } @@ -60,7 +60,7 @@ StmtResult Sema::ActOnExprStmtError() { StmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro) { - return Owned(new (Context) NullStmt(SemiLoc, HasLeadingEmptyMacro)); + return new (Context) NullStmt(SemiLoc, HasLeadingEmptyMacro); } StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc, @@ -70,7 +70,7 @@ StmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc, // If we have an invalid decl, just return an error. if (DG.isNull()) return StmtError(); - return Owned(new (Context) DeclStmt(DG, StartLoc, EndLoc)); + return new (Context) DeclStmt(DG, StartLoc, EndLoc); } void Sema::ActOnForEachDeclStmt(DeclGroupPtrTy dg) { @@ -344,7 +344,7 @@ StmtResult Sema::ActOnCompoundStmt(SourceLocation L, SourceLocation R, DiagnoseEmptyLoopBody(Elts[i], Elts[i + 1]); } - return Owned(new (Context) CompoundStmt(Context, Elts, L, R)); + return new (Context) CompoundStmt(Context, Elts, L, R); } StmtResult @@ -384,7 +384,7 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, Expr *LHSVal, CaseStmt *CS = new (Context) CaseStmt(LHSVal, RHSVal, CaseLoc, DotDotDotLoc, ColonLoc); getCurFunction()->SwitchStack.back()->addSwitchCase(CS); - return Owned(CS); + return CS; } /// ActOnCaseStmtBody - This installs a statement as the body of a case. @@ -402,12 +402,12 @@ Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, if (getCurFunction()->SwitchStack.empty()) { Diag(DefaultLoc, diag::err_default_not_in_switch); - return Owned(SubStmt); + return SubStmt; } DefaultStmt *DS = new (Context) DefaultStmt(DefaultLoc, ColonLoc, SubStmt); getCurFunction()->SwitchStack.back()->addSwitchCase(DS); - return Owned(DS); + return DS; } StmtResult @@ -417,7 +417,7 @@ Sema::ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, if (TheDecl->getStmt()) { Diag(IdentLoc, diag::err_redefinition_of_label) << TheDecl->getDeclName(); Diag(TheDecl->getLocation(), diag::note_previous_definition); - return Owned(SubStmt); + return SubStmt; } // Otherwise, things are good. Fill in the declaration and return it. @@ -427,7 +427,7 @@ Sema::ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, TheDecl->setLocStart(IdentLoc); TheDecl->setLocation(IdentLoc); } - return Owned(LS); + return LS; } StmtResult Sema::ActOnAttributedStmt(SourceLocation AttrLoc, @@ -435,7 +435,7 @@ StmtResult Sema::ActOnAttributedStmt(SourceLocation AttrLoc, Stmt *SubStmt) { // Fill in the declaration and return it. AttributedStmt *LS = AttributedStmt::Create(Context, AttrLoc, Attrs, SubStmt); - return Owned(LS); + return LS; } StmtResult @@ -471,8 +471,8 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar, DiagnoseUnusedExprResult(elseStmt); - return Owned(new (Context) IfStmt(Context, IfLoc, ConditionVar, ConditionExpr, - thenStmt, ElseLoc, elseStmt)); + return new (Context) IfStmt(Context, IfLoc, ConditionVar, ConditionExpr, + thenStmt, ElseLoc, elseStmt); } /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have @@ -661,7 +661,7 @@ Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, SwitchStmt *SS = new (Context) SwitchStmt(Context, ConditionVar, Cond); getCurFunction()->SwitchStack.push_back(SS); - return Owned(SS); + return SS; } static void AdjustAPSInt(llvm::APSInt &Val, unsigned BitWidth, bool IsSigned) { @@ -1151,7 +1151,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, if (CaseListIsErroneous) return StmtError(); - return Owned(SS); + return SS; } void @@ -1225,8 +1225,8 @@ Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond, if (isa(Body)) getCurCompoundScope().setHasEmptyLoopBodies(); - return Owned(new (Context) WhileStmt(Context, ConditionVar, ConditionExpr, - Body, WhileLoc)); + return new (Context) + WhileStmt(Context, ConditionVar, ConditionExpr, Body, WhileLoc); } StmtResult @@ -1248,7 +1248,7 @@ Sema::ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, DiagnoseUnusedExprResult(Body); - return Owned(new (Context) DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen)); + return new (Context) DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen); } namespace { @@ -1632,10 +1632,8 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, if (isa(Body)) getCurCompoundScope().setHasEmptyLoopBodies(); - return Owned(new (Context) ForStmt(Context, First, - SecondResult.get(), ConditionVar, - Third, Body, ForLoc, LParenLoc, - RParenLoc)); + return new (Context) ForStmt(Context, First, SecondResult.get(), ConditionVar, + Third, Body, ForLoc, LParenLoc, RParenLoc); } /// In an Objective C collection iteration statement: @@ -1661,7 +1659,7 @@ Sema::CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection) { return ExprError(); // Bail out early if we've got a type-dependent expression. - if (collection->isTypeDependent()) return Owned(collection); + if (collection->isTypeDependent()) return collection; // Perform normal l-value conversion. ExprResult result = DefaultFunctionArrayLvalueConversion(collection); @@ -1723,7 +1721,7 @@ Sema::CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection) { } // Wrap up any cleanups in the expression. - return Owned(collection); + return collection; } StmtResult @@ -1802,9 +1800,8 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc, if (CollectionExprResult.isInvalid()) return StmtError(); - return Owned(new (Context) ObjCForCollectionStmt(First, - CollectionExprResult.get(), - nullptr, ForLoc, RParenLoc)); + return new (Context) ObjCForCollectionStmt(First, CollectionExprResult.get(), + nullptr, ForLoc, RParenLoc); } /// Finish building a variable declaration for a for-range statement. @@ -2173,9 +2170,8 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation ColonLoc, // Find the array bound. ExprResult BoundExpr; if (const ConstantArrayType *CAT = dyn_cast(UnqAT)) - BoundExpr = Owned(IntegerLiteral::Create(Context, CAT->getSize(), - Context.getPointerDiffType(), - RangeLoc)); + BoundExpr = IntegerLiteral::Create( + Context, CAT->getSize(), Context.getPointerDiffType(), RangeLoc); else if (const VariableArrayType *VAT = dyn_cast(UnqAT)) BoundExpr = VAT->getSizeExpr(); @@ -2332,11 +2328,9 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation ColonLoc, if (Kind == BFRK_Check) return StmtResult(); - return Owned(new (Context) CXXForRangeStmt(RangeDS, - cast_or_null(BeginEndDecl.get()), - NotEqExpr.get(), IncrExpr.get(), - LoopVarDS, /*Body=*/nullptr, - ForLoc, ColonLoc, RParenLoc)); + return new (Context) CXXForRangeStmt( + RangeDS, cast_or_null(BeginEndDecl.get()), NotEqExpr.get(), + IncrExpr.get(), LoopVarDS, /*Body=*/nullptr, ForLoc, ColonLoc, RParenLoc); } /// FinishObjCForCollectionStmt - Attach the body to a objective-C foreach @@ -2375,7 +2369,7 @@ StmtResult Sema::ActOnGotoStmt(SourceLocation GotoLoc, LabelDecl *TheDecl) { getCurFunction()->setHasBranchIntoScope(); TheDecl->markUsed(Context); - return Owned(new (Context) GotoStmt(TheDecl, GotoLoc, LabelLoc)); + return new (Context) GotoStmt(TheDecl, GotoLoc, LabelLoc); } StmtResult @@ -2385,7 +2379,7 @@ Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, if (!E->isTypeDependent()) { QualType ETy = E->getType(); QualType DestTy = Context.getPointerType(Context.VoidTy.withConst()); - ExprResult ExprRes = Owned(E); + ExprResult ExprRes = E; AssignConvertType ConvTy = CheckSingleAssignmentConstraints(DestTy, ExprRes); if (ExprRes.isInvalid()) @@ -2402,7 +2396,7 @@ Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, getCurFunction()->setHasIndirectGoto(); - return Owned(new (Context) IndirectGotoStmt(GotoLoc, StarLoc, E)); + return new (Context) IndirectGotoStmt(GotoLoc, StarLoc, E); } StmtResult @@ -2413,7 +2407,7 @@ Sema::ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope) { return StmtError(Diag(ContinueLoc, diag::err_continue_not_in_loop)); } - return Owned(new (Context) ContinueStmt(ContinueLoc)); + return new (Context) ContinueStmt(ContinueLoc); } StmtResult @@ -2424,7 +2418,7 @@ Sema::ActOnBreakStmt(SourceLocation BreakLoc, Scope *CurScope) { return StmtError(Diag(BreakLoc, diag::err_break_not_in_loop_or_switch)); } - return Owned(new (Context) BreakStmt(BreakLoc)); + return new (Context) BreakStmt(BreakLoc); } /// \brief Determine whether the given expression is a candidate for @@ -2725,7 +2719,7 @@ Sema::ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { if (CurCap->HasImplicitReturnType || NRVOCandidate) FunctionScopes.back()->Returns.push_back(Result); - return Owned(Result); + return Result; } /// Deduce the return type for a function from a returned expression, per @@ -2921,7 +2915,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { D = diag::ext_return_has_void_expr; } else { - ExprResult Result = Owned(RetValExp); + ExprResult Result = RetValExp; Result = IgnoredValueConversions(Result.get()); if (Result.isInvalid()) return StmtError(); @@ -3034,7 +3028,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { if (Result->getNRVOCandidate()) FunctionScopes.back()->Returns.push_back(Result); - return Owned(Result); + return Result; } StmtResult @@ -3045,12 +3039,12 @@ Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc, if (Var && Var->isInvalidDecl()) return StmtError(); - return Owned(new (Context) ObjCAtCatchStmt(AtLoc, RParen, Var, Body)); + return new (Context) ObjCAtCatchStmt(AtLoc, RParen, Var, Body); } StmtResult Sema::ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body) { - return Owned(new (Context) ObjCAtFinallyStmt(AtLoc, Body)); + return new (Context) ObjCAtFinallyStmt(AtLoc, Body); } StmtResult @@ -3061,10 +3055,8 @@ Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, getCurFunction()->setHasBranchProtectedScope(); unsigned NumCatchStmts = CatchStmts.size(); - return Owned(ObjCAtTryStmt::Create(Context, AtLoc, Try, - CatchStmts.data(), - NumCatchStmts, - Finally)); + return ObjCAtTryStmt::Create(Context, AtLoc, Try, CatchStmts.data(), + NumCatchStmts, Finally); } StmtResult Sema::BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw) { @@ -3089,7 +3081,7 @@ StmtResult Sema::BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw) { } } - return Owned(new (Context) ObjCAtThrowStmt(AtLoc, Throw)); + return new (Context) ObjCAtThrowStmt(AtLoc, Throw); } StmtResult @@ -3136,7 +3128,7 @@ Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SyncExpr, Stmt *SyncBody) { // We can't jump into or indirect-jump out of a @synchronized block. getCurFunction()->setHasBranchProtectedScope(); - return Owned(new (Context) ObjCAtSynchronizedStmt(AtLoc, SyncExpr, SyncBody)); + return new (Context) ObjCAtSynchronizedStmt(AtLoc, SyncExpr, SyncBody); } /// ActOnCXXCatchBlock - Takes an exception declaration and a handler block @@ -3145,15 +3137,14 @@ StmtResult Sema::ActOnCXXCatchBlock(SourceLocation CatchLoc, Decl *ExDecl, Stmt *HandlerBlock) { // There's nothing to test that ActOnExceptionDecl didn't already test. - return Owned(new (Context) CXXCatchStmt(CatchLoc, - cast_or_null(ExDecl), - HandlerBlock)); + return new (Context) + CXXCatchStmt(CatchLoc, cast_or_null(ExDecl), HandlerBlock); } StmtResult Sema::ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body) { getCurFunction()->setHasBranchProtectedScope(); - return Owned(new (Context) ObjCAutoreleasePoolStmt(AtLoc, Body)); + return new (Context) ObjCAutoreleasePoolStmt(AtLoc, Body); } namespace { @@ -3247,7 +3238,7 @@ StmtResult Sema::ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, // Neither of these are explicitly forbidden, but every compiler detects them // and warns. - return Owned(CXXTryStmt::Create(Context, TryLoc, TryBlock, Handlers)); + return CXXTryStmt::Create(Context, TryLoc, TryBlock, Handlers); } StmtResult @@ -3259,7 +3250,7 @@ Sema::ActOnSEHTryBlock(bool IsCXXTry, getCurFunction()->setHasBranchProtectedScope(); - return Owned(SEHTryStmt::Create(Context,IsCXXTry,TryLoc,TryBlock,Handler)); + return SEHTryStmt::Create(Context,IsCXXTry,TryLoc,TryBlock,Handler); } StmtResult @@ -3274,14 +3265,14 @@ Sema::ActOnSEHExceptBlock(SourceLocation Loc, << FilterExpr->getType()); } - return Owned(SEHExceptStmt::Create(Context,Loc,FilterExpr,Block)); + return SEHExceptStmt::Create(Context,Loc,FilterExpr,Block); } StmtResult Sema::ActOnSEHFinallyBlock(SourceLocation Loc, Stmt *Block) { assert(Block); - return Owned(SEHFinallyStmt::Create(Context,Loc,Block)); + return SEHFinallyStmt::Create(Context,Loc,Block); } StmtResult Sema::BuildMSDependentExistsStmt(SourceLocation KeywordLoc, @@ -3474,5 +3465,5 @@ StmtResult Sema::ActOnCapturedRegionEnd(Stmt *S) { PopDeclContext(); PopFunctionScopeInfo(); - return Owned(Res); + return Res; } diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index 955772a49d..276ead78be 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -364,7 +364,7 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, return StmtError(); } - return Owned(NS); + return NS; } ExprResult Sema::LookupInlineAsmIdentifier(CXXScopeSpec &SS, @@ -484,5 +484,5 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, /*IsVolatile*/ true, AsmToks, NumOutputs, NumInputs, Constraints, Exprs, AsmString, Clobbers, EndLoc); - return Owned(NS); + return NS; } diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index e4ab2bd1a6..92197e43e2 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -421,15 +421,10 @@ Sema::ActOnDependentIdExpression(const CXXScopeSpec &SS, // perform the double-lookup check. NamedDecl *FirstQualifierInScope = nullptr; - return Owned(CXXDependentScopeMemberExpr::Create(Context, - /*This*/ nullptr, ThisType, - /*IsArrow*/ true, - /*Op*/ SourceLocation(), - SS.getWithLocInContext(Context), - TemplateKWLoc, - FirstQualifierInScope, - NameInfo, - TemplateArgs)); + return CXXDependentScopeMemberExpr::Create( + Context, /*This*/ nullptr, ThisType, /*IsArrow*/ true, + /*Op*/ SourceLocation(), SS.getWithLocInContext(Context), TemplateKWLoc, + FirstQualifierInScope, NameInfo, TemplateArgs); } return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs); @@ -440,11 +435,9 @@ Sema::BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs) { - return Owned(DependentScopeDeclRefExpr::Create(Context, - SS.getWithLocInContext(Context), - TemplateKWLoc, - NameInfo, - TemplateArgs)); + return DependentScopeDeclRefExpr::Create( + Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo, + TemplateArgs); } /// DiagnoseTemplateParameterShadow - Produce a diagnostic complaining @@ -2869,7 +2862,7 @@ ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS, RequiresADL, TemplateArgs, R.begin(), R.end()); - return Owned(ULE); + return ULE; } // We actually only call this from template instantiation. @@ -3452,11 +3445,9 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, // so it was provided with a template keyword. However, its source // location is not stored in the template argument structure. SourceLocation TemplateKWLoc; - ExprResult E = Owned(DependentScopeDeclRefExpr::Create(Context, - SS.getWithLocInContext(Context), - TemplateKWLoc, - NameInfo, - nullptr)); + ExprResult E = DependentScopeDeclRefExpr::Create( + Context, SS.getWithLocInContext(Context), TemplateKWLoc, NameInfo, + nullptr); // If we parsed the template argument as a pack expansion, create a // pack expansion expression. @@ -4732,7 +4723,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, if (InstantiatedParamType->isDependentType() || Arg->isTypeDependent()) { // FIXME: Produce a cloned, canonical expression? Converted = TemplateArgument(Arg); - return Owned(Arg); + return Arg; } // C++ [temp.arg.nontype]p5: @@ -4776,7 +4767,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // we should be able to diagnose that prior to instantiation. if (Arg->isValueDependent()) { Converted = TemplateArgument(Arg); - return Owned(Arg); + return Arg; } // C++ [temp.arg.nontype]p1: @@ -4878,7 +4869,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // The argument is value-dependent. Create a new // TemplateArgument with the converted expression. Converted = TemplateArgument(Arg); - return Owned(Arg); + return Arg; } QualType IntegerType = Context.getCanonicalType(ParamType); @@ -4932,7 +4923,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, ParamType->isEnumeralType() ? Context.getCanonicalType(ParamType) : IntegerType); - return Owned(Arg); + return Arg; } QualType ArgType = Arg->getType(); @@ -4980,13 +4971,13 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, ParamType, Arg, Converted)) return ExprError(); - return Owned(Arg); + return Arg; } if (CheckTemplateArgumentPointerToMember(*this, Param, ParamType, Arg, Converted)) return ExprError(); - return Owned(Arg); + return Arg; } if (ParamType->isPointerType()) { @@ -5001,7 +4992,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, ParamType, Arg, Converted)) return ExprError(); - return Owned(Arg); + return Arg; } if (const ReferenceType *ParamRefType = ParamType->getAs()) { @@ -5032,14 +5023,14 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, ParamType, Arg, Converted)) return ExprError(); - return Owned(Arg); + return Arg; } // Deal with parameters of type std::nullptr_t. if (ParamType->isNullPtrType()) { if (Arg->isTypeDependent() || Arg->isValueDependent()) { Converted = TemplateArgument(Arg); - return Owned(Arg); + return Arg; } switch (isNullPointerValueTemplateArgument(*this, Param, ParamType, Arg)) { @@ -5055,7 +5046,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, case NPV_NullPointer: Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null); Converted = TemplateArgument(ParamType, /*isNullPtr*/true); - return Owned(Arg); + return Arg; } } @@ -5066,7 +5057,7 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, if (CheckTemplateArgumentPointerToMember(*this, Param, ParamType, Arg, Converted)) return ExprError(); - return Owned(Arg); + return Arg; } /// \brief Check a template argument against its corresponding @@ -5295,7 +5286,7 @@ Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, Loc, Loc); } - return Owned(E); + return E; } /// \brief Match two template parameters within template parameter lists. diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index bca7f4d69d..4072766093 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -1084,7 +1084,7 @@ TemplateName TemplateInstantiator::TransformTemplateName(CXXScopeSpec &SS, ExprResult TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) { if (!E->isTypeDependent()) - return SemaRef.Owned(E); + return E; return getSema().BuildPredefinedExpr(E->getLocation(), E->getIdentType()); } @@ -1098,7 +1098,7 @@ TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E, // arguments left unspecified. if (!TemplateArgs.hasTemplateArgument(NTTP->getDepth(), NTTP->getPosition())) - return SemaRef.Owned(E); + return E; TemplateArgument Arg = TemplateArgs(NTTP->getDepth(), NTTP->getPosition()); if (NTTP->isParameterPack()) { @@ -1138,7 +1138,7 @@ ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( // case we just return that expression. if (arg.getKind() == TemplateArgument::Expression) { Expr *argExpr = arg.getAsExpr(); - result = SemaRef.Owned(argExpr); + result = argExpr; type = argExpr->getType(); } else if (arg.getKind() == TemplateArgument::Declaration || @@ -1186,10 +1186,8 @@ ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( if (result.isInvalid()) return ExprError(); Expr *resultExpr = result.get(); - return SemaRef.Owned(new (SemaRef.Context) - SubstNonTypeTemplateParmExpr(type, - resultExpr->getValueKind(), - loc, parm, resultExpr)); + return new (SemaRef.Context) SubstNonTypeTemplateParmExpr( + type, resultExpr->getValueKind(), loc, parm, resultExpr); } ExprResult @@ -1197,7 +1195,7 @@ TemplateInstantiator::TransformSubstNonTypeTemplateParmPackExpr( SubstNonTypeTemplateParmPackExpr *E) { if (getSema().ArgumentPackSubstitutionIndex == -1) { // We aren't expanding the parameter pack, so just return ourselves. - return getSema().Owned(E); + return E; } TemplateArgument Arg = E->getArgumentPack(); @@ -2571,7 +2569,7 @@ Sema::InstantiateClassTemplateSpecializationMembers( StmtResult Sema::SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs) { if (!S) - return Owned(S); + return S; TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(), @@ -2582,7 +2580,7 @@ Sema::SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs) { ExprResult Sema::SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs) { if (!E) - return Owned(E); + return E; TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(), diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 9ecd8d082e..5635bea63d 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -741,7 +741,7 @@ void TemplateDeclInstantiator::InstantiateEnumDefinition( EnumConstantDecl *LastEnumConst = nullptr; for (auto *EC : Pattern->enumerators()) { // The specified value for the enumerator. - ExprResult Value = SemaRef.Owned((Expr *)nullptr); + ExprResult Value((Expr *)nullptr); if (Expr *UninstValue = EC->getInitExpr()) { // The enumerator's value expression is a constant expression. EnterExpressionEvaluationContext Unevaluated(SemaRef, @@ -753,7 +753,7 @@ void TemplateDeclInstantiator::InstantiateEnumDefinition( // Drop the initial value and continue. bool isInvalid = false; if (Value.isInvalid()) { - Value = SemaRef.Owned((Expr *)nullptr); + Value = nullptr; isInvalid = true; } diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp index 9480c11e6f..8e4ce0d9da 100644 --- a/lib/Sema/SemaTemplateVariadic.cpp +++ b/lib/Sema/SemaTemplateVariadic.cpp @@ -509,8 +509,8 @@ ExprResult Sema::CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, } // Create the pack expansion expression and source-location information. - return Owned(new (Context) PackExpansionExpr(Context.DependentTy, Pattern, - EllipsisLoc, NumExpansions)); + return new (Context) + PackExpansionExpr(Context.DependentTy, Pattern, EllipsisLoc, NumExpansions); } /// \brief Retrieve the depth and index of a parameter pack. diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index ac31da2a1e..d2683bec64 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -1741,7 +1741,7 @@ public: Member, MemberNameInfo, cast(Member)->getType(), VK, OK_Ordinary); - return getSema().Owned(ME); + return ME; } CXXScopeSpec SS; @@ -1872,7 +1872,7 @@ public: /// any semantic analysis. Subclasses may override this routine to provide /// different behavior. ExprResult RebuildImplicitValueInitExpr(QualType T) { - return SemaRef.Owned(new (SemaRef.Context) ImplicitValueInitExpr(T)); + return new (SemaRef.Context) ImplicitValueInitExpr(T); } /// \brief Build a new \c va_arg expression. @@ -2137,9 +2137,7 @@ public: QualType ThisType, bool isImplicit) { getSema().CheckCXXThisCapture(ThisLoc); - return getSema().Owned( - new (getSema().Context) CXXThisExpr(ThisLoc, ThisType, - isImplicit)); + return new (getSema().Context) CXXThisExpr(ThisLoc, ThisType, isImplicit); } /// \brief Build a new C++ throw expression. @@ -2158,8 +2156,7 @@ public: /// provide different behavior. ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, ParmVarDecl *Param) { - return getSema().Owned(CXXDefaultArgExpr::Create(getSema().Context, Loc, - Param)); + return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param); } /// \brief Build a new C++11 default-initialization expression. @@ -2169,8 +2166,7 @@ public: /// routine to provide different behavior. ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field) { - return getSema().Owned(CXXDefaultInitExpr::Create(getSema().Context, Loc, - Field)); + return CXXDefaultInitExpr::Create(getSema().Context, Loc, Field); } /// \brief Build a new C++ zero-initialization expression. @@ -2459,8 +2455,7 @@ public: ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, TypeSourceInfo *EncodeTypeInfo, SourceLocation RParenLoc) { - return SemaRef.Owned(SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo, - RParenLoc)); + return SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo, RParenLoc); } /// \brief Build a new Objective-C class message. @@ -2502,7 +2497,7 @@ public: bool IsArrow, bool IsFreeIvar) { // FIXME: We lose track of the IsFreeIvar bit. CXXScopeSpec SS; - ExprResult Base = getSema().Owned(BaseArg); + ExprResult Base = BaseArg; LookupResult R(getSema(), Ivar->getDeclName(), IvarLoc, Sema::LookupMemberName); ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow, @@ -2531,7 +2526,7 @@ public: ObjCPropertyDecl *Property, SourceLocation PropertyLoc) { CXXScopeSpec SS; - ExprResult Base = getSema().Owned(BaseArg); + ExprResult Base = BaseArg; LookupResult R(getSema(), Property->getDeclName(), PropertyLoc, Sema::LookupMemberName); bool IsArrow = false; @@ -2575,7 +2570,7 @@ public: SourceLocation OpLoc, bool IsArrow) { CXXScopeSpec SS; - ExprResult Base = getSema().Owned(BaseArg); + ExprResult Base = BaseArg; LookupResult R(getSema(), &getSema().Context.Idents.get("isa"), IsaLoc, Sema::LookupMemberName); ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow, @@ -2619,9 +2614,9 @@ public: CK_BuiltinFnToFnPtr).get(); // Build the CallExpr - ExprResult TheCall = SemaRef.Owned(new (SemaRef.Context) CallExpr( + ExprResult TheCall = new (SemaRef.Context) CallExpr( SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(), - Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc)); + Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc); // Type-check the __builtin_shufflevector expression. return SemaRef.SemaBuiltinShuffleVector(cast(TheCall.get())); @@ -2728,7 +2723,7 @@ private: template StmtResult TreeTransform::TransformStmt(Stmt *S) { if (!S) - return SemaRef.Owned(S); + return S; switch (S->getStmtClass()) { case Stmt::NoStmtClass: break; @@ -2754,7 +2749,7 @@ StmtResult TreeTransform::TransformStmt(Stmt *S) { } } - return SemaRef.Owned(S); + return S; } template @@ -2778,7 +2773,7 @@ OMPClause *TreeTransform::TransformOMPClause(OMPClause *S) { template ExprResult TreeTransform::TransformExpr(Expr *E) { if (!E) - return SemaRef.Owned(E); + return E; switch (E->getStmtClass()) { case Stmt::NoStmtClass: break; @@ -2789,7 +2784,7 @@ ExprResult TreeTransform::TransformExpr(Expr *E) { #include "clang/AST/StmtNodes.inc" } - return SemaRef.Owned(E); + return E; } template @@ -2798,7 +2793,7 @@ ExprResult TreeTransform::TransformInitializer(Expr *Init, // Initializers are instantiated like expressions, except that various outer // layers are stripped. if (!Init) - return SemaRef.Owned(Init); + return Init; if (ExprWithCleanups *ExprTemp = dyn_cast(Init)) Init = ExprTemp->getSubExpr(); @@ -5313,7 +5308,7 @@ TreeTransform::TransformObjCObjectPointerType(TypeLocBuilder &TLB, template StmtResult TreeTransform::TransformNullStmt(NullStmt *S) { - return SemaRef.Owned(S); + return S; } template @@ -5353,7 +5348,7 @@ TreeTransform::TransformCompoundStmt(CompoundStmt *S, if (!getDerived().AlwaysRebuild() && !SubStmtChanged) - return SemaRef.Owned(S); + return S; return getDerived().RebuildCompoundStmt(S->getLBracLoc(), Statements, @@ -5500,7 +5495,7 @@ TreeTransform::TransformIfStmt(IfStmt *S) { ConditionVar == S->getConditionVariable() && Then.get() == S->getThen() && Else.get() == S->getElse()) - return SemaRef.Owned(S); + return S; return getDerived().RebuildIfStmt(S->getIfLoc(), FullCond, ConditionVar, Then.get(), @@ -5611,7 +5606,7 @@ TreeTransform::TransformDoStmt(DoStmt *S) { if (!getDerived().AlwaysRebuild() && Cond.get() == S->getCond() && Body.get() == S->getBody()) - return SemaRef.Owned(S); + return S; return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(), /*FIXME:*/S->getWhileLoc(), Cond.get(), @@ -5678,7 +5673,7 @@ TreeTransform::TransformForStmt(ForStmt *S) { FullCond.get() == S->getCond() && Inc.get() == S->getInc() && Body.get() == S->getBody()) - return SemaRef.Owned(S); + return S; return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(), Init.get(), FullCond, ConditionVar, @@ -5708,7 +5703,7 @@ TreeTransform::TransformIndirectGotoStmt(IndirectGotoStmt *S) { if (!getDerived().AlwaysRebuild() && Target.get() == S->getTarget()) - return SemaRef.Owned(S); + return S; return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(), Target.get()); @@ -5717,13 +5712,13 @@ TreeTransform::TransformIndirectGotoStmt(IndirectGotoStmt *S) { template StmtResult TreeTransform::TransformContinueStmt(ContinueStmt *S) { - return SemaRef.Owned(S); + return S; } template StmtResult TreeTransform::TransformBreakStmt(BreakStmt *S) { - return SemaRef.Owned(S); + return S; } template @@ -5755,7 +5750,7 @@ TreeTransform::TransformDeclStmt(DeclStmt *S) { } if (!getDerived().AlwaysRebuild() && !DeclChanged) - return SemaRef.Owned(S); + return S; return getDerived().RebuildDeclStmt(Decls, S->getStartLoc(), S->getEndLoc()); } @@ -5810,14 +5805,14 @@ TreeTransform::TransformGCCAsmStmt(GCCAsmStmt *S) { } if (!getDerived().AlwaysRebuild() && !ExprsChanged) - return SemaRef.Owned(S); + return S; // Go through the clobbers. for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) Clobbers.push_back(S->getClobberStringLiteral(I)); // No need to transform the asm string literal. - AsmString = SemaRef.Owned(S->getAsmString()); + AsmString = S->getAsmString(); return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(), S->isVolatile(), S->getNumOutputs(), S->getNumInputs(), Names.data(), @@ -5890,7 +5885,7 @@ TreeTransform::TransformObjCAtTryStmt(ObjCAtTryStmt *S) { TryBody.get() == S->getTryBody() && !AnyCatchChanged && Finally.get() == S->getFinallyStmt()) - return SemaRef.Owned(S); + return S; // Build a new statement. return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(), @@ -5944,7 +5939,7 @@ TreeTransform::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { // If nothing changed, just retain this statement. if (!getDerived().AlwaysRebuild() && Body.get() == S->getFinallyBody()) - return SemaRef.Owned(S); + return S; // Build a new statement. return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(), @@ -5963,7 +5958,7 @@ TreeTransform::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) { if (!getDerived().AlwaysRebuild() && Operand.get() == S->getThrowExpr()) - return getSema().Owned(S); + return S; return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get()); } @@ -5991,7 +5986,7 @@ TreeTransform::TransformObjCAtSynchronizedStmt( if (!getDerived().AlwaysRebuild() && Object.get() == S->getSynchExpr() && Body.get() == S->getSynchBody()) - return SemaRef.Owned(S); + return S; // Build a new statement. return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(), @@ -6010,7 +6005,7 @@ TreeTransform::TransformObjCAutoreleasePoolStmt( // If nothing changed, just retain this statement. if (!getDerived().AlwaysRebuild() && Body.get() == S->getSubStmt()) - return SemaRef.Owned(S); + return S; // Build a new statement. return getDerived().RebuildObjCAutoreleasePoolStmt( @@ -6041,7 +6036,7 @@ TreeTransform::TransformObjCForCollectionStmt( Element.get() == S->getElement() && Collection.get() == S->getCollection() && Body.get() == S->getBody()) - return SemaRef.Owned(S); + return S; // Build a new statement. return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(), @@ -6075,7 +6070,7 @@ StmtResult TreeTransform::TransformCXXCatchStmt(CXXCatchStmt *S) { if (!getDerived().AlwaysRebuild() && !Var && Handler.get() == S->getHandlerBlock()) - return SemaRef.Owned(S); + return S; return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get()); } @@ -6101,7 +6096,7 @@ StmtResult TreeTransform::TransformCXXTryStmt(CXXTryStmt *S) { if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() && !HandlerChanged) - return SemaRef.Owned(S); + return S; return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(), Handlers); @@ -6171,7 +6166,7 @@ TreeTransform::TransformCXXForRangeStmt(CXXForRangeStmt *S) { } if (NewStmt.get() == S) - return SemaRef.Owned(S); + return S; return FinishCXXForRangeStmt(NewStmt.get(), Body.get()); } @@ -6283,7 +6278,7 @@ StmtResult TreeTransform::TransformSEHTryStmt(SEHTryStmt *S) { if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() && Handler.get() == S->getHandler()) - return SemaRef.Owned(S); + return S; return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(), TryBlock.get(), Handler.get()); @@ -6534,7 +6529,7 @@ TreeTransform::TransformOMPCopyinClause(OMPCopyinClause *C) { template ExprResult TreeTransform::TransformPredefinedExpr(PredefinedExpr *E) { - return SemaRef.Owned(E); + return E; } template @@ -6571,7 +6566,7 @@ TreeTransform::TransformDeclRefExpr(DeclRefExpr *E) { // FIXME: this is a bit instantiation-specific. SemaRef.MarkDeclRefReferenced(E); - return SemaRef.Owned(E); + return E; } TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr; @@ -6592,31 +6587,31 @@ TreeTransform::TransformDeclRefExpr(DeclRefExpr *E) { template ExprResult TreeTransform::TransformIntegerLiteral(IntegerLiteral *E) { - return SemaRef.Owned(E); + return E; } template ExprResult TreeTransform::TransformFloatingLiteral(FloatingLiteral *E) { - return SemaRef.Owned(E); + return E; } template ExprResult TreeTransform::TransformImaginaryLiteral(ImaginaryLiteral *E) { - return SemaRef.Owned(E); + return E; } template ExprResult TreeTransform::TransformStringLiteral(StringLiteral *E) { - return SemaRef.Owned(E); + return E; } template ExprResult TreeTransform::TransformCharacterLiteral(CharacterLiteral *E) { - return SemaRef.Owned(E); + return E; } template @@ -6670,7 +6665,7 @@ TreeTransform::TransformParenExpr(ParenExpr *E) { return ExprError(); if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(), E->getRParen()); @@ -6700,7 +6695,7 @@ TreeTransform::TransformUnaryOperator(UnaryOperator *E) { return ExprError(); if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildUnaryOperator(E->getOperatorLoc(), E->getOpcode(), @@ -6765,7 +6760,7 @@ TreeTransform::TransformOffsetOfExpr(OffsetOfExpr *E) { if (!getDerived().AlwaysRebuild() && Type == E->getTypeSourceInfo() && !ExprChanged) - return SemaRef.Owned(E); + return E; // Build a new offsetof expression. return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type, @@ -6778,7 +6773,7 @@ ExprResult TreeTransform::TransformOpaqueValueExpr(OpaqueValueExpr *E) { assert(getDerived().AlreadyTransformed(E->getType()) && "opaque value expression requires transformation"); - return SemaRef.Owned(E); + return E; } template @@ -6815,7 +6810,7 @@ TreeTransform::TransformUnaryExprOrTypeTraitExpr( return ExprError(); if (!getDerived().AlwaysRebuild() && OldT == NewT) - return SemaRef.Owned(E); + return E; return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(), E->getKind(), @@ -6833,7 +6828,7 @@ TreeTransform::TransformUnaryExprOrTypeTraitExpr( return ExprError(); if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(), E->getOperatorLoc(), @@ -6856,7 +6851,7 @@ TreeTransform::TransformArraySubscriptExpr(ArraySubscriptExpr *E) { if (!getDerived().AlwaysRebuild() && LHS.get() == E->getLHS() && RHS.get() == E->getRHS()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildArraySubscriptExpr(LHS.get(), /*FIXME:*/E->getLHS()->getLocStart(), @@ -6936,7 +6931,7 @@ TreeTransform::TransformMemberExpr(MemberExpr *E) { // FIXME: this is a bit instantiation-specific. SemaRef.MarkMemberReferenced(E); - return SemaRef.Owned(E); + return E; } TemplateArgumentListInfo TransArgs; @@ -6985,7 +6980,7 @@ TreeTransform::TransformBinaryOperator(BinaryOperator *E) { if (!getDerived().AlwaysRebuild() && LHS.get() == E->getLHS() && RHS.get() == E->getRHS()) - return SemaRef.Owned(E); + return E; Sema::FPContractStateRAII FPContractState(getSema()); getSema().FPFeatures.fp_contract = E->isFPContractable(); @@ -7018,7 +7013,7 @@ TransformBinaryConditionalOperator(BinaryConditionalOperator *e) { if (!getDerived().AlwaysRebuild() && commonExpr.get() == e->getCommon() && rhs.get() == e->getFalseExpr()) - return SemaRef.Owned(e); + return e; return getDerived().RebuildConditionalOperator(commonExpr.get(), e->getQuestionLoc(), @@ -7046,7 +7041,7 @@ TreeTransform::TransformConditionalOperator(ConditionalOperator *E) { Cond.get() == E->getCond() && LHS.get() == E->getLHS() && RHS.get() == E->getRHS()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildConditionalOperator(Cond.get(), E->getQuestionLoc(), @@ -7078,7 +7073,7 @@ TreeTransform::TransformCStyleCastExpr(CStyleCastExpr *E) { if (!getDerived().AlwaysRebuild() && Type == E->getTypeInfoAsWritten() && SubExpr.get() == E->getSubExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(), Type, @@ -7121,7 +7116,7 @@ TreeTransform::TransformExtVectorElementExpr(ExtVectorElementExpr *E) { if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase()) - return SemaRef.Owned(E); + return E; // FIXME: Bad source location SourceLocation FakeOperatorLoc = @@ -7142,7 +7137,7 @@ TreeTransform::TransformInitListExpr(InitListExpr *E) { return ExprError(); if (!getDerived().AlwaysRebuild() && !InitChanged) - return SemaRef.Owned(E); + return E; return getDerived().RebuildInitList(E->getLBraceLoc(), Inits, E->getRBraceLoc(), E->getType()); @@ -7209,7 +7204,7 @@ TreeTransform::TransformDesignatedInitExpr(DesignatedInitExpr *E) { if (!getDerived().AlwaysRebuild() && Init.get() == E->getInit() && !ExprChanged) - return SemaRef.Owned(E); + return E; return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs, E->getEqualOrColonLoc(), @@ -7230,7 +7225,7 @@ TreeTransform::TransformImplicitValueInitExpr( if (!getDerived().AlwaysRebuild() && T == E->getType()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildImplicitValueInitExpr(T); } @@ -7249,7 +7244,7 @@ TreeTransform::TransformVAArgExpr(VAArgExpr *E) { if (!getDerived().AlwaysRebuild() && TInfo == E->getWrittenTypeInfo() && SubExpr.get() == E->getSubExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(), TInfo, E->getRParenLoc()); @@ -7328,7 +7323,7 @@ TreeTransform::TransformChooseExpr(ChooseExpr *E) { Cond.get() == E->getCond() && LHS.get() == E->getLHS() && RHS.get() == E->getRHS()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildChooseExpr(E->getBuiltinLoc(), Cond.get(), LHS.get(), RHS.get(), @@ -7338,7 +7333,7 @@ TreeTransform::TransformChooseExpr(ChooseExpr *E) { template ExprResult TreeTransform::TransformGNUNullExpr(GNUNullExpr *E) { - return SemaRef.Owned(E); + return E; } template @@ -7480,7 +7475,7 @@ TreeTransform::TransformCXXNamedCastExpr(CXXNamedCastExpr *E) { if (!getDerived().AlwaysRebuild() && Type == E->getTypeInfoAsWritten() && SubExpr.get() == E->getSubExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXNamedCastExpr(E->getOperatorLoc(), E->getStmtClass(), E->getAngleBrackets().getBegin(), @@ -7533,7 +7528,7 @@ TreeTransform::TransformCXXFunctionalCastExpr( if (!getDerived().AlwaysRebuild() && Type == E->getTypeInfoAsWritten() && SubExpr.get() == E->getSubExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXFunctionalCastExpr(Type, E->getLParenLoc(), @@ -7552,7 +7547,7 @@ TreeTransform::TransformCXXTypeidExpr(CXXTypeidExpr *E) { if (!getDerived().AlwaysRebuild() && TInfo == E->getTypeOperandSourceInfo()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getLocStart(), @@ -7573,7 +7568,7 @@ TreeTransform::TransformCXXTypeidExpr(CXXTypeidExpr *E) { if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getExprOperand()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getLocStart(), @@ -7592,7 +7587,7 @@ TreeTransform::TransformCXXUuidofExpr(CXXUuidofExpr *E) { if (!getDerived().AlwaysRebuild() && TInfo == E->getTypeOperandSourceInfo()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getLocStart(), @@ -7608,7 +7603,7 @@ TreeTransform::TransformCXXUuidofExpr(CXXUuidofExpr *E) { if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getExprOperand()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getLocStart(), @@ -7619,14 +7614,14 @@ TreeTransform::TransformCXXUuidofExpr(CXXUuidofExpr *E) { template ExprResult TreeTransform::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { - return SemaRef.Owned(E); + return E; } template ExprResult TreeTransform::TransformCXXNullPtrLiteralExpr( CXXNullPtrLiteralExpr *E) { - return SemaRef.Owned(E); + return E; } template @@ -7637,7 +7632,7 @@ TreeTransform::TransformCXXThisExpr(CXXThisExpr *E) { if (!getDerived().AlwaysRebuild() && T == E->getType()) { // Make sure that we capture 'this'. getSema().CheckCXXThisCapture(E->getLocStart()); - return SemaRef.Owned(E); + return E; } return getDerived().RebuildCXXThisExpr(E->getLocStart(), T, E->isImplicit()); @@ -7652,7 +7647,7 @@ TreeTransform::TransformCXXThrowExpr(CXXThrowExpr *E) { if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(), E->isThrownVariableInScope()); @@ -7669,7 +7664,7 @@ TreeTransform::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) { if (!getDerived().AlwaysRebuild() && Param == E->getParam()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param); } @@ -7684,7 +7679,7 @@ TreeTransform::TransformCXXDefaultInitExpr(CXXDefaultInitExpr *E) { return ExprError(); if (!getDerived().AlwaysRebuild() && Field == E->getField()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field); } @@ -7699,7 +7694,7 @@ TreeTransform::TransformCXXScalarValueInitExpr( if (!getDerived().AlwaysRebuild() && T == E->getTypeSourceInfo()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXScalarValueInitExpr(T, /*FIXME:*/T->getTypeLoc().getEndLoc(), @@ -7780,7 +7775,7 @@ TreeTransform::TransformCXXNewExpr(CXXNewExpr *E) { } } - return SemaRef.Owned(E); + return E; } QualType AllocType = AllocTypeInfo->getType(); @@ -7795,16 +7790,14 @@ TreeTransform::TransformCXXNewExpr(CXXNewExpr *E) { // Do nothing } else if (const ConstantArrayType *ConsArrayT = dyn_cast(ArrayT)) { - ArraySize - = SemaRef.Owned(IntegerLiteral::Create(SemaRef.Context, - ConsArrayT->getSize(), - SemaRef.Context.getSizeType(), - /*FIXME:*/E->getLocStart())); + ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(), + SemaRef.Context.getSizeType(), + /*FIXME:*/ E->getLocStart()); AllocType = ConsArrayT->getElementType(); } else if (const DependentSizedArrayType *DepArrayT = dyn_cast(ArrayT)) { if (DepArrayT->getSizeExpr()) { - ArraySize = SemaRef.Owned(DepArrayT->getSizeExpr()); + ArraySize = DepArrayT->getSizeExpr(); AllocType = DepArrayT->getElementType(); } } @@ -7858,7 +7851,7 @@ TreeTransform::TransformCXXDeleteExpr(CXXDeleteExpr *E) { } } - return SemaRef.Owned(E); + return E; } return getDerived().RebuildCXXDeleteExpr(E->getLocStart(), @@ -8156,7 +8149,7 @@ TreeTransform::TransformTypeTraitExpr(TypeTraitExpr *E) { } if (!getDerived().AlwaysRebuild() && !ArgChanged) - return SemaRef.Owned(E); + return E; return getDerived().RebuildTypeTrait(E->getTrait(), E->getLocStart(), @@ -8173,7 +8166,7 @@ TreeTransform::TransformArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { if (!getDerived().AlwaysRebuild() && T == E->getQueriedTypeSourceInfo()) - return SemaRef.Owned(E); + return E; ExprResult SubExpr; { @@ -8183,7 +8176,7 @@ TreeTransform::TransformArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { return ExprError(); if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression()) - return SemaRef.Owned(E); + return E; } return getDerived().RebuildArrayTypeTrait(E->getTrait(), @@ -8204,7 +8197,7 @@ TreeTransform::TransformExpressionTraitExpr(ExpressionTraitExpr *E) { return ExprError(); if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression()) - return SemaRef.Owned(E); + return E; } return getDerived().RebuildExpressionTrait( @@ -8245,7 +8238,7 @@ TreeTransform::TransformDependentScopeDeclRefExpr( // Note: it is sufficient to compare the Name component of NameInfo: // if name has not changed, DNLoc has not changed either. NameInfo.getName() == E->getDeclName()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildDependentScopeDeclRefExpr(QualifierLoc, TemplateKWLoc, @@ -8305,7 +8298,7 @@ TreeTransform::TransformCXXConstructExpr(CXXConstructExpr *E) { // Mark the constructor as referenced. // FIXME: Instantiation-specific SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor); - return SemaRef.Owned(E); + return E; } return getDerived().RebuildCXXConstructExpr(T, /*FIXME:*/E->getLocStart(), @@ -8677,7 +8670,7 @@ TreeTransform::TransformCXXUnresolvedConstructExpr( if (!getDerived().AlwaysRebuild() && T == E->getTypeSourceInfo() && !ArgumentChanged) - return SemaRef.Owned(E); + return E; // FIXME: we're faking the locations of the commas return getDerived().RebuildCXXUnresolvedConstructExpr(T, @@ -8757,7 +8750,7 @@ TreeTransform::TransformCXXDependentScopeMemberExpr( QualifierLoc == E->getQualifierLoc() && NameInfo.getName() == E->getMember() && FirstQualifierInScope == E->getFirstQualifierFoundInScope()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(), BaseType, @@ -8898,7 +8891,7 @@ TreeTransform::TransformCXXNoexceptExpr(CXXNoexceptExpr *E) { return ExprError(); if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get()); } @@ -8911,7 +8904,7 @@ TreeTransform::TransformPackExpansionExpr(PackExpansionExpr *E) { return ExprError(); if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(), E->getNumExpansions()); @@ -8923,7 +8916,7 @@ TreeTransform::TransformSizeOfPackExpr(SizeOfPackExpr *E) { // If E is not value-dependent, then nothing will change when we transform it. // Note: This is an instantiation-centric view. if (!E->isValueDependent()) - return SemaRef.Owned(E); + return E; // Note: None of the implementations of TryExpandParameterPacks can ever // produce a diagnostic when given only a single unexpanded parameter pack, @@ -8939,7 +8932,7 @@ TreeTransform::TransformSizeOfPackExpr(SizeOfPackExpr *E) { return ExprError(); if (RetainExpansion) - return SemaRef.Owned(E); + return E; NamedDecl *Pack = E->getPack(); if (!ShouldExpand) { @@ -8962,7 +8955,7 @@ ExprResult TreeTransform::TransformSubstNonTypeTemplateParmPackExpr( SubstNonTypeTemplateParmPackExpr *E) { // Default behavior is to do nothing with this transformation. - return SemaRef.Owned(E); + return E; } template @@ -8970,14 +8963,14 @@ ExprResult TreeTransform::TransformSubstNonTypeTemplateParmExpr( SubstNonTypeTemplateParmExpr *E) { // Default behavior is to do nothing with this transformation. - return SemaRef.Owned(E); + return E; } template ExprResult TreeTransform::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) { // Default behavior is to do nothing with this transformation. - return SemaRef.Owned(E); + return E; } template @@ -9003,7 +8996,7 @@ TreeTransform::TransformObjCStringLiteral(ObjCStringLiteral *E) { template ExprResult TreeTransform::TransformObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) { - return SemaRef.Owned(E); + return E; } template @@ -9015,7 +9008,7 @@ TreeTransform::TransformObjCBoxedExpr(ObjCBoxedExpr *E) { if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get()); } @@ -9170,7 +9163,7 @@ TreeTransform::TransformObjCEncodeExpr(ObjCEncodeExpr *E) { if (!getDerived().AlwaysRebuild() && EncodedTypeInfo == E->getEncodedTypeSourceInfo()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(), EncodedTypeInfo, @@ -9202,7 +9195,7 @@ TransformObjCBridgedCastExpr(ObjCBridgedCastExpr *E) { if (!getDerived().AlwaysRebuild() && TSInfo == E->getTypeInfoAsWritten() && Result.get() == E->getSubExpr()) - return SemaRef.Owned(E); + return E; return SemaRef.BuildObjCBridgedCast(E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo, @@ -9272,13 +9265,13 @@ TreeTransform::TransformObjCMessageExpr(ObjCMessageExpr *E) { template ExprResult TreeTransform::TransformObjCSelectorExpr(ObjCSelectorExpr *E) { - return SemaRef.Owned(E); + return E; } template ExprResult TreeTransform::TransformObjCProtocolExpr(ObjCProtocolExpr *E) { - return SemaRef.Owned(E); + return E; } template @@ -9294,7 +9287,7 @@ TreeTransform::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) { // If nothing changed, just retain the existing expression. if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(), E->getLocation(), @@ -9307,7 +9300,7 @@ TreeTransform::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { // 'super' and types never change. Property never changes. Just // retain the existing expression. if (!E->isObjectReceiver()) - return SemaRef.Owned(E); + return E; // Transform the base expression. ExprResult Base = getDerived().TransformExpr(E->getBase()); @@ -9319,7 +9312,7 @@ TreeTransform::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { // If nothing changed, just retain the existing expression. if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase()) - return SemaRef.Owned(E); + return E; if (E->isExplicitProperty()) return getDerived().RebuildObjCPropertyRefExpr(Base.get(), @@ -9349,7 +9342,7 @@ TreeTransform::TransformObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) { // If nothing changed, just retain the existing expression. if (!getDerived().AlwaysRebuild() && Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(), Base.get(), Key.get(), @@ -9368,7 +9361,7 @@ TreeTransform::TransformObjCIsaExpr(ObjCIsaExpr *E) { // If nothing changed, just retain the existing expression. if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(), E->getOpLoc(), @@ -9387,7 +9380,7 @@ TreeTransform::TransformShuffleVectorExpr(ShuffleVectorExpr *E) { if (!getDerived().AlwaysRebuild() && !ArgumentChanged) - return SemaRef.Owned(E); + return E; return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(), SubExprs, @@ -9408,7 +9401,7 @@ TreeTransform::TransformConvertVectorExpr(ConvertVectorExpr *E) { if (!getDerived().AlwaysRebuild() && Type == E->getTypeSourceInfo() && SrcExpr.get() == E->getSrcExpr()) - return SemaRef.Owned(E); + return E; return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(), SrcExpr.get(), Type, @@ -9508,7 +9501,7 @@ TreeTransform::TransformAtomicExpr(AtomicExpr *E) { if (!getDerived().AlwaysRebuild() && !ArgumentChanged) - return SemaRef.Owned(E); + return E; return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs, RetTy, E->getOp(), E->getRParenLoc());