Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).

llvm-svn: 111863
This commit is contained in:
John McCall 2010-08-23 23:25:46 +00:00
parent aaed5ea9b7
commit b268a282a4
27 changed files with 881 additions and 1153 deletions

View File

@ -158,17 +158,17 @@ public:
typedef llvm::SmallVector<TemplateParameterList *, 4> TemplateParameterLists;
typedef Action::ExprResult ExprResult;
typedef Action::StmtResult StmtResult;
typedef Action::BaseResult BaseResult;
typedef Action::MemInitResult MemInitResult;
typedef Action::TypeResult TypeResult;
typedef clang::ExprResult ExprResult;
typedef clang::StmtResult StmtResult;
typedef clang::BaseResult BaseResult;
typedef clang::MemInitResult MemInitResult;
typedef clang::TypeResult TypeResult;
typedef Action::OwningExprResult OwningExprResult;
typedef Action::OwningStmtResult OwningStmtResult;
typedef clang::OwningExprResult OwningExprResult;
typedef clang::OwningStmtResult OwningStmtResult;
typedef Action::ExprArg ExprArg;
typedef Action::MultiStmtArg MultiStmtArg;
typedef Expr *ExprArg;
typedef ASTMultiPtr<Stmt*> MultiStmtArg;
typedef Action::FullExprArg FullExprArg;
/// Adorns a ExprResult with Actions to make it an OwningExprResult

View File

@ -89,14 +89,14 @@ public:
typedef clang::MemInitResult MemInitResult;
/// Same, but with ownership.
typedef ASTOwningResult<Expr*> OwningExprResult;
typedef ASTOwningResult<Stmt*> OwningStmtResult;
typedef clang::OwningExprResult OwningExprResult;
typedef clang::OwningStmtResult OwningStmtResult;
// Note that these will replace ExprResult and StmtResult when the transition
// is complete.
/// Single expressions or statements as arguments.
typedef ASTOwningPtr<Expr*> ExprArg;
typedef ASTOwningPtr<Stmt*> StmtArg;
typedef Expr *ExprArg;
typedef Stmt *StmtArg;
/// Multiple expressions or statements as arguments.
typedef ASTMultiPtr<Expr*> MultiExprArg;
@ -105,25 +105,21 @@ public:
class FullExprArg {
public:
FullExprArg(ActionBase &actions) : Expr(actions) { }
FullExprArg(ActionBase &actions) : Expr(0) { }
// FIXME: The const_cast here is ugly. RValue references would make this
// much nicer (or we could duplicate a bunch of the move semantics
// emulation code from Ownership.h).
FullExprArg(const FullExprArg& Other)
: Expr(move(const_cast<FullExprArg&>(Other).Expr)) {}
FullExprArg &operator=(const FullExprArg& Other) {
Expr.operator=(move(const_cast<FullExprArg&>(Other).Expr));
return *this;
}
FullExprArg(const FullExprArg& Other): Expr(Other.Expr) {}
OwningExprResult release() {
return move(Expr);
}
ExprArg* operator->() {
return &Expr;
ExprArg get() const { return Expr; }
ExprArg operator->() {
return Expr;
}
private:
@ -131,15 +127,13 @@ public:
// Action::FullExpr that needs access to the constructor below.
friend class Action;
explicit FullExprArg(ExprArg expr)
: Expr(move(expr)) {}
explicit FullExprArg(Expr *expr) : Expr(expr) {}
ExprArg Expr;
Expr *Expr;
};
template<typename T>
FullExprArg MakeFullExpr(T &Arg) {
return FullExprArg(ActOnFinishFullExpr(move(Arg)));
FullExprArg MakeFullExpr(Expr *Arg) {
return FullExprArg(ActOnFinishFullExpr(Arg).release());
}
// Utilities for Action implementations to return smart results.

View File

@ -316,39 +316,6 @@ namespace clang {
/// the individual pointers, not the array holding them.
template <typename PtrTy> class ASTMultiPtr;
/// Kept only as a type-safe wrapper for a void pointer.
template <typename PtrTy> class ASTOwningPtr {
PtrTy Node;
public:
explicit ASTOwningPtr(ActionBase &) : Node(0) {}
ASTOwningPtr(ActionBase &, PtrTy node) : Node(node) {}
// Normal copying operators are defined implicitly.
ASTOwningPtr(const ASTOwningResult<PtrTy> &o);
ASTOwningPtr & operator =(PtrTy raw) {
Node = raw;
return *this;
}
/// Access to the raw pointer.
PtrTy get() const { return Node; }
/// Release the raw pointer.
PtrTy take() { return Node; }
/// Take outside ownership of the raw pointer and cast it down.
template<typename T> T *takeAs() {
return static_cast<T*>(Node);
}
/// Alias for interface familiarity with unique_ptr.
PtrTy release() {
return take();
}
};
template <class PtrTy> class ASTOwningResult {
public:
typedef ActionBase::ActionResult<PtrTy> DumbResult;
@ -359,46 +326,42 @@ namespace clang {
public:
explicit ASTOwningResult(bool invalid = false)
: Result(invalid) { }
explicit ASTOwningResult(PtrTy node) : Result(node) { }
explicit ASTOwningResult(const DumbResult &res) : Result(res) { }
ASTOwningResult(PtrTy node) : Result(node) { }
ASTOwningResult(const DumbResult &res) : Result(res) { }
// Normal copying semantics are defined implicitly.
ASTOwningResult(const ASTOwningPtr<PtrTy> &o) : Result(o.get()) { }
// These two overloads prevent void* -> bool conversions.
explicit ASTOwningResult(const void *);
explicit ASTOwningResult(volatile void *);
/// Assignment from a raw pointer. Takes ownership - beware!
ASTOwningResult & operator =(PtrTy raw) {
/// Assignment from a raw pointer.
ASTOwningResult &operator=(PtrTy raw) {
Result = raw;
return *this;
}
/// Assignment from an ActionResult. Takes ownership - beware!
ASTOwningResult & operator =(const DumbResult &res) {
/// Assignment from an ActionResult.
ASTOwningResult &operator=(const DumbResult &res) {
Result = res;
return *this;
}
/// Access to the raw pointer.
PtrTy get() const { return Result.get(); }
bool isInvalid() const { return Result.isInvalid(); }
/// Does this point to a usable AST node? To be usable, the node must be
/// valid and non-null.
/// Does this point to a usable AST node? To be usable, the node
/// must be valid and non-null.
bool isUsable() const { return !Result.isInvalid() && get(); }
/// Take outside ownership of the raw pointer.
PtrTy take() {
return Result.get();
}
/// It is forbidden to call either of these methods on an invalid
/// pointer. We should assert that, but we're not going to,
/// because it's likely to trigger it unpredictable ways on
/// invalid code.
PtrTy get() const { return Result.get(); }
PtrTy take() const { return get(); }
/// Take outside ownership of the raw pointer and cast it down.
template<typename T>
T *takeAs() {
return static_cast<T*>(take());
}
T *takeAs() { return static_cast<T*>(get()); }
/// Alias for interface familiarity with unique_ptr.
PtrTy release() { return take(); }
@ -497,18 +460,9 @@ namespace clang {
return ASTMultiPtr<T>(vec.take(), vec.size());
}
template <class T> inline
ASTOwningPtr<T>::ASTOwningPtr(const ASTOwningResult<T> &o)
: Node(o.get()) { }
// These versions are hopefully no-ops.
template <class T> inline
ASTOwningResult<T>& move(ASTOwningResult<T> &ptr) {
return ptr;
}
template <class T> inline
ASTOwningPtr<T>& move(ASTOwningPtr<T> &ptr) {
ASTOwningResult<T> move(ASTOwningResult<T> &ptr) {
return ptr;
}
@ -541,6 +495,25 @@ namespace clang {
typedef ActionBase::ActionResult<Decl*> DeclResult;
typedef OpaquePtr<TemplateName> ParsedTemplateTy;
typedef ASTOwningResult<Expr*> OwningExprResult;
typedef ASTOwningResult<Stmt*> OwningStmtResult;
inline Expr *move(Expr *E) { return E; }
inline Stmt *move(Stmt *S) { return S; }
typedef ASTMultiPtr<Expr*> MultiExprArg;
typedef ASTMultiPtr<TemplateParameterList*> MultiTemplateParamsArg;
inline Expr *AssertSuccess(OwningExprResult R) {
assert(!R.isInvalid() && "operation was asserted to never fail!");
return R.get();
}
inline Stmt *AssertSuccess(OwningStmtResult R) {
assert(!R.isInvalid() && "operation was asserted to never fail!");
return R.get();
}
}
#endif

View File

@ -2107,7 +2107,7 @@ public:
return GetTypeFromParser(Ty)->isVectorType();
}
OwningExprResult MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg ME);
OwningExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME);
OwningExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
SourceLocation RParenLoc, ExprArg E,
TypeSourceInfo *TInfo);
@ -4781,22 +4781,6 @@ private:
void CheckImplicitConversions(Expr *E);
};
//===--------------------------------------------------------------------===//
// Typed version of Parser::ExprArg (smart pointer for wrapping Expr pointers).
template <typename T>
class ExprOwningPtr : public Action::ExprArg {
public:
ExprOwningPtr(Sema *S, T *expr) : Action::ExprArg(*S, expr) {}
void reset(T* p) { Action::ExprArg::operator=(p); }
T* get() const { return static_cast<T*>(Action::ExprArg::get()); }
T* take() { return static_cast<T*>(Action::ExprArg::take()); }
T* release() { return take(); }
T& operator*() const { return *get(); }
T* operator->() const { return get(); }
};
} // end namespace clang
#endif

View File

@ -147,7 +147,7 @@ void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
else
Diag(Tok.getLocation(), diag::err_default_arg_unparsed);
Actions.ActOnParamDefaultArgument(LM.DefaultArgs[I].Param, EqualLoc,
move(DefArgResult));
DefArgResult.take());
}
assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
@ -231,7 +231,7 @@ void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
// Error recovery.
if (!Tok.is(tok::l_brace)) {
Actions.ActOnFinishFunctionBody(LM.D, Action::StmtArg(Actions));
Actions.ActOnFinishFunctionBody(LM.D, 0);
continue;
}
} else

View File

@ -593,7 +593,7 @@ Decl *Parser::ParseDeclarationAfterDeclarator(Declarator &D,
SkipUntil(tok::comma, true, true);
Actions.ActOnInitializerError(ThisDecl);
} else
Actions.AddInitializerToDecl(ThisDecl, move(Init));
Actions.AddInitializerToDecl(ThisDecl, Init.take());
}
} else if (Tok.is(tok::l_paren)) {
// Parse C++ direct initializer: '(' expression-list ')'
@ -3136,7 +3136,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
} else {
// Inform the actions module about the default argument
Actions.ActOnParamDefaultArgument(Param, EqualLoc,
move(DefArgResult));
DefArgResult.take());
}
}
}

View File

@ -413,8 +413,9 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){
DeclEnd = Tok.getLocation();
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_static_assert);
return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, move(AssertExpr),
move(AssertMessage));
return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc,
AssertExpr.take(),
AssertMessage.take());
}
/// ParseDecltypeSpecifier - Parse a C++0x decltype specifier.

View File

