aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaCXXCast.cpp3
-rw-r--r--lib/Sema/SemaDecl.cpp34
-rw-r--r--lib/Sema/SemaDeclAttr.cpp2
-rw-r--r--lib/Sema/SemaDeclCXX.cpp153
-rw-r--r--lib/Sema/SemaExpr.cpp231
-rw-r--r--lib/Sema/SemaExprCXX.cpp136
-rw-r--r--lib/Sema/SemaExprObjC.cpp12
-rw-r--r--lib/Sema/SemaOverload.cpp136
-rw-r--r--lib/Sema/SemaStmt.cpp198
-rw-r--r--lib/Sema/SemaTemplate.cpp13
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp14
-rw-r--r--lib/Sema/SemaType.cpp16
-rw-r--r--lib/Sema/TreeTransform.h630
13 files changed, 682 insertions, 896 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index a7225180ac..f1bdc7a1f5 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/lib/Sema/SemaCXXCast.cpp
@@ -135,9 +135,8 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
Action::OwningExprResult
Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
- TypeSourceInfo *DestTInfo, ExprArg E,
+ TypeSourceInfo *DestTInfo, ExprArg Ex,
SourceRange AngleBrackets, SourceRange Parens) {
- Expr *Ex = E.takeAs<Expr>();
QualType DestType = DestTInfo->getType();
SourceRange OpRange(OpLoc, Parens.getEnd());
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index e9a2b3cd72..b2c31916b7 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -4035,14 +4035,14 @@ bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) {
return true;
}
-void Sema::AddInitializerToDecl(Decl *dcl, ExprArg init) {
- AddInitializerToDecl(dcl, move(init), /*DirectInit=*/false);
+void Sema::AddInitializerToDecl(Decl *dcl, Expr *init) {
+ AddInitializerToDecl(dcl, init, /*DirectInit=*/false);
}
/// AddInitializerToDecl - Adds the initializer Init to the
/// declaration dcl. If DirectInit is true, this is C++ direct
/// initialization rather than copy initialization.
-void Sema::AddInitializerToDecl(Decl *RealDecl, ExprArg init, bool DirectInit) {
+void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
// If there is no declaration, there was an error parsing it. Just ignore
// the initializer.
if (RealDecl == 0)
@@ -4053,7 +4053,6 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, ExprArg init, bool DirectInit) {
// distinguish between a normal initializer and a pure-specifier.
// Thus this grotesque test.
IntegerLiteral *IL;
- Expr *Init = static_cast<Expr *>(init.get());
if ((IL = dyn_cast<IntegerLiteral>(Init)) && IL->getValue() == 0 &&
Context.getCanonicalType(IL->getType()) == Context.IntTy)
CheckPureMethod(Method, Init->getSourceRange());
@@ -4108,11 +4107,6 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, ExprArg init, bool DirectInit) {
if (getLangOptions().CPlusPlus && VDecl->hasLocalStorage())
setFunctionHasBranchProtectedScope();
- // Take ownership of the expression, now that we're sure we have somewhere
- // to put it.
- Expr *Init = init.takeAs<Expr>();
- assert(Init && "missing initializer");
-
// Capture the variable that is being initialized and the style of
// initialization.
InitializedEntity Entity = InitializedEntity::InitializeVariable(VDecl);
@@ -4860,10 +4854,8 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *D, StmtArg BodyArg) {
return ActOnFinishFunctionBody(D, move(BodyArg), false);
}
-Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, StmtArg BodyArg,
- bool IsInstantiation) {
- Stmt *Body = BodyArg.takeAs<Stmt>();
-
+Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
+ bool IsInstantiation) {
FunctionDecl *FD = 0;
FunctionTemplateDecl *FunTmpl = dyn_cast_or_null<FunctionTemplateDecl>(dcl);
if (FunTmpl)
@@ -6663,9 +6655,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
EnumConstantDecl *LastEnumConst,
SourceLocation IdLoc,
IdentifierInfo *Id,
- ExprArg val) {
- Expr *Val = (Expr *)val.get();
-
+ Expr *Val) {
unsigned IntWidth = Context.Target.getIntWidth();
llvm::APSInt EnumVal(IntWidth);
QualType EltTy;
@@ -6693,11 +6683,6 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
else if (!Context.hasSameType(Val->getType(), Context.IntTy)) {
// Force the type of the expression to 'int'.
ImpCastExprToType(Val, Context.IntTy, CastExpr::CK_IntegralCast);
-
- if (Val != val.get()) {
- val.release();
- val = Val;
- }
}
}
@@ -6785,7 +6770,6 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum,
EnumVal.setIsSigned(EltTy->isSignedIntegerType());
}
- val.release();
return EnumConstantDecl::Create(Context, Enum, IdLoc, Id, EltTy,
Val, EnumVal);
}
@@ -6832,7 +6816,7 @@ Decl *Sema::ActOnEnumConstant(Scope *S, Decl *theEnumDecl,
}
EnumConstantDecl *New = CheckEnumConstant(TheEnumDecl, LastEnumConst,
- IdLoc, Id, Owned(Val));
+ IdLoc, Id, Val);
// Register this decl in the current scope stack.
if (New) {
@@ -7046,8 +7030,8 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
NumPositiveBits, NumNegativeBits);
}
-Decl *Sema::ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr) {
- StringLiteral *AsmString = cast<StringLiteral>(expr.takeAs<Expr>());
+Decl *Sema::ActOnFileScopeAsmDecl(SourceLocation Loc, Expr *expr) {
+ StringLiteral *AsmString = cast<StringLiteral>(expr);
FileScopeAsmDecl *New = FileScopeAsmDecl::Create(Context, CurContext,
Loc, AsmString);
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 11afd14df8..3213b2ea5d 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -193,7 +193,7 @@ static void HandleExtVectorTypeAttr(Scope *scope, Decl *d,
// Instantiate/Install the vector type, and let Sema build the type for us.
// This will run the reguired checks.
- QualType T = S.BuildExtVectorType(curType, S.Owned(sizeExpr), Attr.getLoc());
+ QualType T = S.BuildExtVectorType(curType, sizeExpr, Attr.getLoc());
if (!T.isNull()) {
// FIXME: preserve the old source info.
tDecl->setTypeSourceInfo(S.Context.getTrivialTypeSourceInfo(T));
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 08a34a5d0f..9479fac085 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -108,7 +108,7 @@ namespace {
}
bool
-Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
+Sema::SetParamDefaultArgument(ParmVarDecl *Param, Expr *Arg,
SourceLocation EqualLoc) {
if (RequireCompleteType(Param->getLocation(), Param->getType(),
diag::err_typecheck_decl_incomplete_type)) {
@@ -116,8 +116,6 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
return true;
}
- Expr *Arg = (Expr *)DefaultArg.get();
-
// C++ [dcl.fct.default]p5
// A default argument expression is implicitly converted (clause
// 4) to the parameter type. The default argument expression has
@@ -139,8 +137,6 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
// Okay: add the default argument to the parameter
Param->setDefaultArg(Arg);
- DefaultArg.release();
-
return false;
}
@@ -149,15 +145,13 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
/// to the parameter declaration.
void
Sema::ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
- ExprArg defarg) {
- if (!param || !defarg.get())
+ Expr *DefaultArg) {
+ if (!param || !DefaultArg)
return;
ParmVarDecl *Param = cast<ParmVarDecl>(param);
UnparsedDefaultArgLocs.erase(Param);
- ExprOwningPtr<Expr> DefaultArg(this, defarg.takeAs<Expr>());
-
// Default arguments are only permitted in C++
if (!getLangOptions().CPlusPlus) {
Diag(EqualLoc, diag::err_param_default_argument)
@@ -167,13 +161,13 @@ Sema::ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc,
}
// Check that the default argument is well-formed
- CheckDefaultArgumentVisitor DefaultArgChecker(DefaultArg.get(), this);
- if (DefaultArgChecker.Visit(DefaultArg.get())) {
+ CheckDefaultArgumentVisitor DefaultArgChecker(DefaultArg, this);
+ if (DefaultArgChecker.Visit(DefaultArg)) {
Param->setInvalidDecl();
return;
}
- SetParamDefaultArgument(Param, move(DefaultArg), EqualLoc);
+ SetParamDefaultArgument(Param, DefaultArg, EqualLoc);
}
/// ActOnParamUnparsedDefaultArgument - We've seen a default
@@ -1002,7 +996,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D,
assert((Name || isInstField) && "No identifier for non-field ?");
if (Init)
- AddInitializerToDecl(Member, ExprArg(*this, Init), false);
+ AddInitializerToDecl(Member, Init, false);
if (Deleted) // FIXME: Source location is not very good.
SetDeclDeleted(Member, D.getSourceRange().getBegin());
@@ -1294,9 +1288,9 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args,
if (Member->getType()->isDependentType() || HasDependentArg) {
// Can't check initialization for a member of dependent type or when
// any of the arguments are type-dependent expressions.
- OwningExprResult Init
- = Owned(new (Context) ParenListExpr(Context, LParenLoc, Args, NumArgs,
- RParenLoc));
+ Expr *Init
+ = new (Context) ParenListExpr(Context, LParenLoc, Args, NumArgs,
+ RParenLoc);
// Erase any temporaries within this evaluation context; we're not
// going to track them in the AST, since we'll be rebuilding the
@@ -1307,7 +1301,7 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args,
return new (Context) CXXBaseOrMemberInitializer(Context, Member, IdLoc,
LParenLoc,
- Init.takeAs<Expr>(),
+ Init,
RParenLoc);
}
@@ -1332,7 +1326,7 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args,
// C++0x [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
- MemberInit = MaybeCreateCXXExprWithTemporaries(move(MemberInit));
+ MemberInit = MaybeCreateCXXExprWithTemporaries(MemberInit.get());
if (MemberInit.isInvalid())
return true;
@@ -1348,18 +1342,17 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args,
for (unsigned I = 0; I != NumArgs; ++I)
Args[I]->Retain();
- OwningExprResult Init
- = Owned(new (Context) ParenListExpr(Context, LParenLoc, Args, NumArgs,
- RParenLoc));
+ Expr *Init = new (Context) ParenListExpr(Context, LParenLoc, Args, NumArgs,
+ RParenLoc);
return new (Context) CXXBaseOrMemberInitializer(Context, Member, IdLoc,
LParenLoc,
- Init.takeAs<Expr>(),
+ Init,
RParenLoc);
}
return new (Context) CXXBaseOrMemberInitializer(Context, Member, IdLoc,
LParenLoc,
- MemberInit.takeAs<Expr>(),
+ MemberInit.get(),
RParenLoc);
}
@@ -1464,7 +1457,7 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo,
// C++0x [class.base.init]p7:
// The initialization of each base and member constitutes a
// full-expression.
- BaseInit = MaybeCreateCXXExprWithTemporaries(move(BaseInit));
+ BaseInit = MaybeCreateCXXExprWithTemporaries(BaseInit.get());
if (BaseInit.isInvalid())
return true;
@@ -1560,8 +1553,11 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
case IIK_Move:
assert(false && "Unhandled initializer kind!");
}
+
+ if (BaseInit.isInvalid())
+ return true;
- BaseInit = SemaRef.MaybeCreateCXXExprWithTemporaries(move(BaseInit));
+ BaseInit = SemaRef.MaybeCreateCXXExprWithTemporaries(BaseInit.get());
if (BaseInit.isInvalid())
return true;
@@ -1602,7 +1598,7 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
MemberLookup.addDecl(Field, AS_public);
MemberLookup.resolveKind();
Sema::OwningExprResult CopyCtorArg
- = SemaRef.BuildMemberReferenceExpr(SemaRef.Owned(MemberExprBase),
+ = SemaRef.BuildMemberReferenceExpr(MemberExprBase,
ParamType, Loc,
/*IsArrow=*/false,
SS,
@@ -1643,9 +1639,9 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
"Reference to invented variable cannot fail!");
// Subscript the array with this iteration variable.
- CopyCtorArg = SemaRef.CreateBuiltinArraySubscriptExpr(move(CopyCtorArg),
+ CopyCtorArg = SemaRef.CreateBuiltinArraySubscriptExpr(CopyCtorArg.take(),
Loc,
- move(IterationVarRef),
+ IterationVarRef.take(),
Loc);
if (CopyCtorArg.isInvalid())
return true;
@@ -1675,7 +1671,7 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
Sema::OwningExprResult MemberInit
= InitSeq.Perform(SemaRef, Entities.back(), InitKind,
Sema::MultiExprArg(SemaRef, &CopyCtorArgE, 1));
- MemberInit = SemaRef.MaybeCreateCXXExprWithTemporaries(move(MemberInit));
+ MemberInit = SemaRef.MaybeCreateCXXExprWithTemporaries(MemberInit.get());
if (MemberInit.isInvalid())
return true;
@@ -1701,14 +1697,17 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
Sema::OwningExprResult MemberInit =
InitSeq.Perform(SemaRef, InitEntity, InitKind,
Sema::MultiExprArg(SemaRef, 0, 0));
- MemberInit = SemaRef.MaybeCreateCXXExprWithTemporaries(move(MemberInit));
+ if (MemberInit.isInvalid())
+ return true;
+
+ MemberInit = SemaRef.MaybeCreateCXXExprWithTemporaries(MemberInit.get());
if (MemberInit.isInvalid())
return true;
CXXMemberInit =
new (SemaRef.Context) CXXBaseOrMemberInitializer(SemaRef.Context,
Field, Loc, Loc,
- MemberInit.takeAs<Expr>(),
+ MemberInit.get(),
Loc);
return false;
}
@@ -4541,13 +4540,10 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation,
/// \param Depth Internal parameter recording the depth of the recursion.
///
/// \returns A statement or a loop that copies the expressions.
-static Sema::OwningStmtResult
+static OwningStmtResult
BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T,
- Sema::OwningExprResult To, Sema::OwningExprResult From,
+ Expr *To, Expr *From,
bool CopyingBaseSubobject, unsigned Depth = 0) {
- typedef Sema::OwningStmtResult OwningStmtResult;
- typedef Sema::OwningExprResult OwningExprResult;
-
// C++0x [class.copy]p30:
// Each subobject is assigned in the manner appropriate to its type:
//
@@ -4605,7 +4601,7 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T,
// Create the reference to operator=.
OwningExprResult OpEqualRef
- = S.BuildMemberReferenceExpr(move(To), T, Loc, /*isArrow=*/false, SS,
+ = S.BuildMemberReferenceExpr(To, T, Loc, /*isArrow=*/false, SS,
/*FirstQualifierInScope=*/0, OpLookup,
/*TemplateArgs=*/0,
/*SuppressQualifierCheck=*/true);
@@ -4613,10 +4609,10 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T,
return S.StmtError();
// Build the call to the assignment operator.
- Expr *FromE = From.takeAs<Expr>();
+
OwningExprResult Call = S.BuildCallToMemberFunction(/*Scope=*/0,
OpEqualRef.takeAs<Expr>(),
- Loc, &FromE, 1, 0, Loc);
+ Loc, &From, 1, 0, Loc);
if (Call.isInvalid())
return S.StmtError();
@@ -4627,10 +4623,10 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T,
// operator is used.
const ConstantArrayType *ArrayTy = S.Context.getAsConstantArrayType(T);
if (!ArrayTy) {
- OwningExprResult Assignment = S.CreateBuiltinBinOp(Loc,
+ OwningExprResult Assignment = S.CreateBuiltinBinOp(Loc,
BinaryOperator::Assign,
- To.takeAs<Expr>(),
- From.takeAs<Expr>());
+ To,
+ From);
if (Assignment.isInvalid())
return S.StmtError();
@@ -4676,40 +4672,36 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T,
// Create the comparison against the array bound.
llvm::APInt Upper = ArrayTy->getSize();
Upper.zextOrTrunc(S.Context.getTypeSize(SizeType));
- OwningExprResult Comparison
- = S.Owned(new (S.Context) BinaryOperator(IterationVarRef->Retain(),
+ Expr *Comparison
+ = new (S.Context) BinaryOperator(IterationVarRef->Retain(),
new (S.Context) IntegerLiteral(Upper, SizeType, Loc),
- BinaryOperator::NE, S.Context.BoolTy, Loc));
+ BinaryOperator::NE, S.Context.BoolTy, Loc);
// Create the pre-increment of the iteration variable.
- OwningExprResult Increment
- = S.Owned(new (S.Context) UnaryOperator(IterationVarRef->Retain(),
- UnaryOperator::PreInc,
- SizeType, Loc));
+ Expr *Increment
+ = new (S.Context) UnaryOperator(IterationVarRef->Retain(),
+ UnaryOperator::PreInc,
+ SizeType, Loc);
// Subscript the "from" and "to" expressions with the iteration variable.
- From = S.CreateBuiltinArraySubscriptExpr(move(From), Loc,
- S.Owned(IterationVarRef->Retain()),
- Loc);
- To = S.CreateBuiltinArraySubscriptExpr(move(To), Loc,
- S.Owned(IterationVarRef->Retain()),
- Loc);
- assert(!From.isInvalid() && "Builtin subscripting can't fail!");
- assert(!To.isInvalid() && "Builtin subscripting can't fail!");
+ From = AssertSuccess(S.CreateBuiltinArraySubscriptExpr(From, Loc,
+ IterationVarRef, Loc));
+ To = AssertSuccess(S.CreateBuiltinArraySubscriptExpr(To, Loc,
+ IterationVarRef, Loc));
// Build the copy for an individual element of the array.
OwningStmtResult Copy = BuildSingleCopyAssign(S, Loc,
ArrayTy->getElementType(),
- move(To), move(From),
+ To, From,
CopyingBaseSubobject, Depth+1);
if (Copy.isInvalid())
return S.StmtError();
// Construct the loop that copies all elements of this array.
- return S.ActOnForStmt(Loc, Loc, S.Owned(InitStmt),
+ return S.ActOnForStmt(Loc, Loc, InitStmt,
S.MakeFullExpr(Comparison),
0, S.MakeFullExpr(Increment),
- Loc, move(Copy));
+ Loc, Copy.take());
}
/// \brief Determine whether the given class has a copy assignment operator
@@ -4978,8 +4970,7 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
ImplicitCastExpr::LValue, &BasePath);
// Dereference "this".
- OwningExprResult To = CreateBuiltinUnaryOp(Loc, UnaryOperator::Deref,
- Owned(This->Retain()));
+ OwningExprResult To = CreateBuiltinUnaryOp(Loc, UnaryOperator::Deref, This);
// Implicitly cast "this" to the appropriately-qualified base type.
Expr *ToE = To.takeAs<Expr>();
@@ -4992,7 +4983,7 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
// Build the copy.
OwningStmtResult Copy = BuildSingleCopyAssign(*this, Loc, BaseType,
- move(To), Owned(From),
+ To.get(), From,
/*CopyingBaseSubobject=*/true);
if (Copy.isInvalid()) {
Diag(CurrentLocation, diag::note_member_synthesized_at)
@@ -5050,12 +5041,10 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
LookupMemberName);
MemberLookup.addDecl(*Field);
MemberLookup.resolveKind();
- OwningExprResult From = BuildMemberReferenceExpr(Owned(OtherRef->Retain()),
- OtherRefType,
+ OwningExprResult From = BuildMemberReferenceExpr(OtherRef, OtherRefType,
Loc, /*IsArrow=*/false,
SS, 0, MemberLookup, 0);
- OwningExprResult To = BuildMemberReferenceExpr(Owned(This->Retain()),
- This->getType(),
+ OwningExprResult To = BuildMemberReferenceExpr(This, This->getType(),
Loc, /*IsArrow=*/true,
SS, 0, MemberLookup, 0);
assert(!From.isInvalid() && "Implicit field reference cannot fail");
@@ -5083,8 +5072,8 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
}
// Take the address of the field references for "from" and "to".
- From = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, move(From));
- To = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, move(To));
+ From = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, From.get());
+ To = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, To.get());
bool NeedsCollectableMemCpy =
(BaseType->isRecordType() &&
@@ -5142,12 +5131,12 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
OwningExprResult Call = ExprError();
if (NeedsCollectableMemCpy)
Call = ActOnCallExpr(/*Scope=*/0,
- Owned(CollectableMemCpyRef->Retain()),
+ CollectableMemCpyRef,
Loc, move_arg(CallArgs),
Commas.data(), Loc);
else
Call = ActOnCallExpr(/*Scope=*/0,
- Owned(BuiltinMemCpyRef->Retain()),
+ BuiltinMemCpyRef,
Loc, move_arg(CallArgs),
Commas.data(), Loc);
@@ -5158,7 +5147,7 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
// Build the copy of this field.
OwningStmtResult Copy = BuildSingleCopyAssign(*this, Loc, FieldType,
- move(To), move(From),
+ To.get(), From.get(),
/*CopyingBaseSubobject=*/false);
if (Copy.isInvalid()) {
Diag(CurrentLocation, diag::note_member_synthesized_at)
@@ -5174,9 +5163,9 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
if (!Invalid) {
// Add a "return *this;"
OwningExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UnaryOperator::Deref,
- Owned(This->Retain()));
+ This);
- OwningStmtResult Return = ActOnReturnStmt(Loc, move(ThisObj));
+ OwningStmtResult Return = ActOnReturnStmt(Loc, ThisObj.get());
if (Return.isInvalid())
Invalid = true;
else {
@@ -5570,14 +5559,14 @@ void Sema::AddCXXDirectInitializerToDecl(Decl *RealDecl,
LParenLoc, RParenLoc);
InitializationSequence InitSeq(*this, Entity, Kind,
- (Expr**)Exprs.get(), Exprs.size());
+ Exprs.get(), Exprs.size());
OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind, move(Exprs));
if (Result.isInvalid()) {
VDecl->setInvalidDecl();
return;
}
- Result = MaybeCreateCXXExprWithTemporaries(move(Result));
+ Result = MaybeCreateCXXExprWithTemporaries(Result.get());
VDecl->setInit(Result.takeAs<Expr>());
VDecl->setCXXDirectInitializer(true);
@@ -6198,11 +6187,9 @@ Decl *Sema::ActOnExceptionDeclarator(Scope *S, Declarator &D) {
}
Decl *Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
- ExprArg assertexpr,
- ExprArg assertmessageexpr) {
- Expr *AssertExpr = (Expr *)assertexpr.get();
- StringLiteral *AssertMessage =
- cast<StringLiteral>((Expr *)assertmessageexpr.get());
+ Expr *AssertExpr,
+ Expr *AssertMessageExpr_) {
+ StringLiteral *AssertMessage = cast<StringLiteral>(AssertMessageExpr_);
if (!AssertExpr->isTypeDependent() && !AssertExpr->isValueDependent()) {
llvm::APSInt Value(32);
@@ -6218,8 +6205,6 @@ Decl *Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
}
}
- assertexpr.release();
- assertmessageexpr.release();
Decl *Decl = StaticAssertDecl::Create(Context, CurContext, AssertLoc,
AssertExpr, AssertMessage);
@@ -6933,7 +6918,7 @@ void Sema::SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation) {
Sema::OwningExprResult MemberInit =
InitSeq.Perform(*this, InitEntity, InitKind,
Sema::MultiExprArg(*this, 0, 0));
- MemberInit = MaybeCreateCXXExprWithTemporaries(move(MemberInit));
+ MemberInit = MaybeCreateCXXExprWithTemporaries(MemberInit.get());
// Note, MemberInit could actually come back empty if no initialization
// is required (e.g., because it would call a trivial default constructor)
if (!MemberInit.get() || MemberInit.isInvalid())
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 6a62a1a12d..46e2745b21 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1622,7 +1622,7 @@ Sema::BuildImplicitMemberExpr(const CXXScopeSpec &SS,
This = new (Context) CXXThisExpr(Loc, ThisType, /*isImplicit=*/true);
}
- return BuildMemberReferenceExpr(ExprArg(*this, This), ThisType,
+ return BuildMemberReferenceExpr(This, ThisType,
/*OpLoc*/ SourceLocation(),
/*IsArrow*/ true,
SS,
@@ -1834,7 +1834,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS,
SourceLocation(),
Owned(E));
if (!Res.isInvalid()) {
- Res = MaybeCreateCXXExprWithTemporaries(move(Res));
+ Res = MaybeCreateCXXExprWithTemporaries(Res.get());
Expr *Init = Res.takeAs<Expr>();
BDRE->setCopyConstructorExpr(Init);
}
@@ -2074,8 +2074,7 @@ Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) {
}
Action::OwningExprResult Sema::ActOnParenExpr(SourceLocation L,
- SourceLocation R, ExprArg Val) {
- Expr *E = Val.takeAs<Expr>();
+ SourceLocation R, Expr *E) {
assert((E != 0) && "ActOnParenExpr() missing expr");
return Owned(new (Context) ParenExpr(L, R, E));
}
@@ -2252,7 +2251,7 @@ QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc, bool isReal) {
Action::OwningExprResult
Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
- tok::TokenKind Kind, ExprArg Input) {
+ tok::TokenKind Kind, Expr *Input) {
UnaryOperator::Opcode Opc;
switch (Kind) {
default: assert(0 && "Unknown unary op!");
@@ -2260,22 +2259,21 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
case tok::minusminus: Opc = UnaryOperator::PostDec; break;
}
- return BuildUnaryOp(S, OpLoc, Opc, move(Input));
+ return BuildUnaryOp(S, OpLoc, Opc, Input);
}
Action::OwningExprResult
-Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
- ExprArg Idx, SourceLocation RLoc) {
+Sema::ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
+ Expr *Idx, SourceLocation RLoc) {
// Since this might be a postfix expression, get rid of ParenListExprs.
- Base = MaybeConvertParenListExprToParenExpr(S, move(Base));
+ OwningExprResult Result = MaybeConvertParenListExprToParenExpr(S, Base);
+ if (Result.isInvalid()) return ExprError();
+ Base = Result.take();
- Expr *LHSExp = static_cast<Expr*>(Base.get()),
- *RHSExp = static_cast<Expr*>(Idx.get());
+ Expr *LHSExp = Base, *RHSExp = Idx;
if (getLangOptions().CPlusPlus &&
(LHSExp->isTypeDependent() || RHSExp->isTypeDependent())) {
- Base.release();
- Idx.release();
return Owned(new (Context) ArraySubscriptExpr(LHSExp, RHSExp,
Context.DependentTy, RLoc));
}
@@ -2285,18 +2283,18 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
LHSExp->getType()->isEnumeralType() ||
RHSExp->getType()->isRecordType() ||
RHSExp->getType()->isEnumeralType())) {
- return CreateOverloadedArraySubscriptExpr(LLoc, RLoc, move(Base),move(Idx));
+ return CreateOverloadedArraySubscriptExpr(LLoc, RLoc, Base, Idx);
}
- return CreateBuiltinArraySubscriptExpr(move(Base), LLoc, move(Idx), RLoc);
+ return CreateBuiltinArraySubscriptExpr(Base, LLoc, Idx, RLoc);
}
Action::OwningExprResult
-Sema::CreateBuiltinArraySubscriptExpr(ExprArg Base, SourceLocation LLoc,
- ExprArg Idx, SourceLocation RLoc) {
- Expr *LHSExp = static_cast<Expr*>(Base.get());
- Expr *RHSExp = static_cast<Expr*>(Idx.get());
+Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
+ Expr *Idx, SourceLocation RLoc) {
+ Expr *LHSExp = Base;
+ Expr *RHSExp = Idx;
// Perform default conversions.
if (!LHSExp->getType()->getAs<VectorType>())
@@ -2404,8 +2402,6 @@ Sema::CreateBuiltinArraySubscriptExpr(ExprArg Base, SourceLocation LLoc,
return ExprError();
}
- Base.release();
- Idx.release();
return Owned(new (Context) ArraySubscriptExpr(LHSExp, RHSExp,
ResultType, RLoc));
}
@@ -2546,14 +2542,12 @@ static Decl *FindGetterNameDecl(const ObjCObjectPointerType *QIdTy,
}
Sema::OwningExprResult
-Sema::ActOnDependentMemberExpr(ExprArg Base, QualType BaseType,
+Sema::ActOnDependentMemberExpr(Expr *BaseExpr, QualType BaseType,
bool IsArrow, SourceLocation OpLoc,
const CXXScopeSpec &SS,
NamedDecl *FirstQualifierInScope,
const DeclarationNameInfo &NameInfo,
const TemplateArgumentListInfo *TemplateArgs) {
- Expr *BaseExpr = Base.takeAs<Expr>();
-
// Even in dependent contexts, try to diagnose base expressions with
// obviously wrong types, e.g.:
//
@@ -2582,7 +2576,7 @@ Sema::ActOnDependentMemberExpr(ExprArg Base, QualType BaseType,
// must have pointer type, and the accessed type is the pointee.
return Owned(CXXDependentScopeMemberExpr::Create(Context, BaseExpr, BaseType,
IsArrow, OpLoc,
- static_cast<NestedNameSpecifier*>(SS.getScopeRep()),
+ SS.getScopeRep(),
SS.getRange(),
FirstQualifierInScope,
NameInfo, TemplateArgs));
@@ -2725,17 +2719,15 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
}
Sema::OwningExprResult
-Sema::BuildMemberReferenceExpr(ExprArg BaseArg, QualType BaseType,
+Sema::BuildMemberReferenceExpr(Expr *Base, QualType BaseType,
SourceLocation OpLoc, bool IsArrow,
CXXScopeSpec &SS,
NamedDecl *FirstQualifierInScope,
const DeclarationNameInfo &NameInfo,
const TemplateArgumentListInfo *TemplateArgs) {
- Expr *Base = BaseArg.takeAs<Expr>();
-
if (BaseType->isDependentType() ||
(SS.isSet() && isDependentScopeSpecifier(SS)))
- return ActOnDependentMemberExpr(ExprArg(*this, Base), BaseType,
+ return ActOnDependentMemberExpr(Base, BaseType,
IsArrow, OpLoc,
SS, FirstQualifierInScope,
NameInfo, TemplateArgs);
@@ -2769,20 +2761,19 @@ Sema::BuildMemberReferenceExpr(ExprArg BaseArg, QualType BaseType,
BaseType = Base->getType();
}
- return BuildMemberReferenceExpr(ExprArg(*this, Base), BaseType,
+ return BuildMemberReferenceExpr(Base, BaseType,
OpLoc, IsArrow, SS, FirstQualifierInScope,
R, TemplateArgs);
}
Sema::OwningExprResult
-Sema::BuildMemberReferenceExpr(ExprArg Base, QualType BaseExprType,
+Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
SourceLocation OpLoc, bool IsArrow,
const CXXScopeSpec &SS,
NamedDecl *FirstQualifierInScope,
LookupResult &R,
const TemplateArgumentListInfo *TemplateArgs,
bool SuppressQualifierCheck) {
- Expr *BaseExpr = Base.takeAs<Expr>();
QualType BaseType = BaseExprType;
if (IsArrow) {
assert(BaseType->isPointerType());
@@ -2790,8 +2781,7 @@ Sema::BuildMemberReferenceExpr(ExprArg Base, QualType BaseExprType,
}
R.setBaseObjectType(BaseType);
- NestedNameSpecifier *Qualifier =
- static_cast<NestedNameSpecifier*>(SS.getScopeRep());
+ NestedNameSpecifier *Qualifier = SS.getScopeRep();
const DeclarationNameInfo &MemberNameInfo = R.getLookupNameInfo();
DeclarationName MemberName = MemberNameInfo.getName();
SourceLocation MemberLoc = MemberNameInfo.getLoc();
@@ -3002,7 +2992,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
<< FixItHint::CreateInsertion(Loc, "()");
OwningExprResult NewBase
- = ActOnCallExpr(0, ExprArg(*this, BaseExpr), Loc,
+ = ActOnCallExpr(0, BaseExpr, Loc,
MultiExprArg(*this, 0, 0), 0, Loc);
BaseExpr = 0;
if (NewBase.isInvalid())
@@ -3314,7 +3304,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
/// \param ObjCImpDecl the current ObjC @implementation decl;
/// this is an ugly hack around the fact that ObjC @implementations
/// aren't properly put in the context chain
-Sema::OwningExprResult Sema::ActOnMemberAccessExpr(Scope *S, ExprArg B