/// the individual pointers, not the array holding them.
template <ASTDestroyer Destroyer> class ASTMultiPtr;
- /// Move emulation helper for ASTOwningResult
- template <ASTDestroyer Destroyer>
- class ASTResultMover
- {
- ASTOwningResult<Destroyer> &Moved;
+ namespace moving {
+ /// Move emulation helper for ASTOwningResult. NEVER EVER use this class
+ /// directly if you don't know what you're doing.
+ template <ASTDestroyer Destroyer>
+ class ASTResultMover
+ {
+ ASTOwningResult<Destroyer> &Moved;
- public:
- ASTResultMover(ASTOwningResult<Destroyer> &moved) : Moved(moved) {}
+ public:
+ ASTResultMover(ASTOwningResult<Destroyer> &moved) : Moved(moved) {}
- ASTOwningResult<Destroyer> * operator ->() { return &Moved; }
+ ASTOwningResult<Destroyer> * operator ->() { return &Moved; }
+ };
- // For the transition phase.
- operator void*();
+ /// Move emulation helper for ASTOwningPtr. NEVER EVER use this class
+ /// directly if you don't know what you're doing.
+ template <ASTDestroyer Destroyer>
+ class ASTPtrMover
+ {
+ ASTOwningPtr<Destroyer> &Moved;
- // For the transition phase.
- operator ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID>();
- };
+ public:
+ ASTPtrMover(ASTOwningPtr<Destroyer> &moved) : Moved(moved) {}
- /// Move emulation helper for ASTOwningPtr
- template <ASTDestroyer Destroyer>
- class ASTPtrMover
- {
- ASTOwningPtr<Destroyer> &Moved;
-
- public:
- ASTPtrMover(ASTOwningPtr<Destroyer> &moved) : Moved(moved) {}
+ ASTOwningPtr<Destroyer> * operator ->() { return &Moved; }
+ };
- ASTOwningPtr<Destroyer> * operator ->() { return &Moved; }
+ /// Move emulation helper for ASTMultiPtr. NEVER EVER use this class
+ /// directly if you don't know what you're doing.
+ template <ASTDestroyer Destroyer>
+ class ASTMultiMover
+ {
+ ASTMultiPtr<Destroyer> &Moved;
- operator void*();
- };
+ public:
+ ASTMultiMover(ASTMultiPtr<Destroyer> &moved) : Moved(moved) {}
- /// Move emulation helper for ASTMultiPtr
- template <ASTDestroyer Destroyer>
- class ASTMultiMover
- {
- ASTMultiPtr<Destroyer> &Moved;
+ ASTMultiPtr<Destroyer> * operator ->() { return &Moved; }
- public:
- ASTMultiMover(ASTMultiPtr<Destroyer> &moved) : Moved(moved) {}
-
- /// Reset the moved object's internal structures.
- void release();
- };
+ /// Reset the moved object's internal structures.
+ void release();
+ };
+ }
template <ASTDestroyer Destroyer>
class ASTOwningResult
void *Node;
bool Invalid;
- friend class ASTResultMover<Destroyer>;
+ friend class moving::ASTResultMover<Destroyer>;
friend class ASTOwningPtr<Destroyer>;
- ASTOwningResult(const ASTOwningResult&); // DO NOT IMPLEMENT
- ASTOwningResult& operator =(const ASTOwningResult&); // DO NOT IMPLEMENT
+ ASTOwningResult(ASTOwningResult&); // DO NOT IMPLEMENT
+ ASTOwningResult& operator =(ASTOwningResult&); // DO NOT IMPLEMENT
void destroy() {
if (Node) {
}
}
- void * take() {
- if (Invalid)
- return 0;
- return Node;
- }
-
public:
typedef ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID> DumbResult;
ASTOwningResult(ActionBase &actions, const DumbResult &res)
: Actions(&actions), Node(res.Val), Invalid(res.isInvalid) {}
/// Move from another owning result
- ASTOwningResult(ASTResultMover<Destroyer> mover)
+ ASTOwningResult(moving::ASTResultMover<Destroyer> mover)
: Actions(mover->Actions), Node(mover->take()), Invalid(mover->Invalid) {}
/// Move from an owning pointer
- ASTOwningResult(ASTPtrMover<Destroyer> mover);
+ ASTOwningResult(moving::ASTPtrMover<Destroyer> mover);
/// Move assignment from another owning result
- ASTOwningResult & operator =(ASTResultMover<Destroyer> mover) {
+ ASTOwningResult & operator =(moving::ASTResultMover<Destroyer> mover) {
Actions = mover->Actions;
Node = mover->take();
Invalid = mover->Invalid;
}
/// Move assignment from an owning ptr
- ASTOwningResult & operator =(ASTPtrMover<Destroyer> mover);
+ ASTOwningResult & operator =(moving::ASTPtrMover<Destroyer> mover);
/// Assignment from a raw pointer. Takes ownership - beware!
ASTOwningResult & operator =(void *raw)
/// valid and non-null.
bool isUsable() const { return !Invalid && Node; }
+ /// Take outside ownership of the raw pointer.
+ void * take() {
+ if (Invalid)
+ return 0;
+ void *tmp = Node;
+ Node = 0;
+ return tmp;
+ }
+
+ /// Alias for interface familiarity with unique_ptr.
+ void * release() {
+ return take();
+ }
+
+ /// Pass ownership to a classical ActionResult.
+ DumbResult result() {
+ if (Invalid)
+ return true;
+ return Node;
+ }
+
/// Move hook
- ASTResultMover<Destroyer> move() {
- return ASTResultMover<Destroyer>(*this);
+ operator moving::ASTResultMover<Destroyer>() {
+ return moving::ASTResultMover<Destroyer>(*this);
}
};
ActionBase *Actions;
void *Node;
- friend class ASTPtrMover<Destroyer>;
+ friend class moving::ASTPtrMover<Destroyer>;
friend class ASTOwningResult<Destroyer>;
- ASTOwningPtr(const ASTOwningPtr&); // DO NOT IMPLEMENT
- ASTOwningPtr& operator =(const ASTOwningPtr&); // DO NOT IMPLEMENT
+ ASTOwningPtr(ASTOwningPtr&); // DO NOT IMPLEMENT
+ ASTOwningPtr& operator =(ASTOwningPtr&); // DO NOT IMPLEMENT
void destroy() {
if (Node) {
ASTOwningPtr(ActionBase &actions, void *node)
: Actions(&actions), Node(node) {}
/// Move from another owning pointer
- ASTOwningPtr(ASTPtrMover<Destroyer> mover)
+ ASTOwningPtr(moving::ASTPtrMover<Destroyer> mover)
: Actions(mover->Actions), Node(mover->take()) {}
/// Move from an owning result
- ASTOwningPtr(ASTResultMover<Destroyer> mover);
+ ASTOwningPtr(moving::ASTResultMover<Destroyer> mover);
/// Move assignment from another owning pointer
- ASTOwningPtr & operator =(ASTPtrMover<Destroyer> mover) {
+ ASTOwningPtr & operator =(moving::ASTPtrMover<Destroyer> mover) {
Actions = mover->Actions;
Node = mover->take();
return *this;
}
/// Move assignment from an owning result
- ASTOwningPtr & operator =(ASTResultMover<Destroyer> mover);
+ ASTOwningPtr & operator =(moving::ASTResultMover<Destroyer> mover);
/// Assignment from a raw pointer. Takes ownership - beware!
ASTOwningPtr & operator =(void *raw)
/// Access to the raw pointer.
void * get() const { return Node; }
+ /// Release the raw pointer.
+ void * take() {
+ void *tmp = Node;
+ Node = 0;
+ return tmp;
+ }
+
+ /// Alias for interface familiarity with unique_ptr.
+ void * release() {
+ return take();
+ }
+
/// Move hook
- ASTPtrMover<Destroyer> move() {
- return ASTPtrMover<Destroyer>(*this);
+ operator moving::ASTPtrMover<Destroyer>() {
+ return moving::ASTPtrMover<Destroyer>(*this);
}
};
void **Nodes;
unsigned Count;
- friend class ASTMultiMover<Destroyer>;
+ friend class moving::ASTMultiMover<Destroyer>;
- ASTMultiPtr(const ASTMultiPtr&); // DO NOT IMPLEMENT
+ ASTMultiPtr(ASTMultiPtr&); // DO NOT IMPLEMENT
// Reference member prevents copy assignment.
void destroy() {
ASTMultiPtr(ActionBase &actions, void **nodes, unsigned count)
: Actions(actions), Nodes(nodes), Count(count) {}
/// Move constructor
- ASTMultiPtr(ASTMultiMover<Destroyer> mover)
+ ASTMultiPtr(moving::ASTMultiMover<Destroyer> mover)
: Actions(mover->Actions), Nodes(mover->Nodes), Count(mover->Count) {
- mover->Nodes = 0;
- mover->Count = 0;
+ mover.release();
}
/// Move assignment
- ASTMultiPtr & operator =(ASTMultiMover<Destroyer> mover) {
- Actions = mover->Actions;
+ ASTMultiPtr & operator =(moving::ASTMultiMover<Destroyer> mover) {
+ destroy();
Nodes = mover->Nodes;
Count = mover->Count;
mover.release();
unsigned size() const { return Count; }
/// Move hook
- ASTMultiMover<Destroyer> move() {
- return ASTMultiMover<Destroyer>(*this);
+ operator moving::ASTMultiMover<Destroyer>() {
+ return moving::ASTMultiMover<Destroyer>(*this);
}
};
// Out-of-line implementations due to definition dependencies
template <ASTDestroyer Destroyer> inline
- ASTResultMover<Destroyer>::operator void*() {
- return Moved.take();
- }
-
- template <ASTDestroyer Destroyer> inline
- ASTResultMover<Destroyer>::operator
- ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID>()
- {
- if(Moved.isInvalid())
- return true;
- return Moved.take();
- }
-
- template <ASTDestroyer Destroyer> inline
- ASTPtrMover<Destroyer>::operator void*() {
- return Moved.take();
- }
-
- template <ASTDestroyer Destroyer> inline
- void ASTMultiMover<Destroyer>::release() {
+ void moving::ASTMultiMover<Destroyer>::release() {
Moved.Nodes = 0;
Moved.Count = 0;
}
template <ASTDestroyer Destroyer> inline
- ASTOwningResult<Destroyer>::ASTOwningResult(ASTPtrMover<Destroyer> mover)
+ ASTOwningResult<Destroyer>::ASTOwningResult(
+ moving::ASTPtrMover<Destroyer> mover)
: Actions(mover->Actions), Node(mover->take()), Invalid(false) {}
template <ASTDestroyer Destroyer> inline
ASTOwningResult<Destroyer> &
- ASTOwningResult<Destroyer>::operator =(ASTPtrMover<Destroyer> mover) {
+ ASTOwningResult<Destroyer>::operator =(moving::ASTPtrMover<Destroyer> mover) {
Actions = mover->Actions;
Node = mover->take();
Invalid = false;
}
template <ASTDestroyer Destroyer> inline
- ASTOwningPtr<Destroyer>::ASTOwningPtr(ASTResultMover<Destroyer> mover)
+ ASTOwningPtr<Destroyer>::ASTOwningPtr(moving::ASTResultMover<Destroyer> mover)
: Actions(mover->Actions), Node(mover->take()) {
}
template <ASTDestroyer Destroyer> inline
ASTOwningPtr<Destroyer> &
- ASTOwningPtr<Destroyer>::operator =(ASTResultMover<Destroyer> mover) {
+ ASTOwningPtr<Destroyer>::operator =(moving::ASTResultMover<Destroyer> mover) {
Actions = mover->Actions;
Node = mover->take();
return *this;
}
+
+ // Move overloads.
+
+ template <ASTDestroyer Destroyer> inline
+ ASTOwningResult<Destroyer> move(ASTOwningResult<Destroyer> &ptr) {
+ return ASTOwningResult<Destroyer>(moving::ASTResultMover<Destroyer>(ptr));
+ }
+
+ template <ASTDestroyer Destroyer> inline
+ ASTOwningPtr<Destroyer> move(ASTOwningPtr<Destroyer> &ptr) {
+ return ASTOwningPtr<Destroyer>(moving::ASTPtrMover<Destroyer>(ptr));
+ }
+
+ template <ASTDestroyer Destroyer> inline
+ ASTMultiPtr<Destroyer> move(ASTMultiPtr<Destroyer> &ptr) {
+ return ASTMultiPtr<Destroyer>(moving::ASTMultiMover<Destroyer>(ptr));
+ }
}
#endif
DeclTy *ParseDeclarationOrFunctionDefinition();
DeclTy *ParseFunctionDefinition(Declarator &D);
void ParseKNRParamDeclarations(Declarator &D);
- ExprResult ParseSimpleAsm();
- ExprResult ParseAsmStringLiteral();
+ OwningExprResult ParseSimpleAsm();
+ OwningExprResult ParseAsmStringLiteral();
// Objective-C External Declarations
DeclTy *ParseObjCAtDirectives();
SkipUntil(tok::r_paren);
break;
} else {
- ArgExprs.push_back(ArgExpr.move());
+ ArgExprs.push_back(ArgExpr.release());
}
if (Tok.isNot(tok::comma))
break;
SkipUntil(tok::r_paren);
break;
} else {
- ArgExprs.push_back(ArgExpr.move());
+ ArgExprs.push_back(ArgExpr.release());
}
if (Tok.isNot(tok::comma))
break;
while (1) {
// If a simple-asm-expr is present, parse it.
if (Tok.is(tok::kw_asm)) {
- OwningExprResult AsmLabel(Actions, ParseSimpleAsm());
+ OwningExprResult AsmLabel(ParseSimpleAsm());
if (AsmLabel.isInvalid()) {
SkipUntil(tok::semi);
return 0;
}
- D.setAsmLabel(AsmLabel.move());
+ D.setAsmLabel(AsmLabel.release());
}
// If attributes are present, parse them.
SkipUntil(tok::semi);
return 0;
}
- Actions.AddInitializerToDecl(LastDeclInGroup, Init.move());
+ Actions.AddInitializerToDecl(LastDeclInGroup, Init.release());
} else if (Tok.is(tok::l_paren)) {
// Parse C++ direct initializer: '(' expression-list ')'
SourceLocation LParenLoc = ConsumeParen();
if (Res.isInvalid())
SkipUntil(tok::semi, true, true);
else
- DeclaratorInfo.BitfieldSize = Res.move();
+ DeclaratorInfo.BitfieldSize = Res.release();
}
// If attributes exist after the declarator, parse them.
LastEnumConstDecl,
IdentLoc, Ident,
EqualLoc,
- AssignedVal.move());
+ AssignedVal.release());
EnumConstantDecls.push_back(EnumConstDecl);
LastEnumConstDecl = EnumConstDecl;
} else {
// Inform the actions module about the default argument
Actions.ActOnParamDefaultArgument(Param, EqualLoc,
- DefArgResult.move());
+ DefArgResult.release());
}
}
// Remember that we parsed a pointer type, and remember the type-quals.
D.AddTypeInfo(DeclaratorChunk::getArray(DS.getTypeQualifiers(),
StaticLoc.isValid(), isStar,
- NumElements.move(), StartLoc));
+ NumElements.release(), StartLoc));
}
/// [GNU] typeof-specifier:
const char *PrevSpec = 0;
// Check for duplicate type specifiers.
if (DS.SetTypeSpecType(DeclSpec::TST_typeofExpr, StartLoc, PrevSpec,
- Result.move()))
+ Result.release()))
Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
// FIXME: Not accurate, the range gets one token more than it should.
const char *PrevSpec = 0;
// Check for duplicate type specifiers (e.g. "int typeof(int)").
if (DS.SetTypeSpecType(DeclSpec::TST_typeofExpr, StartLoc, PrevSpec,
- Result.move()))
+ Result.release()))
Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
}
DS.SetRangeEnd(RParenLoc);
// See Sema::ActOnCXXMemberDeclarator for details.
LastDeclInGroup = Actions.ActOnCXXMemberDeclarator(CurScope, AS,
DeclaratorInfo,
- BitfieldSize.move(),
- Init.move(),
+ BitfieldSize.release(),
+ Init.release(),
LastDeclInGroup);
// If we don't have a comma, it is either the end of the list (a ';')
return ParseThrowExpression();
OwningExprResult LHS(Actions, ParseCastExpression(false));
- if (LHS.isInvalid()) return LHS.move();
+ if (LHS.isInvalid()) return LHS.result();
- return ParseRHSOfBinaryExpression(LHS.move(), prec::Comma);
+ return ParseRHSOfBinaryExpression(LHS.result(), prec::Comma);
}
/// This routine is called when the '@' is seen and consumed.
///
Parser::ExprResult Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) {
OwningExprResult LHS(Actions, ParseObjCAtExpression(AtLoc));
- if (LHS.isInvalid()) return LHS.move();
+ if (LHS.isInvalid()) return LHS.result();
- return ParseRHSOfBinaryExpression(LHS.move(), prec::Comma);
+ return ParseRHSOfBinaryExpression(LHS.result(), prec::Comma);
}
/// ParseAssignmentExpression - Parse an expr that doesn't include commas.
return ParseThrowExpression();
OwningExprResult LHS(Actions, ParseCastExpression(false));
- if (LHS.isInvalid()) return LHS.move();
+ if (LHS.isInvalid()) return LHS.result();
- return ParseRHSOfBinaryExpression(LHS.move(), prec::Assignment);
+ return ParseRHSOfBinaryExpression(LHS.result(), prec::Assignment);
}
/// ParseAssignmentExprWithObjCMessageExprStart - Parse an assignment expression
OwningExprResult R(Actions, ParseObjCMessageExpressionBody(LBracLoc, NameLoc,
ReceiverName,
ReceiverExpr));
- if (R.isInvalid()) return R.move();
- R = ParsePostfixExpressionSuffix(R.move());
- if (R.isInvalid()) return R.move();
- return ParseRHSOfBinaryExpression(R.move(), 2);
+ if (R.isInvalid()) return R.result();
+ R = ParsePostfixExpressionSuffix(R.result());
+ if (R.isInvalid()) return R.result();
+ return ParseRHSOfBinaryExpression(R.result(), 2);
}
Parser::ExprResult Parser::ParseConstantExpression() {
OwningExprResult LHS(Actions, ParseCastExpression(false));
- if (LHS.isInvalid()) return LHS.move();
+ if (LHS.isInvalid()) return LHS.result();
- return ParseRHSOfBinaryExpression(LHS.move(), prec::Conditional);
+ return ParseRHSOfBinaryExpression(LHS.result(), prec::Conditional);
}
/// ParseRHSOfBinaryExpression - Parse a binary expression that starts with
// because we are called recursively, or because the token is not a binop),
// then we are done!
if (NextTokPrec < MinPrec)
- return LHS.move();
+ return LHS.result();
// Consume the operator, saving the operator token for error reporting.
Token OpToken = Tok;
// 'logical-OR-expression' as we might expect.
TernaryMiddle = ParseExpression();
if (TernaryMiddle.isInvalid())
- return TernaryMiddle.move();
+ return TernaryMiddle.result();
} else {
// Special case handling of "X ? Y : Z" where Y is empty:
// logical-OR-expression '?' ':' conditional-expression [GNU]
// Parse another leaf here for the RHS of the operator.
OwningExprResult RHS(Actions, ParseCastExpression(false));
if (RHS.isInvalid())
- return RHS.move();
+ return RHS.result();
// Remember the precedence of this operator and get the precedence of the
// operator immediately to the right of the RHS.
// 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(RHS.move(), ThisPrec + !isRightAssoc);
+ RHS = ParseRHSOfBinaryExpression(RHS.result(), ThisPrec + !isRightAssoc);
if (RHS.isInvalid())
- return RHS.move();
+ return RHS.result();
NextTokPrec = getBinOpPrecedence(Tok.getKind());
}
if (!LHS.isInvalid()) {
// Combine the LHS and RHS into the LHS (e.g. build AST).
if (TernaryMiddle.isInvalid())
- LHS = Actions.ActOnBinOp(CurScope, OpToken.getLocation(),
- OpToken.getKind(), LHS.move(), RHS.move());
+ LHS = Actions.ActOnBinOp(CurScope, OpToken.getLocation(),
+ OpToken.getKind(), LHS.release(),
+ RHS.release());
else
LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
- LHS.move(), TernaryMiddle.move(),
- RHS.move());
+ LHS.release(), TernaryMiddle.release(),
+ RHS.release());
}
}
}
SourceLocation LParenLoc = Tok.getLocation();
SourceLocation RParenLoc;
Res = ParseParenExpression(ParenExprType, CastTy, RParenLoc);
- if (Res.isInvalid()) return Res.move();
+ if (Res.isInvalid()) return Res.result();
switch (ParenExprType) {
case SimpleExpr: break; // Nothing else to do.
// TODO: For cast expression with CastTy.
Res = ParseCastExpression(false);
if (!Res.isInvalid())
- Res = Actions.ActOnCastExpr(LParenLoc, CastTy, RParenLoc, Res.move());
- return Res.move();
+ Res = Actions.ActOnCastExpr(LParenLoc, CastTy, RParenLoc,
+ Res.release());
+ return Res.result();
}
// These can be followed by postfix-expr pieces.
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
}
// primary-expression
ConsumeToken();
// These can be followed by postfix-expr pieces.
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
case tok::kw_true:
case tok::kw_false:
SourceLocation L = ConsumeToken();
Res = Actions.ActOnIdentifierExpr(CurScope, L, II, Tok.is(tok::l_paren));
// These can be followed by postfix-expr pieces.
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
}
case tok::char_constant: // constant: character-constant
Res = Actions.ActOnCharacterConstant(Tok);
ConsumeToken();
// These can be followed by postfix-expr pieces.
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
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(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
case tok::string_literal: // primary-expression: string-literal
case tok::wide_string_literal:
Res = ParseStringLiteralExpression();
- if (Res.isInvalid()) return Res.move();
+ if (Res.isInvalid()) return Res.result();
// This can be followed by postfix-expr pieces (e.g. "foo"[1]).
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
case tok::kw___builtin_va_arg:
case tok::kw___builtin_offsetof:
case tok::kw___builtin_choose_expr:
SourceLocation SavedLoc = ConsumeToken();
Res = ParseCastExpression(true);
if (!Res.isInvalid())
- Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.move());
- return Res.move();
+ Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
+ return Res.result();
}
case tok::amp: // unary-expression: '&' cast-expression
case tok::star: // unary-expression: '*' cast-expression
SourceLocation SavedLoc = ConsumeToken();
Res = ParseCastExpression(false);
if (!Res.isInvalid())
- Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.move());
- return Res.move();
+ Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
+ return Res.result();
}
case tok::kw___extension__:{//unary-expression:'__extension__' cast-expr [GNU]
SourceLocation SavedLoc = ConsumeToken();
Res = ParseCastExpression(false);
if (!Res.isInvalid())
- Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.move());
- return Res.move();
+ Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
+ return Res.result();
}
case tok::kw_sizeof: // unary-expression: 'sizeof' unary-expression
// unary-expression: 'sizeof' '(' type-name ')'
Diag(Tok, diag::err_expected_ident);
return ExprResult(true);
}
-
+
Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(),
Tok.getIdentifierInfo());
ConsumeToken();
- return Res.move();
+ return Res.result();
}
case tok::kw_const_cast:
case tok::kw_dynamic_cast:
case tok::kw_static_cast:
Res = ParseCXXCasts();
// These can be followed by postfix-expr pieces.
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
case tok::kw_typeid:
Res = ParseCXXTypeid();
// This can be followed by postfix-expr pieces.
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
case tok::kw_this:
Res = ParseCXXThis();
// This can be followed by postfix-expr pieces.
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
case tok::kw_char:
case tok::kw_wchar_t:
Res = ParseCXXTypeConstructExpression(DS);
// This can be followed by postfix-expr pieces.
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
}
case tok::annot_cxxscope: // [C++] id-expression: qualified-id
case tok::kw_operator: // [C++] id-expression: operator/conversion-function-id
// template-id
Res = ParseCXXIdExpression();
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
case tok::coloncolon: // [C++] new-expression or [C++] delete-expression
// If the next token is neither 'new' nor 'delete', the :: would have been
while (1) {
switch (Tok.getKind()) {
default: // Not a postfix-expression suffix.
- return LHS.move();
+ return LHS.result();
case tok::l_square: { // postfix-expression: p-e '[' expression ']'
Loc = ConsumeBracket();
OwningExprResult Idx(Actions, ParseExpression());
SourceLocation RLoc = Tok.getLocation();
if (!LHS.isInvalid() && !Idx.isInvalid() && Tok.is(tok::r_square)) {
- LHS = Actions.ActOnArraySubscriptExpr(CurScope, LHS.move(), Loc,
- Idx.move(), RLoc);
+ LHS = Actions.ActOnArraySubscriptExpr(CurScope, LHS.release(), Loc,
+ Idx.release(), RLoc);
} else
LHS = ExprResult(true);
if (!LHS.isInvalid() && Tok.is(tok::r_paren)) {
assert((ArgExprs.size() == 0 || ArgExprs.size()-1 == CommaLocs.size())&&
"Unexpected number of commas!");
- LHS = Actions.ActOnCallExpr(CurScope, LHS.move(), Loc,
+ LHS = Actions.ActOnCallExpr(CurScope, LHS.release(), Loc,
ArgExprs.take(),
ArgExprs.size(), &CommaLocs[0],
Tok.getLocation());
}
if (!LHS.isInvalid()) {
- LHS = Actions.ActOnMemberReferenceExpr(LHS.move(), OpLoc, OpKind,
+ LHS = Actions.ActOnMemberReferenceExpr(LHS.release(), OpLoc, OpKind,
Tok.getLocation(),
*Tok.getIdentifierInfo());
}
case tok::minusminus: // postfix-expression: postfix-expression '--'
if (!LHS.isInvalid()) {
LHS = Actions.ActOnPostfixUnaryOp(CurScope, Tok.getLocation(),
- Tok.getKind(), LHS.move());
+ Tok.getKind(), LHS.release());
}
ConsumeToken();
break;
// If this is a parenthesized expression, it is the start of a
// unary-expression, but doesn't include any postfix pieces. Parse these
// now if present.
- Operand = ParsePostfixExpressionSuffix(Operand.move());
+ Operand = ParsePostfixExpressionSuffix(Operand.result());
}
// If we get here, the operand to the sizeof/alignof was an expresion.
if (!Operand.isInvalid())
Operand = Actions.ActOnSizeOfAlignOfExpr(OpTok.getLocation(),
OpTok.is(tok::kw_sizeof),
- /*isType=*/false, Operand.move(),
- SourceRange());
- return Operand.move();
+ /*isType=*/false,
+ Operand.release(), SourceRange());
+ return Operand.result();
}
/// ParseBuiltinPrimaryExpression
Diag(Tok, diag::err_expected_rparen);
return ExprResult(true);
}
- Res = Actions.ActOnVAArg(StartLoc, Expr.move(), Ty, ConsumeParen());
+ Res = Actions.ActOnVAArg(StartLoc, Expr.release(), Ty, ConsumeParen());
break;
}
case tok::kw___builtin_offsetof: {
Res = ParseExpression();
if (Res.isInvalid()) {
SkipUntil(tok::r_paren);
- return Res.move();
+ return Res.result();
}
- Comps.back().U.E = Res.move();
+ Comps.back().U.E = Res.release();
Comps.back().LocEnd =
MatchRHSPunctuation(tok::r_square, Comps.back().LocStart);
OwningExprResult Cond(Actions, ParseAssignmentExpression());
if (Cond.isInvalid()) {
SkipUntil(tok::r_paren);
- return Cond.move();
+ return Cond.result();
}
if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
return ExprResult(true);
OwningExprResult Expr1(Actions, ParseAssignmentExpression());
if (Expr1.isInvalid()) {
SkipUntil(tok::r_paren);
- return Expr1.move();
+ return Expr1.result();
}
if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
return ExprResult(true);
OwningExprResult Expr2(Actions, ParseAssignmentExpression());
if (Expr2.isInvalid()) {
SkipUntil(tok::r_paren);
- return Expr2.move();
+ return Expr2.result();
}
if (Tok.isNot(tok::r_paren)) {
Diag(Tok, diag::err_expected_rparen);
return ExprResult(true);
}
- Res = Actions.ActOnChooseExpr(StartLoc, Cond.move(), Expr1.move(),
- Expr2.move(), ConsumeParen());
+ Res = Actions.ActOnChooseExpr(StartLoc, Cond.release(), Expr1.release(),
+ Expr2.release(), ConsumeParen());
break;
}
case tok::kw___builtin_overload: {
SkipUntil(tok::r_paren);
return ExprResult(true);
} else
- ArgExprs.push_back(ArgExpr.move());
+ ArgExprs.push_back(ArgExpr.release());
if (Tok.isNot(tok::comma))
break;
// These can be followed by postfix-expr pieces because they are
// primary-expressions.
- return ParsePostfixExpressionSuffix(Res.move());
+ return ParsePostfixExpressionSuffix(Res.result());
}
/// ParseParenExpression - This parses the unit that starts with a '(' token,
// If the substmt parsed correctly, build the AST node.
if (!Stmt.isInvalid() && Tok.is(tok::r_paren))
Result = Actions.ActOnStmtExpr(
- OpenLoc, Stmt.move(), Tok.getLocation());
+ OpenLoc, Stmt.release(), Tok.getLocation());
} else if (ExprType >= CompoundLiteral && isTypeIdInParens()) {
// Otherwise, this is a compound literal expression or cast expression.
ExprType = CompoundLiteral;
if (!Result.isInvalid())
return Actions.ActOnCompoundLiteral(OpenLoc, Ty, RParenLoc,
- Result.move());
+ Result.release());
} else if (ExprType == CastExpr) {
// Note that this doesn't parse the subsequence cast-expression, it just
// returns the parsed type to the callee.
Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
return ExprResult(true);
}
- return Result.move();
+ return Result.result();
} else {
Result = ParseExpression();
ExprType = SimpleExpr;
if (!Result.isInvalid() && Tok.is(tok::r_paren))
Result = Actions.ActOnParenExpr(
- OpenLoc, Tok.getLocation(), Result.move());
+ OpenLoc, Tok.getLocation(), Result.release());
}
// Match the ')'.
MatchRHSPunctuation(tok::r_paren, OpenLoc);
}
- return Result.move();
+ return Result.result();
}
/// ParseStringLiteralExpression - This handles the various token types that
if (Expr.isInvalid())
return true;
- Exprs.push_back(Expr.move());
+ Exprs.push_back(Expr.release());
if (Tok.isNot(tok::comma))
return false;
if (Tok.is(tok::l_brace)) {
OwningStmtResult Stmt(Actions, ParseCompoundStatementBody());
if (!Stmt.isInvalid()) {
- Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.move(), CurScope);
+ Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.release(), CurScope);
} else {
Actions.ActOnBlockError(CaretLoc, CurScope);
}
}
ExitScope();
- return Result.move();
+ return Result.result();
}
if (!Result.isInvalid())
Result = Actions.ActOnCXXNamedCast(OpLoc, Kind,
LAngleBracketLoc, CastTy, RAngleBracketLoc,
- LParenLoc, Result.move(), RParenLoc);
+ LParenLoc, Result.release(), RParenLoc);
- return Result.move();
+ return Result.result();
}
/// ParseCXXTypeid - This handles the C++ typeid expression.
MatchRHSPunctuation(tok::r_paren, LParenLoc);
Result = Actions.ActOnCXXTypeid(OpLoc, LParenLoc, /*isType=*/false,
- Result.move(), RParenLoc);
+ Result.release(), RParenLoc);
}
}
- return Result.move();
+ return Result.result();
}
/// ParseCXXBoolLiteral - This handles the C++ Boolean literals.
default:
OwningExprResult Expr(Actions, ParseAssignmentExpression());
- if (Expr.isInvalid()) return Expr.move();
- return Actions.ActOnCXXThrow(ThrowLoc, Expr.move());
+ if (Expr.isInvalid()) return Expr.result();
+ return Actions.ActOnCXXThrow(ThrowLoc, Expr.release());
}
}
// simple-asm-expr[opt]
if (Tok.is(tok::kw_asm)) {
- OwningExprResult AsmLabel(Actions, ParseSimpleAsm());
+ OwningExprResult AsmLabel(ParseSimpleAsm());
if (AsmLabel.isInvalid()) {
SkipUntil(tok::semi);
return true;
}
- DeclaratorInfo.setAsmLabel(AsmLabel.move());
+ DeclaratorInfo.setAsmLabel(AsmLabel.release());
}
// If attributes are present, parse them.
return true;
return Actions.ActOnCXXConditionDeclarationExpr(CurScope, StartLoc,
- DeclaratorInfo,
- EqualLoc, AssignExpr.move());
+ DeclaratorInfo, EqualLoc,
+ AssignExpr.release());
}
/// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers.
first = false;
D.AddTypeInfo(DeclaratorChunk::getArray(0, /*static=*/false, /*star=*/false,
- Size.move(), LLoc));
+ Size.release(), LLoc));
if (MatchRHSPunctuation(tok::r_square, LLoc).isInvalid())
return;
OwningExprResult Operand(Actions, ParseCastExpression(false));
if (Operand.isInvalid())
- return Operand.move();
+ return Operand.result();
- return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete, Operand.move());
+ return Actions.ActOnCXXDelete(Start, UseGlobal, ArrayDelete,
+ Operand.release());
}
OwningExprResult Idx(Actions, ParseAssignmentExpression());
if (Idx.isInvalid()) {
SkipUntil(tok::r_square);
- return Idx.move();
+ return Idx.result();
}
// Given an expression, we could either have a designator (if the next
return ParseAssignmentExprWithObjCMessageExprStart(StartLoc,
SourceLocation(),
- 0, Idx.move());
+ 0, Idx.release());
}
// Create designation if we haven't already.
// If this is a normal array designator, remember it.
if (Tok.isNot(tok::ellipsis)) {
- Desig->AddDesignator(Designator::getArray(Idx.move()));
+ Desig->AddDesignator(Designator::getArray(Idx.release()));
} else {
// Handle the gnu array range extension.
Diag(Tok, diag::ext_gnu_array_range);
OwningExprResult RHS(Actions, ParseConstantExpression());
if (RHS.isInvalid()) {
SkipUntil(tok::r_square);
- return RHS.move();
+ return RHS.result();
}
- Desig->AddDesignator(Designator::getArrayRange(Idx.move(), RHS.move()));
+ Desig->AddDesignator(Designator::getArrayRange(Idx.release(),
+ RHS.release()));
}
MatchRHSPunctuation(tok::r_square, StartLoc);
// If we couldn't parse the subelement, bail out.
if (!SubElt.isInvalid()) {
- InitExprs.push_back(SubElt.move());
+ InitExprs.push_back(SubElt.release());
} else {
InitExprsOk = false;
}
}
ConsumeToken(); // consume ';'
- return Actions.ActOnObjCAtThrowStmt(atLoc, Res.move());
+ return Actions.ActOnObjCAtThrowStmt(atLoc, Res.release());
}
/// objc-synchronized-statement:
ExitScope();
if (SynchBody.isInvalid())
SynchBody = Actions.ActOnNullStmt(Tok.getLocation());
- return Actions.ActOnObjCAtSynchronizedStmt(atLoc, Res.move(),
- SynchBody.move());
+ return Actions.ActOnObjCAtSynchronizedStmt(atLoc, Res.release(),
+ SynchBody.release());
}
/// objc-try-catch-statement:
if (CatchBody.isInvalid())
CatchBody = Actions.ActOnNullStmt(Tok.getLocation());
CatchStmts = Actions.ActOnObjCAtCatchStmt(AtCatchFinallyLoc,
- RParenLoc, FirstPart.move(), CatchBody.move(), CatchStmts.move());
+ RParenLoc, FirstPart.release(), CatchBody.release(),
+ CatchStmts.release());
ExitScope();
} else {
Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)
if (FinallyBody.isInvalid())
FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc,
- FinallyBody.move());
+ FinallyBody.release());
catch_or_finally_seen = true;
ExitScope();
break;
Diag(atLoc, diag::err_missing_catch_finally);
return true;
}
- return Actions.ActOnObjCAtTryStmt(atLoc, TryBody.move(), CatchStmts.move(),
- FinallyStmt.move());
+ return Actions.ActOnObjCAtTryStmt(atLoc, TryBody.release(),
+ CatchStmts.release(),
+ FinallyStmt.release());
}
/// objc-method-def: objc-method-proto ';'[opt] '{' body '}'
ExitScope();
// TODO: Pass argument information.
- Actions.ActOnFinishFunctionBody(MDecl, FnBody.move());
+ Actions.ActOnFinishFunctionBody(MDecl, FnBody.release());
return MDecl;
}
}
// Otherwise, eat the semicolon.
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
- return Actions.ActOnExprStmt(Res.move());
+ return Actions.ActOnExprStmt(Res.release());
}
Parser::ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
OwningExprResult Res(Actions, ParseExpression());
if (Res.isInvalid()) {
SkipUntil(tok::r_square);
- return Res.move();
+ return Res.result();
}
return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(),
- 0, Res.move());
+ 0, Res.release());
}
/// ParseObjCMessageExpressionBody - Having parsed "'[' objc-receiver", parse
// stop at the ']' when it skips to the ';'. We want it to skip beyond
// the enclosing expression.
SkipUntil(tok::r_square);
- return Res.move();
+ return Res.result();
}
// We have a valid expression.
- KeyExprs.push_back(Res.move());
+ KeyExprs.push_back(Res.release());
// Check for another keyword selector.
selIdent = ParseObjCSelector(Loc);
// stop at the ']' when it skips to the ';'. We want it to skip beyond
// the enclosing expression.
SkipUntil(tok::r_square);
- return Res.move();
+ return Res.result();
}
// We have a valid expression.
- KeyExprs.push_back(Res.move());
+ KeyExprs.push_back(Res.release());
}
} else if (!selIdent) {
Diag(Tok, diag::err_expected_ident); // missing selector name.
Parser::ExprResult Parser::ParseObjCStringLiteral(SourceLocation AtLoc) {
OwningExprResult Res(Actions, ParseStringLiteralExpression());
- if (Res.isInvalid()) return Res.move();
+ if (Res.isInvalid()) return Res.result();
// @"foo" @"bar" is a valid concatenated string. Eat any subsequent string
// expressions. At this point, we know that the only valid thing that starts
llvm::SmallVector<SourceLocation, 4> AtLocs;
ExprVector AtStrings(Actions);
AtLocs.push_back(AtLoc);
- AtStrings.push_back(Res.move());
+ AtStrings.push_back(Res.release());
while (Tok.is(tok::at)) {
AtLocs.push_back(ConsumeToken()); // eat the @.
Diag(Tok, diag::err_objc_concat_string);
if (Lit.isInvalid())
- return Lit.move();
+ return Lit.result();
- AtStrings.push_back(Lit.move());
+ AtStrings.push_back(Lit.release());
}
return Actions.ParseObjCStringLiteral(&AtLocs[0], AtStrings.take(),
}
SourceLocation RParenLoc = Tok.getLocation();
- Actions.ActOnPragmaPack(Kind, Name, Alignment.move(), PackLoc,
+ Actions.ActOnPragmaPack(Kind, Name, Alignment.release(), PackLoc,
LParenLoc, RParenLoc);
}
}
// Otherwise, eat the semicolon.
ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr);
- return Actions.ActOnExprStmt(Expr.move());
+ return Actions.ActOnExprStmt(Expr.release());
}
case tok::kw_case: // C99 6.8.1: labeled-statement
case tok::kw_asm:
bool msAsm = false;
Res = ParseAsmStatement(msAsm);
- if (msAsm) return Res.move();
+ if (msAsm) return Res.result();
SemiError = "asm statement";
break;
}
// Skip until we see a } or ;, but don't eat it.
SkipUntil(tok::r_brace, true, true);
}
- return Res.move();
+ return Res.result();
}
/// ParseLabeledStatement - We have an identifier and a ':' after it.
return Actions.ActOnLabelStmt(IdentTok.getLocation(),
IdentTok.getIdentifierInfo(),
- ColonLoc, SubStmt.move());
+ ColonLoc, SubStmt.release());
}
/// ParseCaseStatement
if (SubStmt.isInvalid())
SubStmt = Actions.ActOnNullStmt(ColonLoc);
- return Actions.ActOnCaseStmt(CaseLoc, LHS.move(), DotDotDotLoc,
- RHS.move(), ColonLoc, SubStmt.move());
+ return Actions.ActOnCaseStmt(CaseLoc, LHS.release(), DotDotDotLoc,
+ RHS.release(), ColonLoc, SubStmt.release());
}
/// ParseDefaultStatement
return true;
return Actions.ActOnDefaultStmt(DefaultLoc, ColonLoc,
- SubStmt.move(), CurScope);
+ SubStmt.release(), CurScope);
}
OwningStmtResult Body(Actions, ParseCompoundStatementBody(isStmtExpr));
ExitScope();
- return Body.move();
+ return Body.result();
}
// Add the __extension__ node to the AST.
Res = Actions.ActOnUnaryOp(CurScope, ExtLoc, tok::kw___extension__,
- Res.move());
+ Res.release());
if (Res.isInvalid())
continue;
// 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(Res.move());
+ R = Actions.ActOnExprStmt(Res.release());
}
}
if (R.isUsable())
- Stmts.push_back(R.move());
+ Stmts.push_back(R.release());
}
// We broke out of the while loop because we found a '}' or EOF.
if (ElseStmt.isInvalid())
ElseStmt = Actions.ActOnNullStmt(ElseStmtLoc);
- return Actions.ActOnIfStmt(IfLoc, CondExp.move(), ThenStmt.move(),
- ElseLoc, ElseStmt.move());
+ return Actions.ActOnIfStmt(IfLoc, CondExp.release(), ThenStmt.release(),
+ ElseLoc, ElseStmt.release());
}
/// ParseSwitchStatement
return true;
}
- OwningStmtResult Switch(Actions, Actions.ActOnStartOfSwitchStmt(Cond.move()));
+ OwningStmtResult Switch(Actions,
+ Actions.ActOnStartOfSwitchStmt(Cond.release()));
// C99 6.8.4p3 - In C99, the body of the switch statement is a scope, even if
// there is no compound stmt. C90 does not have this clause. We only do this
ExitScope();
- return Actions.ActOnFinishSwitchStmt(SwitchLoc, Switch.move(), Body.move());
+ return Actions.ActOnFinishSwitchStmt(SwitchLoc, Switch.release(),
+ Body.release());
}
/// ParseWhileStatement
if (Cond.isInvalid() || Body.isInvalid()) return true;
- return Actions.ActOnWhileStmt(WhileLoc, Cond.move(), Body.move());
+ return Actions.ActOnWhileStmt(WhileLoc, Cond.release(), Body.release());
}
/// ParseDoStatement
if (Cond.isInvalid() || Body.isInvalid()) return true;
- return Actions.ActOnDoStmt(DoLoc, Body.move(), WhileLoc, Cond.move());
+ return Actions.ActOnDoStmt(DoLoc, Body.release(), WhileLoc, Cond.release());
}
/// ParseForStatement
// Turn the expression into a stmt.
if (!Value.isInvalid())
- FirstPart = Actions.ActOnExprStmt(Value.move());
-
+ FirstPart = Actions.ActOnExprStmt(Value.release());
+
if (Tok.is(tok::semi)) {
ConsumeToken();
}
Value = ParseExpression();
if (!Value.isInvalid()) {
// Turn the expression into a stmt.
- ThirdPart = Actions.ActOnExprStmt(Value.move());
+ ThirdPart = Actions.ActOnExprStmt(Value.release());
}
}
}
if (Body.isInvalid())
return true;
-
- if (!ForEach)
- return Actions.ActOnForStmt(ForLoc, LParenLoc, FirstPart.move(),
- SecondPart.move(), ThirdPart.move(), RParenLoc,
- Body.move());
+
+ if (!ForEach)
+ return Actions.ActOnForStmt(ForLoc, LParenLoc, FirstPart.release(),
+ SecondPart.release(), ThirdPart.release(),
+ RParenLoc, Body.release());
else
return Actions.ActOnObjCForCollectionStmt(ForLoc, LParenLoc,
- FirstPart.move(),
- SecondPart.move(),
- RParenLoc, Body.move());
+ FirstPart.release(),
+ SecondPart.release(),
+ RParenLoc, Body.release());
}
/// ParseGotoStatement
SkipUntil(tok::semi, false, true);
return true;
}
- Res = Actions.ActOnIndirectGotoStmt(GotoLoc, StarLoc, R.move());
+ Res = Actions.ActOnIndirectGotoStmt(GotoLoc, StarLoc, R.release());
} else {
Diag(Tok, diag::err_expected_ident);
return true;
}
- return Res.move();
+ return Res.result();
}
/// ParseContinueStatement
return true;
}
}
- return Actions.ActOnReturnStmt(ReturnLoc, R.move());
+ return Actions.ActOnReturnStmt(ReturnLoc, R.release());
}
/// FuzzyParseMicrosoftAsmStatement. When -fms-extensions is enabled, this
}
Loc = ConsumeParen();
- OwningExprResult AsmString(Actions, ParseAsmStringLiteral());
+ OwningExprResult AsmString(ParseAsmStringLiteral());
if (AsmString.isInvalid())
return true;
// Parse Inputs, if present.
if (ParseAsmOperandsOpt(Names, Constraints, Exprs))
return true;
-
+
assert(Names.size() == Constraints.size() &&
Constraints.size() == Exprs.size()
&& "Input operand size mismatch!");
NumInputs = Names.size() - NumOutputs;
-
+
// Parse the clobbers, if present.
if (Tok.is(tok::colon)) {
ConsumeToken();
-
+
// Parse the asm-string list for clobbers.
while (1) {
- OwningExprResult Clobber(Actions, ParseAsmStringLiteral());
+ OwningExprResult Clobber(ParseAsmStringLiteral());
if (Clobber.isInvalid())
break;
-
- Clobbers.push_back(Clobber.move());
-
+
+ Clobbers.push_back(Clobber.release());
+
if (Tok.isNot(tok::comma)) break;
ConsumeToken();
}
}
-
+
RParenLoc = MatchRHSPunctuation(tok::r_paren, Loc);
}
-
+
return Actions.ActOnAsmStmt(AsmLoc, isSimple, isVolatile,
NumOutputs, NumInputs,
&Names[0], Constraints.take(),
- Exprs.take(), AsmString.move(),
+ Exprs.take(), AsmString.release(),
Clobbers.size(), Clobbers.take(),
RParenLoc);
}
} else
Names.push_back(std::string());
- OwningExprResult Constraint(Actions, ParseAsmStringLiteral());
+ OwningExprResult Constraint(ParseAsmStringLiteral());
if (Constraint.isInvalid()) {
SkipUntil(tok::r_paren);
return true;
}
- Constraints.push_back(Constraint.move());
+ Constraints.push_back(Constraint.release());
if (Tok.isNot(tok::l_paren)) {
Diag(Tok, diag::err_expected_lparen_after) << "asm operand";
SkipUntil(tok::r_paren);
return true;
}
-
+
// Read the parenthesized expression.
OwningExprResult Res(Actions, ParseSimpleParenExpression());
if (Res.isInvalid()) {
SkipUntil(tok::r_paren);
return true;
}
- Exprs.push_back(Res.move());
+ Exprs.push_back(Res.release());
// Eat the comma and continue parsing if it exists.
if (Tok.isNot(tok::comma)) return false;
ConsumeToken();
// Leave the function body scope.
ExitScope();
- return Actions.ActOnFinishFunctionBody(Decl, FnBody.move());
+ return Actions.ActOnFinishFunctionBody(Decl, FnBody.release());
}
return ParseExternalDeclaration();
}
case tok::kw_asm: {
- OwningExprResult Result(Actions, ParseSimpleAsm());
+ OwningExprResult Result(ParseSimpleAsm());
ExpectAndConsume(tok::semi, diag::err_expected_semi_after,
"top-level asm block");
if (!Result.isInvalid())
- return Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), Result.move());
+ return Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), Result.release());
return 0;
}
case tok::at:
/// [GNU] asm-string-literal:
/// string-literal
///
-Parser::ExprResult Parser::ParseAsmStringLiteral() {
+Parser::OwningExprResult Parser::ParseAsmStringLiteral() {
if (!isTokenStringLiteral()) {
Diag(Tok, diag::err_expected_string_literal);
- return true;
+ return OwningExprResult(true);
}
OwningExprResult Res(Actions, ParseStringLiteralExpression());
- if (Res.isInvalid()) return true;
+ if (Res.isInvalid()) return move(Res);
// TODO: Diagnose: wide string literal in 'asm'
- return Res.move();
+ return move(Res);
}
/// ParseSimpleAsm
/// [GNU] simple-asm-expr:
/// 'asm' '(' asm-string-literal ')'
///
-Parser::ExprResult Parser::ParseSimpleAsm() {
+Parser::OwningExprResult Parser::ParseSimpleAsm() {
assert(Tok.is(tok::kw_asm) && "Not an asm!");
SourceLocation Loc = ConsumeToken();
if (Tok.isNot(tok::l_paren)) {
Diag(Tok, diag::err_expected_lparen_after) << "asm";
- return true;
+ return OwningExprResult(true);
}
ConsumeParen();
- OwningExprResult Result(Actions, ParseAsmStringLiteral());
+ OwningExprResult Result(ParseAsmStringLiteral());
if (Result.isInvalid())
SkipUntil(tok::r_paren);
else
MatchRHSPunctuation(tok::r_paren, Loc);
- return Result.move();
+ return move(Result);
}
/// TryAnnotateTypeOrScopeToken - If the current token position is on a