@ -210,10 +210,10 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) {
}
LHS = Actions.ActOnUnaryOp(getCurScope(), ExtLoc, tok::kw___extension__,
move(LHS));
LHS.take());
if (LHS.isInvalid()) return move(LHS);
return ParseRHSOfBinaryExpression(move(LHS), prec::Comma);
return ParseRHSOfBinaryExpression(LHS.take(), prec::Comma);
}
/// ParseAssignmentExpression - Parse an expr that doesn't include commas.
@ -230,7 +230,7 @@ Parser::OwningExprResult Parser::ParseAssignmentExpression() {
OwningExprResult LHS(ParseCastExpression(false));
if (LHS.isInvalid()) return move(LHS);
return ParseRHSOfBinaryExpression(move(LHS), prec::Assignment);
return ParseRHSOfBinaryExpression(LHS.take(), prec::Assignment);
}
/// ParseAssignmentExprWithObjCMessageExprStart - Parse an assignment expression
@ -245,14 +245,14 @@ Parser::OwningExprResult
Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc,
SourceLocation SuperLoc,
TypeTy *ReceiverType,
ExprArg ReceiverExpr) {
OwningExprResult R(ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
ReceiverType,
move(ReceiverExpr)));
Expr *ReceiverExpr) {
OwningExprResult R
= ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
ReceiverType, ReceiverExpr);
if (R.isInvalid()) return move(R);
R = ParsePostfixExpressionSuffix(move(R));
R = ParsePostfixExpressionSuffix(R.take());
if (R.isInvalid()) return move(R);
return ParseRHSOfBinaryExpression(move(R), prec::Assignment);
return ParseRHSOfBinaryExpression(R.take(), prec::Assignment);
}
@ -266,7 +266,7 @@ Parser::OwningExprResult Parser::ParseConstantExpression() {
OwningExprResult LHS(ParseCastExpression(false));
if (LHS.isInvalid()) return move(LHS);
return ParseRHSOfBinaryExpression(move(LHS), prec::Conditional);
return ParseRHSOfBinaryExpression(LHS.take(), prec::Conditional);
}
/// ParseRHSOfBinaryExpression - Parse a binary expression that starts with
@ -384,7 +384,7 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, prec::Level MinPrec) {
// is okay, to bind exactly as tightly. For example, compile A=B=C=D as
// A=(B=(C=D)), where each paren is a level of recursion here.
// The function takes ownership of the RHS.
RHS = ParseRHSOfBinaryExpression(move(RHS),
RHS = ParseRHSOfBinaryExpression(RHS.get(),
static_cast<prec::Level>(ThisPrec + !isRightAssoc));
if (RHS.isInvalid())
return move(RHS);
@ -407,11 +407,11 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, prec::Level MinPrec) {
Actions.getExprRange(RHS.get()).getEnd()));
LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
OpToken.getKind(), move(LHS), move(RHS));
OpToken.getKind(), LHS.take(), RHS.take());
} else
LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
move(LHS), move(TernaryMiddle),
move(RHS));
LHS.take(), TernaryMiddle.take(),
RHS.take());
}
}
}
@ -560,9 +560,10 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
// expression, or statement expression.
//
// If the parsed tokens consist of a primary-expression, the cases below
// call ParsePostfixExpressionSuffix to handle the postfix expression
// suffixes. Cases that cannot be followed by postfix exprs should
// return without invoking ParsePostfixExpressionSuffix.
// break out of the switch; at the end we call ParsePostfixExpressionSuffix
// to handle the postfix expression suffixes. Cases that cannot be followed
// by postfix exprs should return without invoking
// ParsePostfixExpressionSuffix.
switch (SavedKind) {
case tok::l_paren: {
// If this expression is limited to being a unary-expression, the parent can
@ -596,8 +597,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
return move(Res);
}
// These can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
}
// primary-expression
@ -607,9 +607,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
Res = Actions.ActOnNumericConstant(Tok);
ConsumeToken();
// These can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
case tok::kw_true:
case tok::kw_false:
@ -660,8 +658,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
Res = Actions.ActOnClassPropertyRefExpr(II, PropertyName,
ILoc, PropertyLoc);
// These can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
}
// Function designators are allowed to be undeclared (C99 6.5.1p2), so we
@ -672,28 +669,22 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
Name.setIdentifier(&II, ILoc);
Res = Actions.ActOnIdExpression(getCurScope(), ScopeSpec, Name,
Tok.is(tok::l_paren), false);
// These can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
}
case tok::char_constant: // constant: character-constant
Res = Actions.ActOnCharacterConstant(Tok);
ConsumeToken();
// These can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
case tok::kw___func__: // primary-expression: __func__ [C99 6.4.2.2]
case tok::kw___FUNCTION__: // primary-expression: __FUNCTION__ [GNU]
case tok::kw___PRETTY_FUNCTION__: // primary-expression: __P..Y_F..N__ [GNU]
Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
ConsumeToken();
// These can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
case tok::string_literal: // primary-expression: string-literal
case tok::wide_string_literal:
Res = ParseStringLiteralExpression();
if (Res.isInvalid()) return move(Res);
// This can be followed by postfix-expr pieces (e.g. "foo"[1]).
return ParsePostfixExpressionSuffix(move(Res));
break;
case tok::kw___builtin_va_arg:
case tok::kw___builtin_offsetof:
case tok::kw___builtin_choose_expr:
@ -711,7 +702,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
SourceLocation SavedLoc = ConsumeToken();
Res = ParseCastExpression(!getLang().CPlusPlus);
if (!Res.isInvalid())
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, move(Res));
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get());
return move(Res);
}
case tok::amp: { // unary-expression: '&' cast-expression
@ -719,7 +710,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
SourceLocation SavedLoc = ConsumeToken();
Res = ParseCastExpression(false, true);
if (!Res.isInvalid())
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, move(Res));
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get());
return move(Res);
}
@ -733,7 +724,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
SourceLocation SavedLoc = ConsumeToken();
Res = ParseCastExpression(false);
if (!Res.isInvalid())
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, move(Res));
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get());
return move(Res);
}
@ -743,7 +734,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
SourceLocation SavedLoc = ConsumeToken();
Res = ParseCastExpression(false);
if (!Res.isInvalid())
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, move(Res));
Res = Actions.ActOnUnaryOp(getCurScope(), SavedLoc, SavedKind, Res.get());
return move(Res);
}
case tok::kw_sizeof: // unary-expression: 'sizeof' unary-expression
@ -769,16 +760,13 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
case tok::kw_reinterpret_cast:
case tok::kw_static_cast:
Res = ParseCXXCasts();
// These can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
case tok::kw_typeid:
Res = ParseCXXTypeid();
// This can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
case tok::kw_this:
Res = ParseCXXThis();
// This can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
case tok::kw_char:
case tok::kw_wchar_t:
@ -817,8 +805,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
<< DS.getSourceRange());
Res = ParseCXXTypeConstructExpression(DS);
// This can be followed by postfix-expr pieces.
return ParsePostfixExpressionSuffix(move(Res));
break;
}
case tok::annot_cxxscope: { // [C++] id-expression: qualified-id
@ -848,7 +835,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
// Parse as an id-expression.
Res = ParseCXXIdExpression(isAddressOfOperand);
return ParsePostfixExpressionSuffix(move(Res));
break;
}
case tok::annot_template_id: { // [C++] template-id
@ -868,7 +855,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
case tok::kw_operator: // [C++] id-expression: operator/conversion-function-id
Res = ParseCXXIdExpression(isAddressOfOperand);
return ParsePostfixExpressionSuffix(move(Res));
break;
case tok::coloncolon: {
// ::foo::bar -> global qualified name etc. If TryAnnotateTypeOrScopeToken
@ -932,8 +919,9 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression,
return ExprError();
}
// unreachable.
abort();
// These can be followed by postfix-expr pieces.
if (Res.isInvalid()) return move(Res);
return ParsePostfixExpressionSuffix(Res.get());
}
/// ParsePostfixExpressionSuffix - Once the leading part of a postfix-expression
@ -980,8 +968,8 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
SourceLocation RLoc = Tok.getLocation();
if (!LHS.isInvalid() && !Idx.isInvalid() && Tok.is(tok::r_square)) {
LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), move(LHS), Loc,
move(Idx), RLoc);
LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.take(), Loc,
Idx.take(), RLoc);
} else
LHS = ExprError();
@ -1023,7 +1011,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
if (!LHS.isInvalid()) {
assert((ArgExprs.size() == 0 || ArgExprs.size()-1 == CommaLocs.size())&&
"Unexpected number of commas!");
LHS = Actions.ActOnCallExpr(getCurScope(), move(LHS), Loc,
LHS = Actions.ActOnCallExpr(getCurScope(), LHS.take(), Loc,
move_arg(ArgExprs), CommaLocs.data(),
Tok.getLocation());
}
@ -1042,7 +1030,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
Action::TypeTy *ObjectType = 0;
bool MayBePseudoDestructor = false;
if (getLang().CPlusPlus && !LHS.isInvalid()) {
LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), move(LHS),
LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), LHS.take(),
OpLoc, OpKind, ObjectType,
MayBePseudoDestructor);
if (LHS.isInvalid())
@ -1062,8 +1050,8 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
ConsumeCodeCompletionToken();
}
if (MayBePseudoDestructor) {
LHS = ParseCXXPseudoDestructor(move(LHS), OpLoc, OpKind, SS,
if (MayBePseudoDestructor && !LHS.isInvalid()) {
LHS = ParseCXXPseudoDestructor(LHS.take(), OpLoc, OpKind, SS,
ObjectType);
break;
}
@ -1083,7 +1071,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
return ExprError();
if (!LHS.isInvalid())
LHS = Actions.ActOnMemberAccessExpr(getCurScope(), move(LHS), OpLoc,
LHS = Actions.ActOnMemberAccessExpr(getCurScope(), LHS.take(), OpLoc,
OpKind, SS, Name, ObjCImpDecl,
Tok.is(tok::l_paren));
break;
@ -1092,7 +1080,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
case tok::minusminus: // postfix-expression: postfix-expression '--'
if (!LHS.isInvalid()) {
LHS = Actions.ActOnPostfixUnaryOp(getCurScope(), Tok.getLocation(),
Tok.getKind(), move(LHS));
Tok.getKind(), LHS.take());
}
ConsumeToken();
break;
@ -1179,7 +1167,7 @@ Parser::ParseExprAfterTypeofSizeofAlignof(const Token &OpTok,
// sizeof/alignof or in C++. Therefore, the parenthesized expression is
// the start of a unary-expression, but doesn't include any postfix
// pieces. Parse these now if present.
Operand = ParsePostfixExpressionSuffix(move(Operand));
Operand = ParsePostfixExpressionSuffix(Operand.take());
}
}
@ -1276,7 +1264,7 @@ Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() {
if (Ty.isInvalid())
Res = ExprError();
else
Res = Actions.ActOnVAArg(StartLoc, move(Expr), Ty.get(), ConsumeParen());
Res = Actions.ActOnVAArg(StartLoc, Expr.take(), Ty.get(), ConsumeParen());
break;
}
case tok::kw___builtin_offsetof: {
@ -1377,8 +1365,8 @@ Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() {
Diag(Tok, diag::err_expected_rparen);
return ExprError();
}
Res = Actions.ActOnChooseExpr(StartLoc, move(Cond), move(Expr1),
move(Expr2), ConsumeParen());
Res = Actions.ActOnChooseExpr(StartLoc, Cond.take(), Expr1.take(),
Expr2.take(), ConsumeParen());
break;
}
case tok::kw___builtin_types_compatible_p:
@ -1402,9 +1390,12 @@ Parser::OwningExprResult Parser::ParseBuiltinPrimaryExpression() {
break;
}
if (Res.isInvalid())
return ExprError();
// These can be followed by postfix-expr pieces because they are
// primary-expressions.
return ParsePostfixExpressionSuffix(move(Res));
return ParsePostfixExpressionSuffix(Res.take());
}
/// ParseParenExpression - This parses the unit that starts with a '(' token,
@ -1439,7 +1430,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
// If the substmt parsed correctly, build the AST node.
if (!Stmt.isInvalid() && Tok.is(tok::r_paren))
Result = Actions.ActOnStmtExpr(OpenLoc, move(Stmt), Tok.getLocation());
Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.take(), Tok.getLocation());
} else if (ExprType >= CompoundLiteral &&
isTypeIdInParens(isAmbiguousTypeId)) {
@ -1496,7 +1487,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
Result = ParseCastExpression(false, false, CastTy);
if (!Result.isInvalid())
Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc, CastTy, RParenLoc,
move(Result));
Result.take());
return move(Result);
}
@ -1516,7 +1507,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
Result = ParseExpression();
ExprType = SimpleExpr;
if (!Result.isInvalid() && Tok.is(tok::r_paren))
Result = Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), move(Result));
Result = Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), Result.take());
}
// Match the ')'.
@ -1549,7 +1540,7 @@ Parser::ParseCompoundLiteralExpression(TypeTy *Ty,
Diag(LParenLoc, diag::ext_c99_compound_literal);
OwningExprResult Result = ParseInitializer();
if (!Result.isInvalid() && Ty)
return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, move(Result));
return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, Result.take());
return move(Result);
}
@ -1734,7 +1725,7 @@ Parser::OwningExprResult Parser::ParseBlockLiteralExpression() {
OwningStmtResult Stmt(ParseCompoundStatementBody());
if (!Stmt.isInvalid())
Result = Actions.ActOnBlockStmtExpr(CaretLoc, move(Stmt), getCurScope());
Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.take(), getCurScope());
else
Actions.ActOnBlockError(CaretLoc, getCurScope());
return move(Result);

View File

@ -484,7 +484,7 @@ Parser::OwningExprResult Parser::ParseCXXCasts() {
Result = Actions.ActOnCXXNamedCast(OpLoc, Kind,
LAngleBracketLoc, CastTy.get(),
RAngleBracketLoc,
LParenLoc, move(Result), RParenLoc);
LParenLoc, Result.take(), RParenLoc);
return move(Result);
}
@ -613,7 +613,8 @@ Parser::ParseCXXPseudoDestructor(ExprArg Base, SourceLocation OpLoc,
/*TemplateKWLoc*/SourceLocation()))
return ExprError();
return Actions.ActOnPseudoDestructorExpr(getCurScope(), move(Base), OpLoc, OpKind,
return Actions.ActOnPseudoDestructorExpr(getCurScope(), Base,
OpLoc, OpKind,
SS, FirstTypeName, CCLoc,
TildeLoc, SecondTypeName,
Tok.is(tok::l_paren));
@ -647,12 +648,12 @@ Parser::OwningExprResult Parser::ParseThrowExpression() {
case tok::r_brace:
case tok::colon:
case tok::comma:
return Actions.ActOnCXXThrow(ThrowLoc, ExprArg(Actions));
return Actions.ActOnCXXThrow(ThrowLoc, 0);
default:
OwningExprResult Expr(ParseAssignmentExpression());
if (Expr.isInvalid()) return move(Expr);
return Actions.ActOnCXXThrow(ThrowLoc, move(Expr));
return Actions.ActOnCXXThrow(ThrowLoc, Expr.take());
}
}
@ -748,7 +749,7 @@ bool Parser::ParseCXXCondition(OwningExprResult &ExprResult,
// If required, convert to a boolean value.
if (ConvertToBoolean)
ExprResult
= Actions.ActOnBooleanCondition(getCurScope(), Loc, move(ExprResult));
= Actions.ActOnBooleanCondition(getCurScope(), Loc, ExprResult.take());
return ExprResult.isInvalid();
}
@ -790,7 +791,7 @@ bool Parser::ParseCXXCondition(OwningExprResult &ExprResult,
SourceLocation EqualLoc = ConsumeToken();
OwningExprResult AssignExpr(ParseAssignmentExpression());
if (!AssignExpr.isInvalid())
Actions.AddInitializerToDecl(DeclResult, move(AssignExpr));
Actions.AddInitializerToDecl(DeclResult, AssignExpr.take());
} else {
// FIXME: C++0x allows a braced-init-list
Diag(Tok, diag::err_expected_equal_after_declarator);
@ -1745,7 +1746,7 @@ Parser::ParseCXXDeleteExpression(bool UseGlobal, SourceLocation Start) {
if (Operand.isInvalid())
return move(Operand);
return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete, move(Operand));
return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete, Operand.take());
}
static UnaryTypeTrait UnaryTypeTraitFromTokKind(tok::TokenKind kind) {
@ -1899,7 +1900,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
// Result is what ParseCastExpression returned earlier.
if (!Result.isInvalid())
Result = Actions.ActOnCastExpr(getCurScope(), LParenLoc, CastTy, RParenLoc,
move(Result));
Result.take());
return move(Result);
}
@ -1909,7 +1910,7 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
ExprType = SimpleExpr;
Result = ParseExpression();
if (!Result.isInvalid() && Tok.is(tok::r_paren))
Result = Actions.ActOnParenExpr(LParenLoc, Tok.getLocation(), move(Result));
Result = Actions.ActOnParenExpr(LParenLoc, Tok.getLocation(), Result.take());
// Match the ')'.
if (Result.isInvalid()) {

View File

@ -150,7 +150,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
CheckArrayDesignatorSyntax(*this, StartLoc, Desig);
return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
ConsumeToken(), 0,
ExprArg(Actions));
0);
}
// Parse the receiver, which is either a type or an expression.
@ -168,7 +168,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
SourceLocation(),
TypeOrExpr,
ExprArg(Actions));
0);
}
// If the receiver was an expression, we still don't know
@ -195,7 +195,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
ConsumeToken(),
0,
ExprArg(Actions));
0);
ConsumeToken(); // the identifier
if (!ReceiverType) {
SkipUntil(tok::r_square);
@ -205,7 +205,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
SourceLocation(),
ReceiverType,
ExprArg(Actions));
0);
case Action::ObjCInstanceMessage:
// Fall through; we'll just parse the expression and
@ -239,7 +239,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
CheckArrayDesignatorSyntax(*this, Tok.getLocation(), Desig);
return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
SourceLocation(),
0, move(Idx));
0, Idx.take());
}
// If this is a normal array designator, remember it.

View File

@ -1470,7 +1470,7 @@ Parser::OwningStmtResult Parser::ParseObjCThrowStmt(SourceLocation atLoc) {
}
// consume ';'
ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@throw");
return Actions.ActOnObjCAtThrowStmt(atLoc, move(Res), getCurScope());
return Actions.ActOnObjCAtThrowStmt(atLoc, Res.take(), getCurScope());
}
/// objc-synchronized-statement:
@ -1507,7 +1507,7 @@ Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) {
BodyScope.Exit();
if (SynchBody.isInvalid())
SynchBody = Actions.ActOnNullStmt(Tok.getLocation());
return Actions.ActOnObjCAtSynchronizedStmt(atLoc, move(Res), move(SynchBody));
return Actions.ActOnObjCAtSynchronizedStmt(atLoc, Res.take(), SynchBody.take());
}
/// objc-try-catch-statement:
@ -1586,7 +1586,7 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
OwningStmtResult Catch = Actions.ActOnObjCAtCatchStmt(AtCatchFinallyLoc,
RParenLoc,
FirstPart,
move(CatchBody));
CatchBody.take());
if (!Catch.isInvalid())
CatchStmts.push_back(Catch.release());
@ -1609,7 +1609,7 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
if (FinallyBody.isInvalid())
FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc,
move(FinallyBody));
FinallyBody.take());
catch_or_finally_seen = true;
break;
}
@ -1619,9 +1619,9 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
return StmtError();
}
return Actions.ActOnObjCAtTryStmt(atLoc, move(TryBody),
return Actions.ActOnObjCAtTryStmt(atLoc, TryBody.take(),
move_arg(CatchStmts),
move(FinallyStmt));
FinallyStmt.take());
}
/// objc-method-def: objc-method-proto ';'[opt] '{' body '}'
@ -1671,7 +1671,7 @@ Decl *Parser::ParseObjCMethodDefinition() {
MultiStmtArg(Actions), false);
// TODO: Pass argument information.
Actions.ActOnFinishFunctionBody(MDecl, move(FnBody));
Actions.ActOnFinishFunctionBody(MDecl, FnBody.take());
// Leave the function body scope.
BodyScope.Exit();
@ -1706,7 +1706,7 @@ Parser::OwningStmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc) {
// Otherwise, eat the semicolon.
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
return Actions.ActOnExprStmt(Actions.MakeFullExpr(Res));
return Actions.ActOnExprStmt(Actions.MakeFullExpr(Res.take()));
}
Parser::OwningExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
@ -1797,9 +1797,9 @@ bool Parser::ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr) {
// instance method.
OwningExprResult Receiver = ParseCXXTypeConstructExpression(DS);
if (!Receiver.isInvalid())
Receiver = ParsePostfixExpressionSuffix(move(Receiver));
Receiver = ParsePostfixExpressionSuffix(Receiver.take());
if (!Receiver.isInvalid())
Receiver = ParseRHSOfBinaryExpression(move(Receiver), prec::Comma);
Receiver = ParseRHSOfBinaryExpression(Receiver.take(), prec::Comma);
if (Receiver.isInvalid())
return true;
@ -1863,7 +1863,7 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
if (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_super &&
NextToken().isNot(tok::period) && getCurScope()->isInObjcMethodScope())
return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(), 0,
ExprArg(Actions));
0);
// Parse the receiver, which is either a type or an expression.
bool IsExpr;
@ -1875,10 +1875,10 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
if (IsExpr)
return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), 0,
OwningExprResult(static_cast<Expr*>(TypeOrExpr)));
static_cast<Expr*>(TypeOrExpr));
return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(),
TypeOrExpr, ExprArg(Actions));
TypeOrExpr, 0);
}
if (Tok.is(tok::identifier)) {
@ -1890,8 +1890,7 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
NextToken().is(tok::period),
ReceiverType)) {
case Action::ObjCSuperMessage:
return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(), 0,
ExprArg(Actions));
return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(), 0, 0);
case Action::ObjCClassMessage:
if (!ReceiverType) {
@ -1902,8 +1901,7 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
ConsumeToken(); // the type name
return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(),
ReceiverType,
ExprArg(Actions));
ReceiverType, 0);
case Action::ObjCInstanceMessage:
// Fall through to parse an expression.
@ -1919,7 +1917,7 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() {
}
return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), 0,
move(Res));
Res.take());
}
/// \brief Parse the remainder of an Objective-C message following the
@ -1971,7 +1969,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
else if (ReceiverType)
Actions.CodeCompleteObjCClassMessage(getCurScope(), ReceiverType, 0, 0);
else
Actions.CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr.get(),
Actions.CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
0, 0);
ConsumeCodeCompletionToken();
}
@ -2024,7 +2022,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
KeyIdents.data(),
KeyIdents.size());
else
Actions.CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr.get(),
Actions.CodeCompleteObjCInstanceMessage(getCurScope(), ReceiverExpr,
KeyIdents.data(),
KeyIdents.size());
ConsumeCodeCompletionToken();
@ -2093,7 +2091,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
Action::MultiExprArg(Actions,
KeyExprs.take(),
KeyExprs.size()));
return Actions.ActOnInstanceMessage(getCurScope(), move(ReceiverExpr), Sel,
return Actions.ActOnInstanceMessage(getCurScope(), ReceiverExpr, Sel,
LBracLoc, SelectorLoc, RBracLoc,
Action::MultiExprArg(Actions,
KeyExprs.take(),

View File

@ -137,7 +137,7 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
}
// Otherwise, eat the semicolon.
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
return Actions.ActOnExprStmt(Actions.MakeFullExpr(Expr));
return Actions.ActOnExprStmt(Actions.MakeFullExpr(Expr.get()));
}
case tok::kw_case: // C99 6.8.1: labeled-statement
@ -243,7 +243,7 @@ Parser::OwningStmtResult Parser::ParseLabeledStatement(AttributeList *Attr) {
// FIXME: use attributes?
return Actions.ActOnLabelStmt(IdentTok.getLocation(),
IdentTok.getIdentifierInfo(),
ColonLoc, move(SubStmt));
ColonLoc, SubStmt.get());
}
/// ParseCaseStatement
@ -324,8 +324,8 @@ Parser::OwningStmtResult Parser::ParseCaseStatement(AttributeList *Attr) {
SourceLocation ColonLoc = ConsumeToken();
OwningStmtResult Case =
Actions.ActOnCaseStmt(CaseLoc, move(LHS), DotDotDotLoc,
move(RHS), ColonLoc);
Actions.ActOnCaseStmt(CaseLoc, LHS.get(), DotDotDotLoc,
RHS.get(), ColonLoc);
// If we had a sema error parsing this case, then just ignore it and
// continue parsing the sub-stmt.
@ -340,7 +340,7 @@ Parser::OwningStmtResult Parser::ParseCaseStatement(AttributeList *Attr) {
if (TopLevelCase.isInvalid())
TopLevelCase = move(Case);
else
Actions.ActOnCaseStmtBody(DeepestParsedCaseStmt, move(Case));
Actions.ActOnCaseStmtBody(DeepestParsedCaseStmt, Case.get());
DeepestParsedCaseStmt = NextDeepest;
}
@ -367,7 +367,7 @@ Parser::OwningStmtResult Parser::ParseCaseStatement(AttributeList *Attr) {
SubStmt = Actions.ActOnNullStmt(SourceLocation());
// Install the body into the most deeply-nested case.
Actions.ActOnCaseStmtBody(DeepestParsedCaseStmt, move(SubStmt));
Actions.ActOnCaseStmtBody(DeepestParsedCaseStmt, SubStmt.get());
// Return the top level parsed statement tree.
return move(TopLevelCase);
@ -404,7 +404,7 @@ Parser::OwningStmtResult Parser::ParseDefaultStatement(AttributeList *Attr) {
return StmtError();
return Actions.ActOnDefaultStmt(DefaultLoc, ColonLoc,
move(SubStmt), getCurScope());
SubStmt.get(), getCurScope());
}
@ -507,7 +507,7 @@ Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
// Eat the semicolon at the end of stmt and convert the expr into a
// statement.
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
R = Actions.ActOnExprStmt(Actions.MakeFullExpr(Res));
R = Actions.ActOnExprStmt(Actions.MakeFullExpr(Res.get()));
}
}
@ -554,7 +554,7 @@ bool Parser::ParseParenExprOrCondition(OwningExprResult &ExprResult,
// If required, convert to a boolean value.
if (!ExprResult.isInvalid() && ConvertToBoolean)
ExprResult
= Actions.ActOnBooleanCondition(getCurScope(), Loc, move(ExprResult));
= Actions.ActOnBooleanCondition(getCurScope(), Loc, ExprResult.get());
}
// If the parser was confused by the condition and we don't have a ')', try to
@ -616,7 +616,7 @@ Parser::OwningStmtResult Parser::ParseIfStatement(AttributeList *Attr) {
if (ParseParenExprOrCondition(CondExp, CondVar, IfLoc, true))
return StmtError();
FullExprArg FullCondExp(Actions.MakeFullExpr(CondExp));
FullExprArg FullCondExp(Actions.MakeFullExpr(CondExp.get()));
// C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
@ -696,8 +696,8 @@ Parser::OwningStmtResult Parser::ParseIfStatement(AttributeList *Attr) {
if (ElseStmt.isInvalid())
ElseStmt = Actions.ActOnNullStmt(ElseStmtLoc);
return Actions.ActOnIfStmt(IfLoc, FullCondExp, CondVar, move(ThenStmt),
ElseLoc, move(ElseStmt));
return Actions.ActOnIfStmt(IfLoc, FullCondExp, CondVar, ThenStmt.get(),
ElseLoc, ElseStmt.get());
}
/// ParseSwitchStatement
@ -743,7 +743,7 @@ Parser::OwningStmtResult Parser::ParseSwitchStatement(AttributeList *Attr) {
return StmtError();
OwningStmtResult Switch
= Actions.ActOnStartOfSwitchStmt(SwitchLoc, move(Cond), CondVar);
= Actions.ActOnStartOfSwitchStmt(SwitchLoc, Cond.get(), CondVar);
if (Switch.isInvalid()) {
// Skip the switch body.
@ -783,7 +783,7 @@ Parser::OwningStmtResult Parser::ParseSwitchStatement(AttributeList *Attr) {
// FIXME: Remove the case statement list from the Switch statement.
Body = Actions.ActOnNullStmt(Tok.getLocation());
return Actions.ActOnFinishSwitchStmt(SwitchLoc, move(Switch), move(Body));
return Actions.ActOnFinishSwitchStmt(SwitchLoc, Switch.get(), Body.get());
}
/// ParseWhileStatement
@ -832,7 +832,7 @@ Parser::OwningStmtResult Parser::ParseWhileStatement(AttributeList *Attr) {
if (ParseParenExprOrCondition(Cond, CondVar, WhileLoc, true))
return StmtError();
FullExprArg FullCond(Actions.MakeFullExpr(Cond));
FullExprArg FullCond(Actions.MakeFullExpr(Cond.get()));
// C99 6.8.5p5 - In C99, the body of the if statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
@ -858,7 +858,7 @@ Parser::OwningStmtResult Parser::ParseWhileStatement(AttributeList *Attr) {
if ((Cond.isInvalid() && !CondVar) || Body.isInvalid())
return StmtError();
return Actions.ActOnWhileStmt(WhileLoc, FullCond, CondVar, move(Body));
return Actions.ActOnWhileStmt(WhileLoc, FullCond, CondVar, Body.get());
}
/// ParseDoStatement
@ -925,8 +925,8 @@ Parser::OwningStmtResult Parser::ParseDoStatement(AttributeList *Attr) {
if (Cond.isInvalid() || Body.isInvalid())
return StmtError();
return Actions.ActOnDoStmt(DoLoc, move(Body), WhileLoc, LPLoc,
move(Cond), RPLoc);
return Actions.ActOnDoStmt(DoLoc, Body.get(), WhileLoc, LPLoc,
Cond.get(), RPLoc);
}
/// ParseForStatement
@ -1038,7 +1038,7 @@ Parser::OwningStmtResult Parser::ParseForStatement(AttributeList *Attr) {
// Turn the expression into a stmt.
if (!Value.isInvalid())
FirstPart = Actions.ActOnExprStmt(Actions.MakeFullExpr(Value));
FirstPart = Actions.ActOnExprStmt(Actions.MakeFullExpr(Value.get()));
if (Tok.is(tok::semi)) {
ConsumeToken();
@ -1056,7 +1056,7 @@ Parser::OwningStmtResult Parser::ParseForStatement(AttributeList *Attr) {
}
}
if (!ForEach) {
assert(!SecondPart->get() && "Shouldn't have a second expression yet.");
assert(!SecondPart.get() && "Shouldn't have a second expression yet.");
// Parse the second part of the for specifier.
if (Tok.is(tok::semi)) { // for (...;;
// no second part.
@ -1068,10 +1068,10 @@ Parser::OwningStmtResult Parser::ParseForStatement(AttributeList *Attr) {
Second = ParseExpression();
if (!Second.isInvalid())
Second = Actions.ActOnBooleanCondition(getCurScope(), ForLoc,
move(Second));
Second.get());
}
SecondPartIsInvalid = Second.isInvalid();
SecondPart = Actions.MakeFullExpr(Second);
SecondPart = Actions.MakeFullExpr(Second.get());
}
if (Tok.is(tok::semi)) {
@ -1085,7 +1085,7 @@ Parser::OwningStmtResult Parser::ParseForStatement(AttributeList *Attr) {
// Parse the third part of the for specifier.
if (Tok.isNot(tok::r_paren)) { // for (...;...;)
OwningExprResult Third = ParseExpression();
ThirdPart = Actions.MakeFullExpr(Third);
ThirdPart = Actions.MakeFullExpr(Third.take());
}
}
// Match the ')'.
@ -1118,14 +1118,14 @@ Parser::OwningStmtResult Parser::ParseForStatement(AttributeList *Attr) {
return StmtError();
if (!ForEach)
return Actions.ActOnForStmt(ForLoc, LParenLoc, move(FirstPart), SecondPart,
SecondVar, ThirdPart, RParenLoc, move(Body));
return Actions.ActOnForStmt(ForLoc, LParenLoc, FirstPart.take(), SecondPart,
SecondVar, ThirdPart, RParenLoc, Body.take());
// FIXME: It isn't clear how to communicate the late destruction of
// C++ temporaries used to create the collection.
return Actions.ActOnObjCForCollectionStmt(ForLoc, LParenLoc, move(FirstPart),
move(Collection), RParenLoc,
move(Body));
return Actions.ActOnObjCForCollectionStmt(ForLoc, LParenLoc, FirstPart.take(),
Collection.take(), RParenLoc,
Body.take());
}
/// ParseGotoStatement
@ -1156,7 +1156,7 @@ Parser::OwningStmtResult Parser::ParseGotoStatement(AttributeList *Attr) {
SkipUntil(tok::semi, false, true);
return StmtError();
}
Res = Actions.ActOnIndirectGotoStmt(GotoLoc, StarLoc, move(R));
Res = Actions.ActOnIndirectGotoStmt(GotoLoc, StarLoc, R.take());
} else {
Diag(Tok, diag::err_expected_ident);
return StmtError();
@ -1218,7 +1218,7 @@ Parser::OwningStmtResult Parser::ParseReturnStatement(AttributeList *Attr) {
return StmtError();
}
}
return Actions.ActOnReturnStmt(ReturnLoc, move(R));
return Actions.ActOnReturnStmt(ReturnLoc, R.take());
}
/// FuzzyParseMicrosoftAsmStatement. When -fms-extensions is enabled, this
@ -1253,7 +1253,7 @@ Parser::OwningStmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
ExprVector Clobbers(Actions);
return Actions.ActOnAsmStmt(Tok.getLocation(), true, true, 0, 0, 0,
move_arg(Constraints), move_arg(Exprs),
move(AsmString), move_arg(Clobbers),
AsmString.take(), move_arg(Clobbers),
Tok.getLocation(), true);
}
@ -1326,7 +1326,7 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
return Actions.ActOnAsmStmt(AsmLoc, /*isSimple*/ true, isVolatile,
/*NumOutputs*/ 0, /*NumInputs*/ 0, 0,
move_arg(Constraints), move_arg(Exprs),
move(AsmString), move_arg(Clobbers),
AsmString.take(), move_arg(Clobbers),
RParenLoc);
}
@ -1391,7 +1391,7 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
return Actions.ActOnAsmStmt(AsmLoc, false, isVolatile,
NumOutputs, NumInputs, Names.data(),
move_arg(Constraints), move_arg(Exprs),
move(AsmString), move_arg(Clobbers),
AsmString.take(), move_arg(Clobbers),
RParenLoc);
}
@ -1482,7 +1482,7 @@ Decl *Parser::ParseFunctionStatementBody(Decl *Decl) {
FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc,
MultiStmtArg(Actions), false);
return Actions.ActOnFinishFunctionBody(Decl, move(FnBody));
return Actions.ActOnFinishFunctionBody(Decl, FnBody.take());
}
/// ParseFunctionTryBlock - Parse a C++ function-try-block.
@ -1510,7 +1510,7 @@ Decl *Parser::ParseFunctionTryBlock(Decl *Decl) {
FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc,
MultiStmtArg(Actions), false);
return Actions.ActOnFinishFunctionBody(Decl, move(FnBody));
return Actions.ActOnFinishFunctionBody(Decl, FnBody.take());
}
/// ParseCXXTryBlock - Parse a C++ try-block.
@ -1566,7 +1566,7 @@ Parser::OwningStmtResult Parser::ParseCXXTryBlockCommon(SourceLocation TryLoc) {
if (Handlers.empty())
return StmtError();
return Actions.ActOnCXXTryBlock(TryLoc, move(TryBlock), move_arg(Handlers));
return Actions.ActOnCXXTryBlock(TryLoc, TryBlock.take(), move_arg(Handlers));
}
/// ParseCXXCatchBlock - Parse a C++ catch block, called handler in the standard
@ -1618,5 +1618,5 @@ Parser::OwningStmtResult Parser::ParseCXXCatchBlock() {
if (Block.isInvalid())
return move(Block);
return Actions.ActOnCXXCatchBlock(CatchLoc, ExceptionDecl, move(Block));
return Actions.ActOnCXXCatchBlock(CatchLoc, ExceptionDecl, Block.take());
}

View File

@ -620,7 +620,7 @@ Parser::ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position) {
// Create the parameter.
return Actions.ActOnNonTypeTemplateParameter(getCurScope(), ParamDecl,
Depth, Position, EqualLoc,
move(DefaultArg));
DefaultArg.take());
}
/// \brief Parses a template-id that after the template name has

View File

@ -443,7 +443,7 @@ Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration(CXX0XAttributeList Attr)
if (Result.isInvalid())
return DeclGroupPtrTy();
SingleDecl = Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), move(Result));
SingleDecl = Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), Result.get());
break;
}
case tok::at:
@ -696,7 +696,7 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
// Recover from error.
if (!Tok.is(tok::l_brace)) {
Actions.ActOnFinishFunctionBody(Res, Action::StmtArg(Actions));
Actions.ActOnFinishFunctionBody(Res, 0);
return Res;
}
} else

View File

@ -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());

View File

@ -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);

View File

@ -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));

View File

@ -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())

View File

@ -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 BaseArg,
Sema::OwningExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr *Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
CXXScopeSpec &SS,
@ -3340,13 +3330,13 @@ Sema::OwningExprResult Sema::ActOnMemberAccessExpr(Scope *S, ExprArg BaseArg,
static_cast<NestedNameSpecifier*>(SS.getScopeRep())));
// This is a postfix expression, so get rid of ParenListExprs.
BaseArg = MaybeConvertParenListExprToParenExpr(S, move(BaseArg));
OwningExprResult Result = MaybeConvertParenListExprToParenExpr(S, Base);
if (Result.isInvalid()) return ExprError();
Base = Result.take();
Expr *Base = BaseArg.takeAs<Expr>();
OwningExprResult Result;
if (Base->getType()->isDependentType() || Name.isDependentName() ||
isDependentScopeSpecifier(SS)) {
Result = ActOnDependentMemberExpr(ExprArg(*this, Base), Base->getType(),
Result = ActOnDependentMemberExpr(Base, Base->getType(),
IsArrow, OpLoc,
SS, FirstQualifierInScope,
NameInfo, TemplateArgs);
@ -3367,12 +3357,12 @@ Sema::OwningExprResult Sema::ActOnMemberAccessExpr(Scope *S, ExprArg BaseArg,
// call now.
if (!HasTrailingLParen &&
Id.getKind() == UnqualifiedId::IK_DestructorName)
return DiagnoseDtorReference(NameInfo.getLoc(), move(Result));
return DiagnoseDtorReference(NameInfo.getLoc(), Result.get());
return move(Result);
}
Result = BuildMemberReferenceExpr(ExprArg(*this, Base), Base->getType(),
Result = BuildMemberReferenceExpr(Base, Base->getType(),
OpLoc, IsArrow, SS, FirstQualifierInScope,
R, TemplateArgs);
}
@ -3571,17 +3561,17 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc,
/// This provides the location of the left/right parens and a list of comma
/// locations.
Action::OwningExprResult
Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
MultiExprArg args,
SourceLocation *CommaLocs, SourceLocation RParenLoc) {
unsigned NumArgs = args.size();
// Since this might be a postfix expression, get rid of ParenListExprs.
fn = MaybeConvertParenListExprToParenExpr(S, move(fn));
OwningExprResult Result = MaybeConvertParenListExprToParenExpr(S, Fn);
if (Result.isInvalid()) return ExprError();
Fn = Result.take();
Expr *Fn = fn.takeAs<Expr>();
Expr **Args = reinterpret_cast<Expr**>(args.release());
assert(Fn && "no function call expression");
Expr **Args = args.release();
if (getLangOptions().CPlusPlus) {
// If this is a pseudo-destructor expression, build the call immediately.
@ -3653,21 +3643,21 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc,
= BO->getType()->getAs<FunctionProtoType>()) {
QualType ResultTy = FPT->getCallResultType(Context);
ExprOwningPtr<CXXMemberCallExpr>
TheCall(this, new (Context) CXXMemberCallExpr(Context, BO, Args,
NumArgs, ResultTy,
RParenLoc));
CXXMemberCallExpr *TheCall
= new (Context) CXXMemberCallExpr(Context, BO, Args,
NumArgs, ResultTy,
RParenLoc);
if (CheckCallReturnType(FPT->getResultType(),
BO->getRHS()->getSourceRange().getBegin(),
TheCall.get(), 0))
TheCall, 0))
return ExprError();
if (ConvertArgumentsForCall(&*TheCall, BO, 0, FPT, Args, NumArgs,
if (ConvertArgumentsForCall(TheCall, BO, 0, FPT, Args, NumArgs,
RParenLoc))
return ExprError();
return Owned(MaybeBindToTemporary(TheCall.release()).release());
return MaybeBindToTemporary(TheCall);
}
return ExprError(Diag(Fn->getLocStart(),
diag::err_typecheck_call_not_function)
@ -3712,10 +3702,10 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
// Make the call expr early, before semantic checks. This guarantees cleanup
// of arguments and function on error.
ExprOwningPtr<CallExpr> TheCall(this, new (Context) CallExpr(Context, Fn,
Args, NumArgs,
Context.BoolTy,
RParenLoc));
CallExpr *TheCall = new (Context) CallExpr(Context, Fn,
Args, NumArgs,
Context.BoolTy,
RParenLoc);
const FunctionType *FuncT;
if (!Fn->getType()->isBlockPointerType()) {
@ -3736,7 +3726,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
// Check for a valid return type
if (CheckCallReturnType(FuncT->getResultType(),
Fn->getSourceRange().getBegin(), TheCall.get(),
Fn->getSourceRange().getBegin(), TheCall,
FDecl))
return ExprError();
@ -3744,7 +3734,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
TheCall->setType(FuncT->getCallResultType(Context));
if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FuncT)) {
if (ConvertArgumentsForCall(&*TheCall, Fn, FDecl, Proto, Args, NumArgs,
if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, NumArgs,
RParenLoc))
return ExprError();
} else {
@ -3788,22 +3778,22 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
// Do special checking on direct calls to functions.
if (FDecl) {
if (CheckFunctionCall(FDecl, TheCall.get()))
if (CheckFunctionCall(FDecl, TheCall))
return ExprError();
if (unsigned BuiltinID = FDecl->getBuiltinID())
return CheckBuiltinFunctionCall(BuiltinID, TheCall.take());
return CheckBuiltinFunctionCall(BuiltinID, TheCall);
} else if (NDecl) {
if (CheckBlockCall(NDecl, TheCall.get()))
if (CheckBlockCall(NDecl, TheCall))
return ExprError();
}
return MaybeBindToTemporary(TheCall.take());
return MaybeBindToTemporary(TheCall);
}
Action::OwningExprResult
Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
SourceLocation RParenLoc, ExprArg InitExpr) {
SourceLocation RParenLoc, Expr *InitExpr) {
assert((Ty != 0) && "ActOnCompoundLiteral(): missing type");
// FIXME: put back this assert when initializers are worked out.
//assert((InitExpr != 0) && "ActOnCompoundLiteral(): missing expression");
@ -3813,14 +3803,13 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
if (!TInfo)
TInfo = Context.getTrivialTypeSourceInfo(literalType);
return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, move(InitExpr));
return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
}
Action::OwningExprResult
Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
SourceLocation RParenLoc, ExprArg InitExpr) {
SourceLocation RParenLoc, Expr *literalExpr) {
QualType literalType = TInfo->getType();
Expr *literalExpr = static_cast<Expr*>(InitExpr.get());
if (literalType->isArrayType()) {
if (literalType->isVariableArrayType())
@ -3844,8 +3833,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
&literalType);
if (Result.isInvalid())
return ExprError();
InitExpr.release();
literalExpr = static_cast<Expr*>(Result.get());
literalExpr = Result.get();
bool isFileScope = getCurFunctionOrMethodDecl() == 0;
if (isFileScope) { // 6.5.2.5p3
@ -3853,8 +3841,6 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
return ExprError();
}
Result.release();
return Owned(new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType,
literalExpr, isFileScope));
}
@ -3863,7 +3849,7 @@ Action::OwningExprResult
Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg initlist,
SourceLocation RBraceLoc) {
unsigned NumInit = initlist.size();
Expr **InitList = reinterpret_cast<Expr**>(initlist.release());
Expr **InitList = initlist.release();
// Semantic analysis for initializers is done by ActOnDeclarator() and
// CheckInitializer() - it requires knowledge of the object being intialized.
@ -4062,8 +4048,8 @@ bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *&CastExpr,
Action::OwningExprResult
Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty,
SourceLocation RParenLoc, ExprArg Op) {
assert((Ty != 0) && (Op.get() != 0) &&
SourceLocation RParenLoc, Expr *castExpr) {
assert((Ty != 0) && (castExpr != 0) &&
"ActOnCastExpr(): missing type or expr");
TypeSourceInfo *castTInfo;
@ -4072,26 +4058,22 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty,
castTInfo = Context.getTrivialTypeSourceInfo(castType);
// If the Expr being casted is a ParenListExpr, handle it specially.
Expr *castExpr = (Expr *)Op.get();
if (isa<ParenListExpr>(castExpr))
return ActOnCastOfParenListExpr(S, LParenLoc, RParenLoc, move(Op),
return ActOnCastOfParenListExpr(S, LParenLoc, RParenLoc, castExpr,
castTInfo);
return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, move(Op));
return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, castExpr);
}
Action::OwningExprResult
Sema::BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty,
SourceLocation RParenLoc, ExprArg Op) {
Expr *castExpr = static_cast<Expr*>(Op.get());
SourceLocation RParenLoc, Expr *castExpr) {
CastExpr::CastKind Kind = CastExpr::CK_Unknown;
CXXCastPath BasePath;
if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), Ty->getType(), castExpr,
Kind, BasePath))
return ExprError();
Op.release();
return Owned(CStyleCastExpr::Create(Context,
Ty->getType().getNonLValueExprType(Context),
Kind, castExpr, &BasePath, Ty,
@ -4100,9 +4082,8 @@ Sema::BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty,
/// This is not an AltiVec-style cast, so turn the ParenListExpr into a sequence
/// of comma binary operators.
Action::OwningExprResult
Sema::MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg EA) {
Expr *expr = EA.takeAs<Expr>();
OwningExprResult
Sema::MaybeConvertParenListExprToParenExpr(Scope *S, Expr *expr) {
ParenListExpr *E = dyn_cast<ParenListExpr>(expr);
if (!E)
return Owned(expr);
@ -4110,17 +4091,19 @@ Sema::MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg EA) {
OwningExprResult Result(E->getExpr(0));
for (unsigned i = 1, e = E->getNumExprs(); i != e && !Result.isInvalid(); ++i)
Result = ActOnBinOp(S, E->getExprLoc(), tok::comma, move(Result),
Owned(E->getExpr(i)));
Result = ActOnBinOp(S, E->getExprLoc(), tok::comma, Result.get(),
E->getExpr(i));
return ActOnParenExpr(E->getLParenLoc(), E->getRParenLoc(), move(Result));
if (Result.isInvalid()) return ExprError();
return ActOnParenExpr(E->getLParenLoc(), E->getRParenLoc(), Result.get());
}
Action::OwningExprResult
Sema::ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
SourceLocation RParenLoc, ExprArg Op,
SourceLocation RParenLoc, Expr *Op,
TypeSourceInfo *TInfo) {
ParenListExpr *PE = (ParenListExpr *)Op.get();
ParenListExpr *PE = cast<ParenListExpr>(Op);
QualType Ty = TInfo->getType();
bool isAltiVecLiteral = false;
@ -4148,17 +4131,17 @@ Sema::ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
// FIXME: This means that pretty-printing the final AST will produce curly
// braces instead of the original commas.
Op.release();
InitListExpr *E = new (Context) InitListExpr(Context, LParenLoc,
&initExprs[0],
initExprs.size(), RParenLoc);
E->setType(Ty);
return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, Owned(E));
return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, E);
} else {
// This is not an AltiVec-style cast, so turn the ParenListExpr into a
// sequence of BinOp comma operators.
Op = MaybeConvertParenListExprToParenExpr(S, move(Op));
return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, move(Op));
OwningExprResult Result = MaybeConvertParenListExprToParenExpr(S, Op);
if (Result.isInvalid()) return ExprError();
return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Result.take());
}
}
@ -4502,11 +4485,8 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS,
/// in the case of a the GNU conditional expr extension.
Action::OwningExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
SourceLocation ColonLoc,
ExprArg Cond, ExprArg LHS,
ExprArg RHS) {
Expr *CondExpr = (Expr *) Cond.get();
Expr *LHSExpr = (Expr *) LHS.get(), *RHSExpr = (Expr *) RHS.get();
Expr *CondExpr, Expr *LHSExpr,
Expr *RHSExpr) {
// If this is the gnu "x ?: y" extension, analyze the types as though the LHS
// was the condition.
bool isLHSNull = LHSExpr == 0;
@ -4518,9 +4498,6 @@ Action::OwningExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
if (result.isNull())
return ExprError();
Cond.release();
LHS.release();
RHS.release();
return Owned(new (Context) ConditionalOperator(CondExpr, QuestionLoc,
isLHSNull ? 0 : LHSExpr,
ColonLoc, RHSExpr, result));
@ -6653,10 +6630,8 @@ static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperator::Opcode Opc,
// Binary Operators. 'Tok' is the token for the operator.
Action::OwningExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
tok::TokenKind Kind,
ExprArg LHS, ExprArg RHS) {
Expr *lhs, Expr *rhs) {
BinaryOperator::Opcode Opc = ConvertTokenKindToBinaryOpcode(Kind);
Expr *lhs = LHS.takeAs<Expr>(), *rhs = RHS.takeAs<Expr>();
assert((lhs != 0) && "ActOnBinOp(): missing left expression");
assert((rhs != 0) && "ActOnBinOp(): missing right expression");
@ -6693,11 +6668,9 @@ Action::OwningExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
Action::OwningExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
unsigned OpcIn,
ExprArg InputArg) {
Expr *Input) {
UnaryOperator::Opcode Opc = static_cast<UnaryOperator::Opcode>(OpcIn);
// FIXME: Input is modified below, but InputArg is not updated appropriately.
Expr *Input = (Expr *)InputArg.get();
QualType resultType;
switch (Opc) {
case UnaryOperator::PreInc:
@ -6774,14 +6747,12 @@ Action::OwningExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
if (resultType.isNull())
return ExprError();
InputArg.release();
return Owned(new (Context) UnaryOperator(Input, Opc, resultType, OpLoc));
}
Action::OwningExprResult Sema::BuildUnaryOp(Scope *S, SourceLocation OpLoc,
UnaryOperator::Opcode Opc,
ExprArg input) {
Expr *Input = (Expr*)input.get();
Expr *Input) {
if (getLangOptions().CPlusPlus && Input->getType()->isOverloadableType() &&
Opc != UnaryOperator::Extension) {
// Find all of the overloaded operators visible from this
@ -6794,16 +6765,16 @@ Action::OwningExprResult Sema::BuildUnaryOp(Scope *S, SourceLocation OpLoc,
LookupOverloadedOperatorName(OverOp, S, Input->getType(), QualType(),
Functions);
return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, move(input));
return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
}
return CreateBuiltinUnaryOp(OpLoc, Opc, move(input));
return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
}
// Unary Operators. 'Tok' is the token for the operator.
Action::OwningExprResult Sema::ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
tok::TokenKind Op, ExprArg input) {
return BuildUnaryOp(S, OpLoc, ConvertTokenKindToUnaryOpcode(Op), move(input));
tok::TokenKind Op, Expr *Input) {
return BuildUnaryOp(S, OpLoc, ConvertTokenKindToUnaryOpcode(Op), Input);
}
/// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
@ -6824,9 +6795,8 @@ Sema::OwningExprResult Sema::ActOnAddrLabel(SourceLocation OpLoc,
}
Sema::OwningExprResult
Sema::ActOnStmtExpr(SourceLocation LPLoc, StmtArg substmt,
Sema::ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
SourceLocation RPLoc) { // "({..})"
Stmt *SubStmt = static_cast<Stmt*>(substmt.get());
assert(SubStmt && isa<CompoundStmt>(SubStmt) && "Invalid action invocation!");
CompoundStmt *Compound = cast<CompoundStmt>(SubStmt);
@ -6856,7 +6826,6 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, StmtArg substmt,
// FIXME: Check that expression type is complete/non-abstract; statement
// expressions are not lvalues.
substmt.release();
return Owned(new (Context) StmtExpr(Compound, Ty, LPLoc, RPLoc));
}
@ -7067,13 +7036,9 @@ Sema::BuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
Sema::OwningExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc,
ExprArg cond,
ExprArg expr1, ExprArg expr2,
Expr *CondExpr,
Expr *LHSExpr, Expr *RHSExpr,
SourceLocation RPLoc) {
Expr *CondExpr = static_cast<Expr*>(cond.get());
Expr *LHSExpr = static_cast<Expr*>(expr1.get());
Expr *RHSExpr = static_cast<Expr*>(expr2.get());
assert((CondExpr && LHSExpr && RHSExpr) && "Missing type argument(s)");
QualType resType;
@ -7096,7 +7061,6 @@ Sema::OwningExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc,
: RHSExpr->isValueDependent();
}
cond.release(); expr1.release(); expr2.release();
return Owned(new (Context) ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr,
resType, RPLoc,
resType->isDependentType(),
@ -7234,7 +7198,7 @@ void Sema::ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope) {
/// ActOnBlockStmtExpr - This is called when the body of a block statement
/// literal was successfully completed. ^(int x){...}
Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
StmtArg body, Scope *CurScope) {
Stmt *Body, Scope *CurScope) {
// If blocks are disabled, emit an error.
if (!LangOpts.Blocks)
Diag(CaretLoc, diag::err_blocks_disable);
@ -7297,9 +7261,9 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
// If needed, diagnose invalid gotos and switches in the block.
if (FunctionNeedsScopeChecking() && !hasAnyErrorsInThisFunction())
DiagnoseInvalidJumps(static_cast<CompoundStmt*>(body.get()));
DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
BSI->TheDecl->setBody(body.takeAs<CompoundStmt>());
BSI->TheDecl->setBody(cast<CompoundStmt>(Body));
bool Good = true;
// Check goto/label use.
@ -7333,17 +7297,16 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
}
Sema::OwningExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
ExprArg expr, TypeTy *type,
Expr *expr, TypeTy *type,
SourceLocation RPLoc) {
TypeSourceInfo *TInfo;
QualType T = GetTypeFromParser(type, &TInfo);
return BuildVAArgExpr(BuiltinLoc, move(expr), TInfo, RPLoc);
return BuildVAArgExpr(BuiltinLoc, expr, TInfo, RPLoc);
}
Sema::OwningExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
ExprArg expr, TypeSourceInfo *TInfo,
Expr *E, TypeSourceInfo *TInfo,
SourceLocation RPLoc) {
Expr *E = static_cast<Expr*>(expr.get());
Expr *OrigExpr = E;
InitBuiltinVaListType();
@ -7375,7 +7338,6 @@ Sema::OwningExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
// FIXME: Check that type is complete/non-abstract
// FIXME: Warn if a non-POD type is passed in.
expr.release();
QualType T = TInfo->getType().getNonLValueExprType(Context);
return Owned(new (Context) VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T));
}
@ -7909,8 +7871,7 @@ bool Sema::CheckBooleanCondition(Expr *&E, SourceLocation Loc) {
}
Sema::OwningExprResult Sema::ActOnBooleanCondition(Scope *S, SourceLocation Loc,
ExprArg SubExpr) {
Expr *Sub = SubExpr.takeAs<Expr>();
Expr *Sub) {
if (!Sub)
return ExprError();

View File

@ -281,10 +281,9 @@ Sema::OwningExprResult Sema::BuildCXXTypeId(QualType TypeInfoType,
/// \brief Build a C++ typeid expression with an expression operand.
Sema::OwningExprResult Sema::BuildCXXTypeId(QualType TypeInfoType,
SourceLocation TypeidLoc,
ExprArg Operand,
Expr *E,
SourceLocation RParenLoc) {
bool isUnevaluatedOperand = true;
Expr *E = static_cast<Expr *>(Operand.get());
if (E && !E->isTypeDependent()) {
QualType T = E->getType();
if (const RecordType *RecordT = T->getAs<RecordType>()) {
@ -317,8 +316,6 @@ Sema::OwningExprResult Sema::BuildCXXTypeId(QualType TypeInfoType,
if (!Context.hasSameType(T, UnqualT)) {
T = UnqualT;
ImpCastExprToType(E, UnqualT, CastExpr::CK_NoOp, CastCategory(E));
Operand.release();
Operand = Owned(E);
}
}
@ -329,7 +326,7 @@ Sema::OwningExprResult Sema::BuildCXXTypeId(QualType TypeInfoType,
ExprEvalContexts.back().Context = Unevaluated;
return Owned(new (Context) CXXTypeidExpr(TypeInfoType.withConst(),
Operand.takeAs<Expr>(),
E,
SourceRange(TypeidLoc, RParenLoc)));
}
@ -364,7 +361,7 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc,
}
// The operand is an expression.
return BuildCXXTypeId(TypeInfoType, OpLoc, Owned((Expr*)TyOrExpr), RParenLoc);
return BuildCXXTypeId(TypeInfoType, OpLoc, (Expr*)TyOrExpr, RParenLoc);
}
/// ActOnCXXBoolLiteral - Parse {true,false} literals.
@ -384,8 +381,7 @@ Sema::ActOnCXXNullPtrLiteral(SourceLocation Loc) {
/// ActOnCXXThrow - Parse throw expressions.
Action::OwningExprResult
Sema::ActOnCXXThrow(SourceLocation OpLoc, ExprArg E) {
Expr *Ex = E.takeAs<Expr>();
Sema::ActOnCXXThrow(SourceLocation OpLoc, Expr *Ex) {
if (Ex && !Ex->isTypeDependent() && CheckCXXThrowOperand(OpLoc, Ex))
return ExprError();
return Owned(new (Context) CXXThrowExpr(Ex, Context.VoidTy, OpLoc));
@ -643,7 +639,7 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
AllocType,
D.getSourceRange().getBegin(),
R,
Owned(ArraySize),
ArraySize,
ConstructorLParen,
move(ConstructorArgs),
ConstructorRParen);
@ -658,7 +654,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
QualType AllocType,
SourceLocation TypeLoc,
SourceRange TypeRange,
ExprArg ArraySizeE,
Expr *ArraySize,
SourceLocation ConstructorLParen,
MultiExprArg ConstructorArgs,
SourceLocation ConstructorRParen) {
@ -667,12 +663,12 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
// Per C++0x [expr.new]p5, the type being constructed may be a
// typedef of an array type.
if (!ArraySizeE.get()) {
if (!ArraySize) {
if (const ConstantArrayType *Array
= Context.getAsConstantArrayType(AllocType)) {
ArraySizeE = Owned(new (Context) IntegerLiteral(Array->getSize(),
Context.getSizeType(),
TypeRange.getEnd()));
ArraySize = new (Context) IntegerLiteral(Array->getSize(),
Context.getSizeType(),
TypeRange.getEnd());
AllocType = Array->getElementType();
}
}
@ -681,13 +677,12 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
// C++ 5.3.4p6: "The expression in a direct-new-declarator shall have integral
// or enumeration type with a non-negative value."
Expr *ArraySize = (Expr *)ArraySizeE.get();
if (ArraySize && !ArraySize->isTypeDependent()) {
QualType SizeType = ArraySize->getType();
OwningExprResult ConvertedSize
= ConvertToIntegralOrEnumerationType(StartLoc, move(ArraySizeE),
= ConvertToIntegralOrEnumerationType(StartLoc, ArraySize,
PDiag(diag::err_array_size_not_integral),
PDiag(diag::err_array_size_incomplete_type)
<< ArraySize->getSourceRange(),
@ -700,8 +695,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
if (ConvertedSize.isInvalid())
return ExprError();
ArraySize = ConvertedSize.takeAs<Expr>();
ArraySizeE = Owned(ArraySize);
ArraySize = ConvertedSize.take();
SizeType = ArraySize->getType();
if (!SizeType->isIntegralOrEnumerationType())
return ExprError();
@ -851,7 +845,6 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
PlacementArgs.release();
ConstructorArgs.release();
ArraySizeE.release();
// FIXME: The TypeSourceInfo should also be included in CXXNewExpr.
return Owned(new (Context) CXXNewExpr(Context, UseGlobal, OperatorNew,
@ -1382,7 +1375,7 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
/// @code delete [] ptr; @endcode
Action::OwningExprResult
Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
bool ArrayForm, ExprArg Operand) {
bool ArrayForm, Expr *Ex) {
// C++ [expr.delete]p1:
// The operand shall have a pointer type, or a class type having a single
// conversion function to a pointer type. The result has type void.
@ -1391,7 +1384,6 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
FunctionDecl *OperatorDelete = 0;
Expr *Ex = (Expr *)Operand.get();
if (!Ex->isTypeDependent()) {
QualType Type = Ex->getType();
@ -1425,11 +1417,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
// We have a single conversion to a pointer-to-object type. Perform
// that conversion.
// TODO: don't redo the conversion calculation.
Operand.release();
if (!PerformImplicitConversion(Ex,
ObjectPtrConversions.front()->getConversionType(),
AA_Converting)) {
Operand = Owned(Ex);
Type = Ex->getType();
}
}
@ -1470,10 +1460,6 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
ImpCastExprToType(Ex, Context.getPointerType(Context.VoidTy),
CastExpr::CK_NoOp);
// Update the operand.
Operand.take();
Operand = ExprArg(*this, Ex);
DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName(
ArrayForm ? OO_Array_Delete : OO_Delete);
@ -1505,7 +1491,6 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
// FIXME: Check access and ambiguity of operator delete and destructor.
}
Operand.release();
return Owned(new (Context) CXXDeleteExpr(Context.VoidTy, UseGlobal, ArrayForm,
OperatorDelete, Ex, StartLoc));
}
@ -1586,9 +1571,7 @@ static Sema::OwningExprResult BuildCXXCastArgument(Sema &S,
QualType Ty,
CastExpr::CastKind Kind,
CXXMethodDecl *Method,
Sema::ExprArg Arg) {
Expr *From = Arg.takeAs<Expr>();
Expr *From) {
switch (Kind) {
default: assert(0 && "Unhandled cast kind!");
case CastExpr::CK_ConstructorConversion: {
@ -1674,7 +1657,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
From->getLocStart(),
ToType.getNonReferenceType(),
CastKind, cast<CXXMethodDecl>(FD),
Owned(From));
From);
if (CastArg.isInvalid())
return true;
@ -2694,16 +2677,15 @@ FullExpr Sema::CreateFullExpr(Expr *SubExpr) {
}
Sema::OwningExprResult
Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc,
Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc,
tok::TokenKind OpKind, TypeTy *&ObjectType,
bool &MayBePseudoDestructor) {
// 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.get();
Expr *BaseExpr = (Expr*)Base.get();
assert(BaseExpr && "no record expansion");
QualType BaseType = BaseExpr->getType();
QualType BaseType = Base->getType();
MayBePseudoDestructor = false;
if (BaseType->isDependentType()) {
// If we have a pointer to a dependent type and are using the -> operator,
@ -2715,7 +2697,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc,
ObjectType = BaseType.getAsOpaquePtr();
MayBePseudoDestructor = true;
return move(Base);
return Owned(Base);
}
// C++ [over.match.oper]p8:
@ -2728,13 +2710,13 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc,
CTypes.insert(Context.getCanonicalType(BaseType));
while (BaseType->isRecordType()) {
Base = BuildOverloadedArrowExpr(S, move(Base), OpLoc);
BaseExpr = (Expr*)Base.get();
if (BaseExpr == NULL)
Result = BuildOverloadedArrowExpr(S, Base, OpLoc);
if (Result.isInvalid())
return ExprError();
if (CXXOperatorCallExpr *OpCall = dyn_cast<CXXOperatorCallExpr>(BaseExpr))
Base = Result.get();
if (CXXOperatorCallExpr *OpCall = dyn_cast<CXXOperatorCallExpr>(Base))
Locations.push_back(OpCall->getDirectCallee()->getLocation());
BaseType = BaseExpr->getType();
BaseType = Base->getType();
CanQualType CBaseType = Context.getCanonicalType(BaseType);
if (!CTypes.insert(CBaseType)) {
Diag(OpLoc, diag::err_operator_arrow_circular);
@ -2761,7 +2743,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc,
// pseudo-destructor-name.
ObjectType = 0;
MayBePseudoDestructor = true;
return move(Base);
return Owned(Base);
}
// The object type must be complete (or dependent).
@ -2780,22 +2762,21 @@ Sema::ActOnStartCXXMemberReference(Scope *S, ExprArg Base, SourceLocation OpLoc,
}
Sema::OwningExprResult Sema::DiagnoseDtorReference(SourceLocation NameLoc,
ExprArg MemExpr) {
Expr *E = (Expr *) MemExpr.get();
Expr *MemExpr) {
SourceLocation ExpectedLParenLoc = PP.getLocForEndOfToken(NameLoc);
Diag(E->getLocStart(), diag::err_dtor_expr_without_call)
<< isa<CXXPseudoDestructorExpr>(E)
Diag(MemExpr->getLocStart(), diag::err_dtor_expr_without_call)
<< isa<CXXPseudoDestructorExpr>(MemExpr)
<< FixItHint::CreateInsertion(ExpectedLParenLoc, "()");
return ActOnCallExpr(/*Scope*/ 0,
move(MemExpr),
MemExpr,
/*LPLoc*/ ExpectedLParenLoc,
Sema::MultiExprArg(*this, 0, 0),
/*CommaLocs*/ 0,
/*RPLoc*/ ExpectedLParenLoc);
}
Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base,
Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
const CXXScopeSpec &SS,
@ -2810,12 +2791,11 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base,
// The left-hand side of the dot operator shall be of scalar type. The
// left-hand side of the arrow operator shall be of pointer to scalar type.
// This scalar type is the object type.
Expr *BaseE = (Expr *)Base.get();
QualType ObjectType = BaseE->getType();
QualType ObjectType = Base->getType();
if (OpKind == tok::arrow) {
if (const PointerType *Ptr = ObjectType->getAs<PointerType>()) {
ObjectType = Ptr->getPointeeType();
} else if (!BaseE->isTypeDependent()) {
} else if (!Base->isTypeDependent()) {
// The user wrote "p->" when she probably meant "p."; fix it.
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
<< ObjectType << true
@ -2829,7 +2809,7 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base,
if (!ObjectType->isDependentType() && !ObjectType->isScalarType()) {
Diag(OpLoc, diag::err_pseudo_dtor_base_not_scalar)
<< ObjectType << BaseE->getSourceRange();
<< ObjectType << Base->getSourceRange();
return ExprError();
}
@ -2843,7 +2823,7 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base,
if (!DestructedType->isDependentType() && !ObjectType->isDependentType() &&
!Context.hasSameUnqualifiedType(DestructedType, ObjectType)) {
Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
<< ObjectType << DestructedType << BaseE->getSourceRange()
<< ObjectType << DestructedType << Base->getSourceRange()
<< DestructedTypeInfo->getTypeLoc().getLocalSourceRange();
// Recover by setting the destructed type to the object type.
@ -2868,7 +2848,7 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base,
Diag(ScopeTypeInfo->getTypeLoc().getLocalSourceRange().getBegin(),
diag::err_pseudo_dtor_type_mismatch)
<< ObjectType << ScopeType << BaseE->getSourceRange()
<< ObjectType << ScopeType << Base->getSourceRange()
<< ScopeTypeInfo->getTypeLoc().getLocalSourceRange();
ScopeType = QualType();
@ -2876,25 +2856,22 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base,
}
}
OwningExprResult Result
= Owned(new (Context) CXXPseudoDestructorExpr(Context,
Base.takeAs<Expr>(),
OpKind == tok::arrow,
OpLoc,
(NestedNameSpecifier *) SS.getScopeRep(),
SS.getRange(),
ScopeTypeInfo,
CCLoc,
TildeLoc,
Destructed));
Expr *Result
= new (Context) CXXPseudoDestructorExpr(Context, Base,
OpKind == tok::arrow, OpLoc,
SS.getScopeRep(), SS.getRange(),
ScopeTypeInfo,
CCLoc,
TildeLoc,
Destructed);
if (HasTrailingLParen)
return move(Result);
return Owned(Result);
return DiagnoseDtorReference(Destructed.getLocation(), move(Result));
return DiagnoseDtorReference(Destructed.getLocation(), Result);
}
Sema::OwningExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
Sema::OwningExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, Expr *Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
CXXScopeSpec &SS,
@ -2910,13 +2887,11 @@ Sema::OwningExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
SecondTypeName.getKind() == UnqualifiedId::IK_Identifier) &&
"Invalid second type name in pseudo-destructor");
Expr *BaseE = (Expr *)Base.get();
// C++ [expr.pseudo]p2:
// The left-hand side of the dot operator shall be of scalar type. The
// left-hand side of the arrow operator shall be of pointer to scalar type.
// This scalar type is the object type.
QualType ObjectType = BaseE->getType();
QualType ObjectType = Base->getType();
if (OpKind == tok::arrow) {
if (const PointerType *Ptr = ObjectType->getAs<PointerType>()) {
ObjectType = Ptr->getPointeeType();
@ -3043,7 +3018,7 @@ Sema::OwningExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
FirstTypeName.StartLocation);
return BuildPseudoDestructorExpr(move(Base), OpLoc, OpKind, SS,
return BuildPseudoDestructorExpr(Base, OpLoc, OpKind, SS,
ScopeTypeInfo, CCLoc, TildeLoc,
Destructed, HasTrailingLParen);
}
@ -3066,12 +3041,7 @@ CXXMemberCallExpr *Sema::BuildCXXMemberCallExpr(Expr *Exp,
return CE;
}
Sema::OwningExprResult Sema::ActOnFinishFullExpr(ExprArg Arg) {
Expr *FullExpr = Arg.takeAs<Expr>();
if (FullExpr)
FullExpr = MaybeCreateCXXExprWithTemporaries(FullExpr);
else
return ExprError();
return Owned(FullExpr);
Sema::OwningExprResult Sema::ActOnFinishFullExpr(Expr *FullExpr) {
if (!FullExpr) return ExprError();
return MaybeCreateCXXExprWithTemporaries(FullExpr);
}

View File

@ -659,7 +659,7 @@ Sema::OwningExprResult Sema::ActOnSuperMessage(Scope *S,
// message to the superclass instance.
QualType SuperTy = Context.getObjCInterfaceType(Super);
SuperTy = Context.getObjCObjectPointerType(SuperTy);
return BuildInstanceMessage(ExprArg(*this), SuperTy, SuperLoc,
return BuildInstanceMessage(0, SuperTy, SuperLoc,
Sel, /*Method=*/0, LBracLoc, RBracLoc,
move(Args));
}
@ -828,7 +828,7 @@ Sema::OwningExprResult Sema::ActOnClassMessage(Scope *S,
/// \param RBrac The location of the closing square bracket ']'.
///
/// \param Args The message arguments.
Sema::OwningExprResult Sema::BuildInstanceMessage(ExprArg ReceiverE,
Sema::OwningExprResult Sema::BuildInstanceMessage(Expr *Receiver,
QualType ReceiverType,
SourceLocation SuperLoc,
Selector Sel,
@ -838,7 +838,6 @@ Sema::OwningExprResult Sema::BuildInstanceMessage(ExprArg ReceiverE,
MultiExprArg ArgsIn) {
// If we have a receiver expression, perform appropriate promotions
// and determine receiver type.
Expr *Receiver = ReceiverE.takeAs<Expr>();
if (Receiver) {
if (Receiver->isTypeDependent()) {
// If the receiver is type-dependent, we can't type-check anything
@ -986,7 +985,7 @@ Sema::OwningExprResult Sema::BuildInstanceMessage(ExprArg ReceiverE,
Receiver = ICE->getSubExpr();
ReceiverType = Receiver->getType();
}
return BuildInstanceMessage(Owned(Receiver),
return BuildInstanceMessage(Receiver,
ReceiverType,
SuperLoc,
Sel,
@ -1034,17 +1033,16 @@ Sema::OwningExprResult Sema::BuildInstanceMessage(ExprArg ReceiverE,
// ArgExprs is optional - if it is present, the number of expressions
// is obtained from Sel.getNumArgs().
Sema::OwningExprResult Sema::ActOnInstanceMessage(Scope *S,
ExprArg ReceiverE,
Expr *Receiver,
Selector Sel,
SourceLocation LBracLoc,
SourceLocation SelectorLoc,
SourceLocation RBracLoc,
MultiExprArg Args) {
Expr *Receiver = static_cast<Expr *>(ReceiverE.get());
if (!Receiver)
return ExprError();
return BuildInstanceMessage(move(ReceiverE), Receiver->getType(),
return BuildInstanceMessage(Receiver, Receiver->getType(),
/*SuperLoc=*/SourceLocation(), Sel, /*Method=*/0,
LBracLoc, RBracLoc, move(Args));
}

View File

@ -3192,7 +3192,7 @@ bool Sema::PerformContextuallyConvertToObjCId(Expr *&From) {
/// \returns The expression, converted to an integral or enumeration type if
/// successful.
Sema::OwningExprResult
Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From,
const PartialDiagnostic &NotIntDiag,
const PartialDiagnostic &IncompleteDiag,
const PartialDiagnostic &ExplicitConvDiag,
@ -3200,16 +3200,14 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
const PartialDiagnostic &AmbigDiag,
const PartialDiagnostic &AmbigNote,
const PartialDiagnostic &ConvDiag) {
Expr *From = static_cast<Expr *>(FromE.get());
// We can't perform any more checking for type-dependent expressions.
if (From->isTypeDependent())
return move(FromE);
return Owned(From);
// If the expression already has integral or enumeration type, we're golden.
QualType T = From->getType();
if (T->isIntegralOrEnumerationType())
return move(FromE);
return Owned(From);
// FIXME: Check for missing '()' if T is a function type?
@ -3219,12 +3217,12 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
if (!RecordTy || !getLangOptions().CPlusPlus) {
Diag(Loc, NotIntDiag)
<< T << From->getSourceRange();
return move(FromE);
return Owned(From);
}
// We must have a complete class type.
if (RequireCompleteType(Loc, T, IncompleteDiag))
return move(FromE);
return Owned(From);
// Look for a conversion to an integral or enumeration type.
UnresolvedSet<4> ViableConversions;
@ -3276,8 +3274,7 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
return ExprError();
CheckMemberOperatorAccess(From->getExprLoc(), From, 0, Found);
From = BuildCXXMemberCallExpr(FromE.takeAs<Expr>(), Found, Conversion);
FromE = Owned(From);
From = BuildCXXMemberCallExpr(From, Found, Conversion);
}
// We'll complain below about a non-integral condition type.
@ -3300,9 +3297,8 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
<< T << ConvTy->isEnumeralType() << ConvTy << From->getSourceRange();
}
From = BuildCXXMemberCallExpr(FromE.takeAs<Expr>(), Found,
From = BuildCXXMemberCallExpr(From, Found,
cast<CXXConversionDecl>(Found->getUnderlyingDecl()));
FromE = Owned(From);
break;
}
@ -3316,14 +3312,14 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
Diag(Conv->getLocation(), AmbigNote)
<< ConvTy->isEnumeralType() << ConvTy;
}
return move(FromE);
return Owned(From);
}
if (!From->getType()->isIntegralOrEnumerationType())
Diag(Loc, NotIntDiag)
<< From->getType() << From->getSourceRange();
return move(FromE);
return Owned(From);
}
/// AddOverloadCandidate - Adds the given function to the set of
@ -6553,7 +6549,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
// This shouldn't cause an infinite loop because we're giving it
// an expression with non-empty lookup results, which should never
// end up here.
return SemaRef.ActOnCallExpr(/*Scope*/ 0, move(NewFn), LParenLoc,
return SemaRef.ActOnCallExpr(/*Scope*/ 0, NewFn.take(), LParenLoc,
Sema::MultiExprArg(SemaRef, Args, NumArgs),
CommaLocs, RParenLoc);
}
@ -6662,9 +6658,8 @@ static bool IsOverloaded(const UnresolvedSetImpl &Functions) {
Sema::OwningExprResult
Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
const UnresolvedSetImpl &Fns,
ExprArg input) {
Expr *Input) {
UnaryOperator::Opcode Opc = static_cast<UnaryOperator::Opcode>(OpcIn);
Expr *Input = (Expr *)input.get();
OverloadedOperatorKind Op = UnaryOperator::getOverloadedOperator(Opc);
assert(Op != OO_None && "Invalid opcode for overloaded unary operator");
@ -6687,7 +6682,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
if (Input->isTypeDependent()) {
if (Fns.empty())
return Owned(new (Context) UnaryOperator(input.takeAs<Expr>(),
return Owned(new (Context) UnaryOperator(Input,
Opc,
Context.DependentTy,
OpLoc));
@ -6698,7 +6693,6 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
0, SourceRange(), OpNameInfo,
/*ADL*/ true, IsOverloaded(Fns),
Fns.begin(), Fns.end());
input.release();
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn,
&Args[0], NumArgs,
Context.DependentTy,
@ -6747,12 +6741,10 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
= PerformCopyInitialization(InitializedEntity::InitializeParameter(
FnDecl->getParamDecl(0)),
SourceLocation(),
move(input));
Input);
if (InputInit.isInvalid())
return ExprError();
input = move(InputInit);
Input = (Expr *)input.get();
Input = InputInit.take();
}
DiagnoseUseOfDecl(Best->FoundDecl, OpLoc);
@ -6765,17 +6757,16 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
SourceLocation());
UsualUnaryConversions(FnExpr);
input.release();
Args[0] = Input;
ExprOwningPtr<CallExpr> TheCall(this,
CallExpr *TheCall =
new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
Args, NumArgs, ResultTy, OpLoc));
Args, NumArgs, ResultTy, OpLoc);
if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall.get(),
if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall,
FnDecl))
return ExprError();
return MaybeBindToTemporary(TheCall.release());
return MaybeBindToTemporary(TheCall);
} else {
// We matched a built-in operator. Convert the arguments, then
// break out so that we will build the appropriate built-in
@ -6813,8 +6804,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
// Either we found no viable overloaded operator or we matched a
// built-in operator. In either case, fall through to trying to
// build a built-in operation.
input.release();
return CreateBuiltinUnaryOp(OpLoc, Opc, Owned(Input));
return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
}
/// \brief Create a binary operation that may resolve to an overloaded
@ -6975,16 +6965,15 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
OpLoc);
UsualUnaryConversions(FnExpr);
ExprOwningPtr<CXXOperatorCallExpr>
TheCall(this, new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
Args, 2, ResultTy,
OpLoc));
CXXOperatorCallExpr *TheCall =
new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
Args, 2, ResultTy, OpLoc);
if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall.get(),
if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall,
FnDecl))
return ExprError();
return MaybeBindToTemporary(TheCall.release());
return MaybeBindToTemporary(TheCall);
} else {
// We matched a built-in operator. Convert the arguments, then
// break out so that we will build the appropriate built-in
@ -7053,9 +7042,8 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
Action::OwningExprResult
Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
SourceLocation RLoc,
ExprArg Base, ExprArg Idx) {
Expr *Args[2] = { static_cast<Expr*>(Base.get()),
static_cast<Expr*>(Idx.get()) };
Expr *Base, Expr *Idx) {
Expr *Args[2] = { Base, Idx };
DeclarationName OpName =
Context.DeclarationNames.getCXXOperatorName(OO_Subscript);
@ -7075,8 +7063,6 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
UnresolvedSetIterator());
// Can't add any actual overloads yet
Base.release();
Idx.release();
return Owned(new (Context) CXXOperatorCallExpr(Context, OO_Subscript, Fn,
Args, 2,
Context.DependentTy,
@ -7135,18 +7121,16 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
LLoc);
UsualUnaryConversions(FnExpr);
Base.release();
Idx.release();
ExprOwningPtr<CXXOperatorCallExpr>
TheCall(this, new (Context) CXXOperatorCallExpr(Context, OO_Subscript,
FnExpr, Args, 2,
ResultTy, RLoc));
CXXOperatorCallExpr *TheCall =
new (Context) CXXOperatorCallExpr(Context, OO_Subscript,
FnExpr, Args, 2,
ResultTy, RLoc);
if (CheckCallReturnType(FnDecl->getResultType(), LLoc, TheCall.get(),
if (CheckCallReturnType(FnDecl->getResultType(), LLoc, TheCall,
FnDecl))
return ExprError();
return MaybeBindToTemporary(TheCall.release());
return MaybeBindToTemporary(TheCall);
} else {
// We matched a built-in operator. Convert the arguments, then
// break out so that we will build the appropriate built-in
@ -7192,10 +7176,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
}
// We matched a built-in operator; build it.
Base.release();
Idx.release();
return CreateBuiltinArraySubscriptExpr(Owned(Args[0]), LLoc,
Owned(Args[1]), RLoc);
return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
}
/// BuildCallToMemberFunction - Build a call to a member
@ -7313,15 +7294,14 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
}
assert(Method && "Member call to something that isn't a method?");
ExprOwningPtr<CXXMemberCallExpr>
TheCall(this, new (Context) CXXMemberCallExpr(Context, MemExprE, Args,
NumArgs,
Method->getCallResultType(),
RParenLoc));
CXXMemberCallExpr *TheCall =
new (Context) CXXMemberCallExpr(Context, MemExprE, Args, NumArgs,
Method->getCallResultType(),
RParenLoc);
// Check for a valid return type.
if (CheckCallReturnType(Method->getResultType(), MemExpr->getMemberLoc(),
TheCall.get(), Method))
TheCall, Method))
return ExprError();
// Convert the object argument (for a non-static member function call).
@ -7336,14 +7316,14 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
// Convert the rest of the arguments
const FunctionProtoType *Proto = Method->getType()->getAs<FunctionProtoType>();
if (ConvertArgumentsForCall(&*TheCall, MemExpr, Method, Proto, Args, NumArgs,
if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args, NumArgs,
RParenLoc))
return ExprError();
if (CheckFunctionCall(Method, TheCall.get()))
if (CheckFunctionCall(Method, TheCall))
return ExprError();
return MaybeBindToTemporary(TheCall.release());
return MaybeBindToTemporary(TheCall);
}
/// BuildCallToObjectOfClassType - Build a call to an object of class
@ -7488,7 +7468,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
CXXMemberCallExpr *CE = BuildCXXMemberCallExpr(Object, Best->FoundDecl,
Conv);
return ActOnCallExpr(S, ExprArg(*this, CE), LParenLoc,
return ActOnCallExpr(S, CE, LParenLoc,
MultiExprArg(*this, (ExprTy**)Args, NumArgs),
CommaLocs, RParenLoc).result();
}
@ -7526,13 +7506,13 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
// Once we've built TheCall, all of the expressions are properly
// owned.
QualType ResultTy = Method->getCallResultType();
ExprOwningPtr<CXXOperatorCallExpr>
TheCall(this, new (Context) CXXOperatorCallExpr(Context, OO_Call, NewFn,
MethodArgs, NumArgs + 1,
ResultTy, RParenLoc));
CXXOperatorCallExpr *TheCall =
new (Context) CXXOperatorCallExpr(Context, OO_Call, NewFn,
MethodArgs, NumArgs + 1,
ResultTy, RParenLoc);
delete [] MethodArgs;
if (CheckCallReturnType(Method->getResultType(), LParenLoc, TheCall.get(),
if (CheckCallReturnType(Method->getResultType(), LParenLoc, TheCall,
Method))
return true;
@ -7562,7 +7542,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
OwningExprResult InputInit
= PerformCopyInitialization(InitializedEntity::InitializeParameter(
Method->getParamDecl(i)),
SourceLocation(), Owned(Arg));
SourceLocation(), Arg);
IsError |= InputInit.isInvalid();
Arg = InputInit.takeAs<Expr>();
@ -7592,18 +7572,17 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
if (IsError) return true;
if (CheckFunctionCall(Method, TheCall.get()))
if (CheckFunctionCall(Method, TheCall))
return true;
return MaybeBindToTemporary(TheCall.release()).result();
return MaybeBindToTemporary(TheCall).result();
}
/// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
/// (if one exists), where @c Base is an expression of class type and
/// @c Member is the name of the member we're trying to find.
Sema::OwningExprResult
Sema::BuildOverloadedArrowExpr(Scope *S, ExprArg BaseIn, SourceLocation OpLoc) {
Expr *Base = static_cast<Expr *>(BaseIn.get());
Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc) {
assert(Base->getType()->isRecordType() && "left-hand side must have class type");
SourceLocation Loc = Base->getExprLoc();
@ -7673,23 +7652,20 @@ Sema::BuildOverloadedArrowExpr(Scope *S, ExprArg BaseIn, SourceLocation OpLoc) {
Best->FoundDecl, Method))
return ExprError();
// No concerns about early exits now.
BaseIn.release();
// Build the operator call.
Expr *FnExpr = new (Context) DeclRefExpr(Method, Method->getType(),
SourceLocation());
UsualUnaryConversions(FnExpr);
QualType ResultTy = Method->getCallResultType();
ExprOwningPtr<CXXOperatorCallExpr>
TheCall(this, new (Context) CXXOperatorCallExpr(Context, OO_Arrow, FnExpr,
&Base, 1, ResultTy, OpLoc));
CXXOperatorCallExpr *TheCall =
new (Context) CXXOperatorCallExpr(Context, OO_Arrow, FnExpr,
&Base, 1, ResultTy, OpLoc);
if (CheckCallReturnType(Method->getResultType(), OpLoc, TheCall.get(),
if (CheckCallReturnType(Method->getResultType(), OpLoc, TheCall,
Method))
return ExprError();
return move(TheCall);
return Owned(TheCall);
}
/// FixOverloadedFunctionReference - E is an expression that refers to

View File

@ -28,7 +28,7 @@
using namespace clang;
Sema::OwningStmtResult Sema::ActOnExprStmt(FullExprArg expr) {
Expr *E = expr->takeAs<Expr>();
Expr *E = expr.get();
assert(E && "ActOnExprStmt(): missing expression");
// C99 6.8.3p2: The expression in an expression statement is evaluated as a
// void expression for its side effects. Conversion to void allows any
@ -171,25 +171,22 @@ Sema::ActOnCompoundStmt(SourceLocation L, SourceLocation R,
}
Action::OwningStmtResult
Sema::ActOnCaseStmt(SourceLocation CaseLoc, ExprArg lhsval,
SourceLocation DotDotDotLoc, ExprArg rhsval,
Sema::ActOnCaseStmt(SourceLocation CaseLoc, Expr *LHSVal,
SourceLocation DotDotDotLoc, Expr *RHSVal,
SourceLocation ColonLoc) {
assert((lhsval.get() != 0) && "missing expression in case statement");
assert((LHSVal != 0) && "missing expression in case statement");
// C99 6.8.4.2p3: The expression shall be an integer constant.
// However, GCC allows any evaluatable integer expression.
Expr *LHSVal = static_cast<Expr*>(lhsval.get());
if (!LHSVal->isTypeDependent() && !LHSVal->isValueDependent() &&
VerifyIntegerConstantExpression(LHSVal))
return StmtError();
// GCC extension: The expression shall be an integer constant.
Expr *RHSVal = static_cast<Expr*>(rhsval.get());
if (RHSVal && !RHSVal->isTypeDependent() && !RHSVal->isValueDependent() &&
VerifyIntegerConstantExpression(RHSVal)) {
RHSVal = 0; // Recover by just forgetting about it.
rhsval = 0;
}
if (getSwitchStack().empty()) {
@ -197,9 +194,6 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, ExprArg lhsval,
return StmtError();
}
// Only now release the smart pointers.
lhsval.release();
rhsval.release();
CaseStmt *CS = new (Context) CaseStmt(LHSVal, RHSVal, CaseLoc, DotDotDotLoc,
ColonLoc);
getSwitchStack().back()->addSwitchCase(CS);
@ -207,17 +201,14 @@ Sema::ActOnCaseStmt(SourceLocation CaseLoc, ExprArg lhsval,
}
/// ActOnCaseStmtBody - This installs a statement as the body of a case.
void Sema::ActOnCaseStmtBody(StmtTy *caseStmt, StmtArg subStmt) {
void Sema::ActOnCaseStmtBody(Stmt *caseStmt, Stmt *SubStmt) {
CaseStmt *CS = static_cast<CaseStmt*>(caseStmt);
Stmt *SubStmt = subStmt.takeAs<Stmt>();
CS->setSubStmt(SubStmt);
}
Action::OwningStmtResult
Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc,
StmtArg subStmt, Scope *CurScope) {
Stmt *SubStmt = subStmt.takeAs<Stmt>();
Stmt *SubStmt, Scope *CurScope) {
if (getSwitchStack().empty()) {
Diag(DefaultLoc, diag::err_default_not_in_switch);
return Owned(SubStmt);
@ -230,8 +221,7 @@ Sema::ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc,
Action::OwningStmtResult
Sema::ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
SourceLocation ColonLoc, StmtArg subStmt) {
Stmt *SubStmt = subStmt.takeAs<Stmt>();
SourceLocation ColonLoc, Stmt *SubStmt) {
// Look up the record for this label identifier.
LabelStmt *&LabelDecl = getLabelMap()[II];
@ -258,8 +248,8 @@ Sema::ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
Action::OwningStmtResult
Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar,
StmtArg ThenVal, SourceLocation ElseLoc,
StmtArg ElseVal) {
Stmt *thenStmt, SourceLocation ElseLoc,
Stmt *elseStmt) {
OwningExprResult CondResult(CondVal.release());
VarDecl *ConditionVar = 0;
@ -273,22 +263,19 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal, Decl *CondVar,
if (!ConditionExpr)
return StmtError();
Stmt *thenStmt = ThenVal.takeAs<Stmt>();
DiagnoseUnusedExprResult(thenStmt);
// Warn if the if block has a null body without an else value.
// this helps prevent bugs due to typos, such as
// if (condition);
// do_stuff();
if (!ElseVal.get()) {
if (!elseStmt) {
if (NullStmt* stmt = dyn_cast<NullStmt>(thenStmt))
Diag(stmt->getSemiLoc(), diag::warn_empty_if_body);
}
Stmt *elseStmt = ElseVal.takeAs<Stmt>();
DiagnoseUnusedExprResult(elseStmt);
CondResult.release();
return Owned(new (Context) IfStmt(Context, IfLoc, ConditionVar, ConditionExpr,
thenStmt, ElseLoc, elseStmt));
}
@ -396,57 +383,55 @@ static QualType GetTypeBeforeIntegralPromotion(const Expr* expr) {
}
Action::OwningStmtResult
Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, ExprArg Cond,
Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond,
Decl *CondVar) {
OwningExprResult CondResult;
VarDecl *ConditionVar = 0;
if (CondVar) {
ConditionVar = cast<VarDecl>(CondVar);
OwningExprResult CondE = CheckConditionVariable(ConditionVar, SourceLocation(), false);
if (CondE.isInvalid())
CondResult = CheckConditionVariable(ConditionVar, SourceLocation(), false);
if (CondResult.isInvalid())
return StmtError();
Cond = move(CondE);
Cond = CondResult.release();
}
if (!Cond.get())
if (!Cond)
return StmtError();
Expr *CondExpr = static_cast<Expr *>(Cond.get());
OwningExprResult ConvertedCond
= ConvertToIntegralOrEnumerationType(SwitchLoc, move(Cond),
CondResult
= ConvertToIntegralOrEnumerationType(SwitchLoc, Cond,
PDiag(diag::err_typecheck_statement_requires_integer),
PDiag(diag::err_switch_incomplete_class_type)
<< CondExpr->getSourceRange(),
<< Cond->getSourceRange(),
PDiag(diag::err_switch_explicit_conversion),
PDiag(diag::note_switch_conversion),
PDiag(diag::err_switch_multiple_conversions),
PDiag(diag::note_switch_conversion),
PDiag(0));
if (ConvertedCond.isInvalid())
return StmtError();
CondExpr = ConvertedCond.takeAs<Expr>();
if (CondResult.isInvalid()) return StmtError();
Cond = CondResult.take();
if (!CondVar) {
CondExpr = MaybeCreateCXXExprWithTemporaries(CondExpr);
if (!CondExpr)
CondResult = MaybeCreateCXXExprWithTemporaries(Cond);
if (CondResult.isInvalid())
return StmtError();
Cond = CondResult.take();
}
setFunctionHasBranchIntoScope();
SwitchStmt *SS = new (Context) SwitchStmt(Context, ConditionVar, CondExpr);
SwitchStmt *SS = new (Context) SwitchStmt(Context, ConditionVar, Cond);
getSwitchStack().push_back(SS);
return Owned(SS);
}
Action::OwningStmtResult
Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
StmtArg Body) {
Stmt *BodyStmt = Body.takeAs<Stmt>();
SwitchStmt *SS = getSwitchStack().back();
assert(SS == (SwitchStmt*)Switch.get() && "switch stack missing push/pop!");
Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
Stmt *BodyStmt) {
SwitchStmt *SS = cast<SwitchStmt>(Switch);
assert(SS == getSwitchStack().back() && "switch stack missing push/pop!");
SS->setBody(BodyStmt, SwitchLoc);
getSwitchStack().pop_back();
@ -795,13 +780,12 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch,
if (CaseListIsErroneous)
return StmtError();
Switch.release();
return Owned(SS);
}
Action::OwningStmtResult
Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond,
Decl *CondVar, StmtArg Body) {
Decl *CondVar, Stmt *Body) {
OwningExprResult CondResult(Cond.release());
VarDecl *ConditionVar = 0;
@ -811,49 +795,40 @@ Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond,
if (CondResult.isInvalid())
return StmtError();
}
Expr *ConditionExpr = CondResult.takeAs<Expr>();
Expr *ConditionExpr = CondResult.take();
if (!ConditionExpr)
return StmtError();
Stmt *bodyStmt = Body.takeAs<Stmt>();
DiagnoseUnusedExprResult(bodyStmt);
DiagnoseUnusedExprResult(Body);
CondResult.release();
return Owned(new (Context) WhileStmt(Context, ConditionVar, ConditionExpr,
bodyStmt, WhileLoc));
Body, WhileLoc));
}
Action::OwningStmtResult
Sema::ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
Sema::ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
SourceLocation WhileLoc, SourceLocation CondLParen,
ExprArg Cond, SourceLocation CondRParen) {
Expr *condExpr = Cond.takeAs<Expr>();
assert(condExpr && "ActOnDoStmt(): missing expression");
Expr *Cond, SourceLocation CondRParen) {
assert(Cond && "ActOnDoStmt(): missing expression");
if (CheckBooleanCondition(condExpr, DoLoc)) {
Cond = condExpr;
if (CheckBooleanCondition(Cond, DoLoc))
return StmtError();
}
condExpr = MaybeCreateCXXExprWithTemporaries(condExpr);
if (!condExpr)
OwningExprResult CondResult = MaybeCreateCXXExprWithTemporaries(Cond);
if (CondResult.isInvalid())
return StmtError();
Cond = CondResult.take();
Stmt *bodyStmt = Body.takeAs<Stmt>();
DiagnoseUnusedExprResult(bodyStmt);
DiagnoseUnusedExprResult(Body);
Cond.release();
return Owned(new (Context) DoStmt(bodyStmt, condExpr, DoLoc,
WhileLoc, CondRParen));
return Owned(new (Context) DoStmt(Body, Cond, DoLoc, WhileLoc, CondRParen));
}
Action::OwningStmtResult
Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
StmtArg first, FullExprArg second, Decl *secondVar,
Stmt *First, FullExprArg second, Decl *secondVar,
FullExprArg third,
SourceLocation RParenLoc, StmtArg body) {
Stmt *First = static_cast<Stmt*>(first.get());
SourceLocation RParenLoc, Stmt *Body) {
if (!getLangOptions().CPlusPlus) {
if (DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
// C99 6.8.5p3: The declaration part of a 'for' statement shall only
@ -881,16 +856,13 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
}
Expr *Third = third.release().takeAs<Expr>();
Stmt *Body = static_cast<Stmt*>(body.get());
DiagnoseUnusedExprResult(First);
DiagnoseUnusedExprResult(Third);
DiagnoseUnusedExprResult(Body);
first.release();
body.release();
return Owned(new (Context) ForStmt(Context, First,
SecondResult.takeAs<Expr>(), ConditionVar,
SecondResult.take(), ConditionVar,
Third, Body, ForLoc, LParenLoc,
RParenLoc));
}
@ -898,11 +870,8 @@ Sema::ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
Action::OwningStmtResult
Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
SourceLocation LParenLoc,
StmtArg first, ExprArg second,
SourceLocation RParenLoc, StmtArg body) {
Stmt *First = static_cast<Stmt*>(first.get());
Expr *Second = static_cast<Expr*>(second.get());
Stmt *Body = static_cast<Stmt*>(body.get());
Stmt *First, Expr *Second,
SourceLocation RParenLoc, Stmt *Body) {
if (First) {
QualType FirstType;
if (DeclStmt *DS = dyn_cast<DeclStmt>(First)) {
@ -963,9 +932,6 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
}
}
}
first.release();
second.release();
body.release();
return Owned(new (Context) ObjCForCollectionStmt(First, Second, Body,
ForLoc, RParenLoc));
}
@ -987,9 +953,8 @@ Sema::ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
Action::OwningStmtResult
Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc,
ExprArg DestExp) {
Expr *E) {
// Convert operand to void*
Expr* E = DestExp.takeAs<Expr>();
if (!E->isTypeDependent()) {
QualType ETy = E->getType();
QualType DestTy = Context.getPointerType(Context.VoidTy.withConst());
@ -1153,8 +1118,7 @@ Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
}
Action::OwningStmtResult
Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprArg rex) {
Expr *RetValExp = rex.takeAs<Expr>();
Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
if (getCurBlock())
return ActOnBlockReturnStmt(ReturnLoc, RetValExp);
@ -1285,15 +1249,15 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
IdentifierInfo **Names,
MultiExprArg constraints,
MultiExprArg exprs,
ExprArg asmString,
Expr *asmString,
MultiExprArg clobbers,
SourceLocation RParenLoc,
bool MSAsm) {
unsigned NumClobbers = clobbers.size();
StringLiteral **Constraints =
reinterpret_cast<StringLiteral**>(constraints.get());
Expr **Exprs = reinterpret_cast<Expr **>(exprs.get());
StringLiteral *AsmString = cast<StringLiteral>((Expr *)asmString.get());
Expr **Exprs = exprs.get();
StringLiteral *AsmString = cast<StringLiteral>(asmString);
StringLiteral **Clobbers = reinterpret_cast<StringLiteral**>(clobbers.get());
llvm::SmallVector<TargetInfo::ConstraintInfo, 4> OutputConstraintInfos;
@ -1389,10 +1353,6 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
diag::err_asm_unknown_register_name) << Clobber);
}
constraints.release();
exprs.release();
asmString.release();
clobbers.release();
AsmStmt *NS =
new (Context) AsmStmt(Context, AsmLoc, IsSimple, IsVolatile, MSAsm,
NumOutputs, NumInputs, Names, Constraints, Exprs,
@ -1505,35 +1465,32 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
Action::OwningStmtResult
Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
SourceLocation RParen, Decl *Parm,
StmtArg Body) {
Stmt *Body) {
VarDecl *Var = cast_or_null<VarDecl>(Parm);
if (Var && Var->isInvalidDecl())
return StmtError();
return Owned(new (Context) ObjCAtCatchStmt(AtLoc, RParen, Var,
Body.takeAs<Stmt>()));
return Owned(new (Context) ObjCAtCatchStmt(AtLoc, RParen, Var, Body));
}
Action::OwningStmtResult
Sema::ActOnObjCAtFinallyStmt(SourceLocation AtLoc, StmtArg Body) {
return Owned(new (Context) ObjCAtFinallyStmt(AtLoc,
static_cast<Stmt*>(Body.release())));
Sema::ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body) {
return Owned(new (Context) ObjCAtFinallyStmt(AtLoc, Body));
}
Action::OwningStmtResult
Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, StmtArg Try,
MultiStmtArg CatchStmts, StmtArg Finally) {
Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try,
MultiStmtArg CatchStmts, Stmt *Finally) {
setFunctionHasBranchProtectedScope();
unsigned NumCatchStmts = CatchStmts.size();
return Owned(ObjCAtTryStmt::Create(Context, AtLoc, Try.takeAs<Stmt>(),
(Stmt **)CatchStmts.release(),
return Owned(ObjCAtTryStmt::Create(Context, AtLoc, Try,
CatchStmts.release(),
NumCatchStmts,
Finally.takeAs<Stmt>()));
Finally));
}
Sema::OwningStmtResult Sema::BuildObjCAtThrowStmt(SourceLocation AtLoc,
ExprArg ThrowE) {
Expr *Throw = static_cast<Expr *>(ThrowE.get());
Expr *Throw) {
if (Throw) {
QualType ThrowType = Throw->getType();
// Make sure the expression type is an ObjC pointer or "void *".
@ -1546,13 +1503,13 @@ Sema::OwningStmtResult Sema::BuildObjCAtThrowStmt(SourceLocation AtLoc,
}
}
return Owned(new (Context) ObjCAtThrowStmt(AtLoc, ThrowE.takeAs<Expr>()));
return Owned(new (Context) ObjCAtThrowStmt(AtLoc, Throw));
}
Action::OwningStmtResult
Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg Throw,
Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw,
Scope *CurScope) {
if (!Throw.get()) {
if (!Throw) {
// @throw without an expression designates a rethrow (which much occur
// in the context of an @catch clause).
Scope *AtCatchParent = CurScope;
@ -1562,16 +1519,15 @@ Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg Throw,
return StmtError(Diag(AtLoc, diag::error_rethrow_used_outside_catch));
}
return BuildObjCAtThrowStmt(AtLoc, move(Throw));
return BuildObjCAtThrowStmt(AtLoc, Throw);
}
Action::OwningStmtResult
Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprArg SynchExpr,
StmtArg SynchBody) {
Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SyncExpr,
Stmt *SyncBody) {
setFunctionHasBranchProtectedScope();
// Make sure the expression type is an ObjC pointer or "void *".
Expr *SyncExpr = static_cast<Expr*>(SynchExpr.get());
if (!SyncExpr->getType()->isDependentType() &&
!SyncExpr->getType()->isObjCObjectPointerType()) {
const PointerType *PT = SyncExpr->getType()->getAs<PointerType>();
@ -1580,20 +1536,18 @@ Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprArg SynchExpr,
<< SyncExpr->getType() << SyncExpr->getSourceRange());
}
return Owned(new (Context) ObjCAtSynchronizedStmt(AtLoc,
SynchExpr.takeAs<Stmt>(),
SynchBody.takeAs<Stmt>()));
return Owned(new (Context) ObjCAtSynchronizedStmt(AtLoc, SyncExpr, SyncBody));
}
/// ActOnCXXCatchBlock - Takes an exception declaration and a handler block
/// and creates a proper catch handler from them.
Action::OwningStmtResult
Sema::ActOnCXXCatchBlock(SourceLocation CatchLoc, Decl *ExDecl,
StmtArg HandlerBlock) {
Stmt *HandlerBlock) {
// There's nothing to test that ActOnExceptionDecl didn't already test.
return Owned(new (Context) CXXCatchStmt(CatchLoc,
cast_or_null<VarDecl>(ExDecl),
HandlerBlock.takeAs<Stmt>()));
HandlerBlock));
}
namespace {
@ -1632,12 +1586,12 @@ public:
/// ActOnCXXTryBlock - Takes a try compound-statement and a number of
/// handlers and creates a try statement from them.
Action::OwningStmtResult
Sema::ActOnCXXTryBlock(SourceLocation TryLoc, StmtArg TryBlock,
Sema::ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
MultiStmtArg RawHandlers) {
unsigned NumHandlers = RawHandlers.size();
assert(NumHandlers > 0 &&
"The parser shouldn't call this if there are no handlers.");
Stmt **Handlers = reinterpret_cast<Stmt**>(RawHandlers.get());
Stmt **Handlers = RawHandlers.get();
llvm::SmallVector<TypeWithHandler, 8> TypesWithHandlers;
@ -1685,8 +1639,6 @@ Sema::ActOnCXXTryBlock(SourceLocation TryLoc, StmtArg TryBlock,
// Neither of these are explicitly forbidden, but every compiler detects them
// and warns.
RawHandlers.release();
return Owned(CXXTryStmt::Create(Context, TryLoc,
static_cast<Stmt*>(TryBlock.release()),
return Owned(CXXTryStmt::Create(Context, TryLoc, TryBlock,
Handlers, NumHandlers));
}

View File

@ -584,7 +584,7 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
unsigned Depth,
unsigned Position,
SourceLocation EqualLoc,
ExprArg DefaultArg) {
Expr *Default) {
TypeSourceInfo *TInfo = GetTypeForDeclarator(D, S);
QualType T = TInfo->getType();
@ -622,14 +622,14 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
}
// Check the well-formedness of the default template argument, if provided.
if (Expr *Default = static_cast<Expr *>(DefaultArg.get())) {
if (Default) {
TemplateArgument Converted;
if (CheckTemplateArgument(Param, Param->getType(), Default, Converted)) {
Param->setInvalidDecl();
return Param;
}
Param->setDefaultArgument(DefaultArg.takeAs<Expr>(), false);
Param->setDefaultArgument(Default, false);
}
return Param;
@ -3057,7 +3057,8 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
QualType ClassType
= Context.getTypeDeclType(cast<RecordDecl>(VD->getDeclContext()));
NestedNameSpecifier *Qualifier
= NestedNameSpecifier::Create(Context, 0, false, ClassType.getTypePtr());
= NestedNameSpecifier::Create(Context, 0, false,
ClassType.getTypePtr());
CXXScopeSpec SS;
SS.setScopeRep(Qualifier);
OwningExprResult RefExpr = BuildDeclRefExpr(VD,
@ -3067,7 +3068,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
if (RefExpr.isInvalid())
return ExprError();
RefExpr = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, move(RefExpr));
RefExpr = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, RefExpr.get());
// We might need to perform a trailing qualification conversion, since
// the element type on the parameter could be more qualified than the
@ -3108,7 +3109,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
}
// Take the address of everything else
return CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, move(RefExpr));
return CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, RefExpr.get());
}
// If the non-type template parameter has reference type, qualify the

View File

@ -433,10 +433,8 @@ Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
CommaLocs.data(),
RParenLoc);
} else if (InitArgs.size() == 1) {
Expr *Init = (Expr*)(InitArgs.take()[0]);
SemaRef.AddInitializerToDecl(Var,
SemaRef.Owned(Init),
false);
Expr *Init = InitArgs.take()[0];
SemaRef.AddInitializerToDecl(Var, Init, false);
} else {
assert(InitArgs.size() == 0);
SemaRef.ActOnUninitializedDecl(Var, false);
@ -594,8 +592,8 @@ Decl *TemplateDeclInstantiator::VisitStaticAssertDecl(StaticAssertDecl *D) {
OwningExprResult Message(D->getMessage());
D->getMessage()->Retain();
return SemaRef.ActOnStaticAssertDeclaration(D->getLocation(),
move(InstantiatedAssertExpr),
move(Message));
InstantiatedAssertExpr.get(),
Message.get());
}
Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
@ -638,7 +636,7 @@ Decl *TemplateDeclInstantiator::VisitEnumDecl(EnumDecl *D) {
EnumConstantDecl *EnumConst
= SemaRef.CheckEnumConstant(Enum, LastEnumConst,
EC->getLocation(), EC->getIdentifier(),
move(Value));
Value.get());
if (isInvalid) {
if (EnumConst)
@ -2113,7 +2111,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
if (Body.isInvalid())
Function->setInvalidDecl();
ActOnFinishFunctionBody(Function, move(Body),
ActOnFinishFunctionBody(Function, Body.get(),
/*IsInstantiation=*/true);
PerformDependentDiagnostics(PatternDecl, TemplateArgs);

View File

@ -750,11 +750,8 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
/// \brief Build an ext-vector type.
///
/// Run the required checks for the extended vector type.
QualType Sema::BuildExtVectorType(QualType T, ExprArg ArraySize,
QualType Sema::BuildExtVectorType(QualType T, Expr *ArraySize,
SourceLocation AttrLoc) {
Expr *Arg = (Expr *)ArraySize.get();
// unlike gcc's vector_size attribute, we do not allow vectors to be defined
// in conjunction with complex types (pointers, arrays, functions, etc.).
if (!T->isDependentType() &&
@ -763,11 +760,11 @@ QualType Sema::BuildExtVectorType(QualType T, ExprArg ArraySize,
return QualType();
}
if (!Arg->isTypeDependent() && !Arg->isValueDependent()) {
if (!ArraySize->isTypeDependent() && !ArraySize->isValueDependent()) {
llvm::APSInt vecSize(32);
if (!Arg->isIntegerConstantExpr(vecSize, Context)) {
if (!ArraySize->isIntegerConstantExpr(vecSize, Context)) {
Diag(AttrLoc, diag::err_attribute_argument_not_int)
<< "ext_vector_type" << Arg->getSourceRange();
<< "ext_vector_type" << ArraySize->getSourceRange();
return QualType();
}
@ -777,7 +774,7 @@ QualType Sema::BuildExtVectorType(QualType T, ExprArg ArraySize,
if (vectorSize == 0) {
Diag(AttrLoc, diag::err_attribute_zero_size)
<< Arg->getSourceRange();
<< ArraySize->getSourceRange();
return QualType();
}
@ -785,8 +782,7 @@ QualType Sema::BuildExtVectorType(QualType T, ExprArg ArraySize,
return Context.getExtVectorType(T, vectorSize);
}
return Context.getDependentSizedExtVectorType(T, ArraySize.takeAs<Expr>(),
AttrLoc);
return Context.getDependentSizedExtVectorType(T, ArraySize, AttrLoc);
}
/// \brief Build a function type.

File diff suppressed because it is too large Load Diff