diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-02-05 15:02:23 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-02-05 15:02:23 +0000 |
commit | 76ad2e85575722e8a38a2bd4648ab4304d9fcd24 (patch) | |
tree | 4fd48aba612cba8567f0e3014a8b76236f76d1dc /lib | |
parent | 0defd76d0b73c4866f1d5f71a274bf125fafd446 (diff) |
Put the invalid flag of OwningResult into the Action pointer.
This shrinks OwningResult by one pointer. Since it is no longer larger than OwningPtr, merge the two.
This leads to simpler client code and speeds up my benchmark by 2.7%.
For some reason, this exposes a previously hidden bug, causing a regression in SemaCXX/condition.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63867 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 2 | ||||
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 35 | ||||
-rw-r--r-- | lib/Parse/ParseInit.cpp | 2 | ||||
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 22 | ||||
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 52 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 2 |
6 files changed, 54 insertions, 61 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index e2601b6cf4..bbd5d4bb86 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -312,7 +312,7 @@ ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) { SkipUntil(tok::semi); return 0; } - Actions.AddInitializerToDecl(LastDeclInGroup, move_arg(Init)); + Actions.AddInitializerToDecl(LastDeclInGroup, move(Init)); } else if (Tok.is(tok::l_paren)) { // Parse C++ direct initializer: '(' expression-list ')' SourceLocation LParenLoc = ConsumeParen(); diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index d20f294bc6..597c50c08a 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -205,7 +205,7 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) { if (LHS.isInvalid()) return move(LHS); LHS = Actions.ActOnUnaryOp(CurScope, ExtLoc, tok::kw___extension__, - move_arg(LHS)); + move(LHS)); if (LHS.isInvalid()) return move(LHS); return ParseRHSOfBinaryExpression(move(LHS), prec::Comma); @@ -334,12 +334,11 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, unsigned MinPrec) { // Combine the LHS and RHS into the LHS (e.g. build AST). if (TernaryMiddle.isInvalid()) LHS = Actions.ActOnBinOp(CurScope, OpToken.getLocation(), - OpToken.getKind(), move_arg(LHS), - move_arg(RHS)); + OpToken.getKind(), move(LHS), move(RHS)); else LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc, - move_arg(LHS), move_arg(TernaryMiddle), - move_arg(RHS)); + move(LHS), move(TernaryMiddle), + move(RHS)); } } } @@ -493,8 +492,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression, // TODO: For cast expression with CastTy. Res = ParseCastExpression(false); if (!Res.isInvalid()) - Res = Actions.ActOnCastExpr(LParenLoc, CastTy, RParenLoc, - move_arg(Res)); + Res = Actions.ActOnCastExpr(LParenLoc, CastTy, RParenLoc, move(Res)); return move(Res); } @@ -570,7 +568,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression, SourceLocation SavedLoc = ConsumeToken(); Res = ParseCastExpression(true); if (!Res.isInvalid()) - Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, move_arg(Res)); + Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, move(Res)); return move(Res); } case tok::amp: { // unary-expression: '&' cast-expression @@ -578,7 +576,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression, SourceLocation SavedLoc = ConsumeToken(); Res = ParseCastExpression(false, true); if (!Res.isInvalid()) - Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, move_arg(Res)); + Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, move(Res)); return move(Res); } @@ -592,7 +590,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression, SourceLocation SavedLoc = ConsumeToken(); Res = ParseCastExpression(false); if (!Res.isInvalid()) - Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, move_arg(Res)); + Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, move(Res)); return move(Res); } @@ -602,7 +600,7 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression, SourceLocation SavedLoc = ConsumeToken(); Res = ParseCastExpression(false); if (!Res.isInvalid()) - Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, move_arg(Res)); + Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, move(Res)); return move(Res); } case tok::kw_sizeof: // unary-expression: 'sizeof' unary-expression @@ -765,8 +763,8 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) { SourceLocation RLoc = Tok.getLocation(); if (!LHS.isInvalid() && !Idx.isInvalid() && Tok.is(tok::r_square)) { - LHS = Actions.ActOnArraySubscriptExpr(CurScope, move_arg(LHS), Loc, - move_arg(Idx), RLoc); + LHS = Actions.ActOnArraySubscriptExpr(CurScope, move(LHS), Loc, + move(Idx), RLoc); } else LHS = ExprError(); @@ -792,7 +790,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) { 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, move_arg(LHS), Loc, + LHS = Actions.ActOnCallExpr(CurScope, move(LHS), Loc, move_arg(ArgExprs), &CommaLocs[0], Tok.getLocation()); } @@ -811,7 +809,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) { } if (!LHS.isInvalid()) { - LHS = Actions.ActOnMemberReferenceExpr(CurScope, move_arg(LHS), OpLoc, + LHS = Actions.ActOnMemberReferenceExpr(CurScope, move(LHS), OpLoc, OpKind, Tok.getLocation(), *Tok.getIdentifierInfo()); } @@ -822,7 +820,7 @@ Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) { case tok::minusminus: // postfix-expression: postfix-expression '--' if (!LHS.isInvalid()) { LHS = Actions.ActOnPostfixUnaryOp(CurScope, Tok.getLocation(), - Tok.getKind(), move_arg(LHS)); + Tok.getKind(), move(LHS)); } ConsumeToken(); break; @@ -1128,7 +1126,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, ExprType = CompoundLiteral; if (!Result.isInvalid()) return Actions.ActOnCompoundLiteral(OpenLoc, Ty, RParenLoc, - move_arg(Result)); + move(Result)); return move(Result); } @@ -1146,8 +1144,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, Result = ParseExpression(); ExprType = SimpleExpr; if (!Result.isInvalid() && Tok.is(tok::r_paren)) - Result = Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), - move_arg(Result)); + Result = Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), move(Result)); } // Match the ')'. diff --git a/lib/Parse/ParseInit.cpp b/lib/Parse/ParseInit.cpp index ec8470cb45..0b34feaedb 100644 --- a/lib/Parse/ParseInit.cpp +++ b/lib/Parse/ParseInit.cpp @@ -174,7 +174,7 @@ ParseInitializerWithPotentialDesignator(InitListDesignations &Designations, return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, SourceLocation(), - 0, move_arg(Idx)); + 0, move(Idx)); } // Create designation if we haven't already. diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 5d7d7f1000..f45562644f 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1202,7 +1202,7 @@ Parser::OwningStmtResult Parser::ParseObjCThrowStmt(SourceLocation atLoc) { } } ConsumeToken(); // consume ';' - return Actions.ActOnObjCAtThrowStmt(atLoc, move_arg(Res)); + return Actions.ActOnObjCAtThrowStmt(atLoc, move(Res)); } /// objc-synchronized-statement: @@ -1239,8 +1239,7 @@ Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) { BodyScope.Exit(); if (SynchBody.isInvalid()) SynchBody = Actions.ActOnNullStmt(Tok.getLocation()); - return Actions.ActOnObjCAtSynchronizedStmt(atLoc, move_arg(Res), - move_arg(SynchBody)); + return Actions.ActOnObjCAtSynchronizedStmt(atLoc, move(Res), move(SynchBody)); } /// objc-try-catch-statement: @@ -1313,8 +1312,8 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { if (CatchBody.isInvalid()) CatchBody = Actions.ActOnNullStmt(Tok.getLocation()); CatchStmts = Actions.ActOnObjCAtCatchStmt(AtCatchFinallyLoc, - RParenLoc, move_arg(FirstPart), move_arg(CatchBody), - move_arg(CatchStmts)); + RParenLoc, move(FirstPart), move(CatchBody), + move(CatchStmts)); } else { Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after) << "@catch clause"; @@ -1334,7 +1333,7 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { if (FinallyBody.isInvalid()) FinallyBody = Actions.ActOnNullStmt(Tok.getLocation()); FinallyStmt = Actions.ActOnObjCAtFinallyStmt(AtCatchFinallyLoc, - move_arg(FinallyBody)); + move(FinallyBody)); catch_or_finally_seen = true; break; } @@ -1343,9 +1342,8 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { Diag(atLoc, diag::err_missing_catch_finally); return StmtError(); } - return Actions.ActOnObjCAtTryStmt(atLoc, move_arg(TryBody), - move_arg(CatchStmts), - move_arg(FinallyStmt)); + return Actions.ActOnObjCAtTryStmt(atLoc, move(TryBody), move(CatchStmts), + move(FinallyStmt)); } /// objc-method-def: objc-method-proto ';'[opt] '{' body '}' @@ -1387,7 +1385,7 @@ Parser::DeclTy *Parser::ParseObjCMethodDefinition() { BodyScope.Exit(); // TODO: Pass argument information. - Actions.ActOnFinishFunctionBody(MDecl, move_arg(FnBody)); + Actions.ActOnFinishFunctionBody(MDecl, move(FnBody)); return MDecl; } @@ -1408,7 +1406,7 @@ Parser::OwningStmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc) { } // Otherwise, eat the semicolon. ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr); - return Actions.ActOnExprStmt(move_arg(Res)); + return Actions.ActOnExprStmt(move(Res)); } Parser::OwningExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { @@ -1459,7 +1457,7 @@ Parser::OwningExprResult Parser::ParseObjCMessageExpression() { } return ParseObjCMessageExpressionBody(LBracLoc, SourceLocation(), - 0, move_arg(Res)); + 0, move(Res)); } /// ParseObjCMessageExpressionBody - Having parsed "'[' objc-receiver", parse diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 5ff09052f5..a8303997f7 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -118,7 +118,7 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) { } // Otherwise, eat the semicolon. ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr); - return Actions.ActOnExprStmt(move_arg(Expr)); + return Actions.ActOnExprStmt(move(Expr)); } case tok::kw_case: // C99 6.8.1: labeled-statement @@ -217,7 +217,7 @@ Parser::OwningStmtResult Parser::ParseLabeledStatement() { return Actions.ActOnLabelStmt(IdentTok.getLocation(), IdentTok.getIdentifierInfo(), - ColonLoc, move_arg(SubStmt)); + ColonLoc, move(SubStmt)); } /// ParseCaseStatement @@ -271,8 +271,8 @@ Parser::OwningStmtResult Parser::ParseCaseStatement() { if (SubStmt.isInvalid()) SubStmt = Actions.ActOnNullStmt(ColonLoc); - return Actions.ActOnCaseStmt(CaseLoc, move_arg(LHS), DotDotDotLoc, - move_arg(RHS), ColonLoc, move_arg(SubStmt)); + return Actions.ActOnCaseStmt(CaseLoc, move(LHS), DotDotDotLoc, + move(RHS), ColonLoc, move(SubStmt)); } /// ParseDefaultStatement @@ -303,7 +303,7 @@ Parser::OwningStmtResult Parser::ParseDefaultStatement() { return StmtError(); return Actions.ActOnDefaultStmt(DefaultLoc, ColonLoc, - move_arg(SubStmt), CurScope); + move(SubStmt), CurScope); } @@ -393,7 +393,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(move_arg(Res)); + R = Actions.ActOnExprStmt(move(Res)); } } @@ -568,8 +568,8 @@ Parser::OwningStmtResult Parser::ParseIfStatement() { if (ElseStmt.isInvalid()) ElseStmt = Actions.ActOnNullStmt(ElseStmtLoc); - return Actions.ActOnIfStmt(IfLoc, move_arg(CondExp), move_arg(ThenStmt), - ElseLoc, move_arg(ElseStmt)); + return Actions.ActOnIfStmt(IfLoc, move(CondExp), move(ThenStmt), + ElseLoc, move(ElseStmt)); } /// ParseSwitchStatement @@ -612,7 +612,7 @@ Parser::OwningStmtResult Parser::ParseSwitchStatement() { OwningStmtResult Switch(Actions); if (!Cond.isInvalid()) - Switch = Actions.ActOnStartOfSwitchStmt(move_arg(Cond)); + Switch = Actions.ActOnStartOfSwitchStmt(move(Cond)); // 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 @@ -644,8 +644,7 @@ Parser::OwningStmtResult Parser::ParseSwitchStatement() { if (Cond.isInvalid()) return StmtError(); - return Actions.ActOnFinishSwitchStmt(SwitchLoc, move_arg(Switch), - move_arg(Body)); + return Actions.ActOnFinishSwitchStmt(SwitchLoc, move(Switch), move(Body)); } /// ParseWhileStatement @@ -714,7 +713,7 @@ Parser::OwningStmtResult Parser::ParseWhileStatement() { if (Cond.isInvalid() || Body.isInvalid()) return StmtError(); - return Actions.ActOnWhileStmt(WhileLoc, move_arg(Cond), move_arg(Body)); + return Actions.ActOnWhileStmt(WhileLoc, move(Cond), move(Body)); } /// ParseDoStatement @@ -778,7 +777,7 @@ Parser::OwningStmtResult Parser::ParseDoStatement() { if (Cond.isInvalid() || Body.isInvalid()) return StmtError(); - return Actions.ActOnDoStmt(DoLoc, move_arg(Body), WhileLoc, move_arg(Cond)); + return Actions.ActOnDoStmt(DoLoc, move(Body), WhileLoc, move(Cond)); } /// ParseForStatement @@ -860,7 +859,7 @@ Parser::OwningStmtResult Parser::ParseForStatement() { // Turn the expression into a stmt. if (!Value.isInvalid()) - FirstPart = Actions.ActOnExprStmt(move_arg(Value)); + FirstPart = Actions.ActOnExprStmt(move(Value)); if (Tok.is(tok::semi)) { ConsumeToken(); @@ -927,14 +926,14 @@ Parser::OwningStmtResult Parser::ParseForStatement() { return StmtError(); if (!ForEach) - return Actions.ActOnForStmt(ForLoc, LParenLoc, move_arg(FirstPart), - move_arg(SecondPart), move_arg(ThirdPart), - RParenLoc, move_arg(Body)); + return Actions.ActOnForStmt(ForLoc, LParenLoc, move(FirstPart), + move(SecondPart), move(ThirdPart), + RParenLoc, move(Body)); else return Actions.ActOnObjCForCollectionStmt(ForLoc, LParenLoc, - move_arg(FirstPart), - move_arg(SecondPart), - RParenLoc, move_arg(Body)); + move(FirstPart), + move(SecondPart), + RParenLoc, move(Body)); } /// ParseGotoStatement @@ -962,7 +961,7 @@ Parser::OwningStmtResult Parser::ParseGotoStatement() { SkipUntil(tok::semi, false, true); return StmtError(); } - Res = Actions.ActOnIndirectGotoStmt(GotoLoc, StarLoc, move_arg(R)); + Res = Actions.ActOnIndirectGotoStmt(GotoLoc, StarLoc, move(R)); } else { Diag(Tok, diag::err_expected_ident); return StmtError(); @@ -1008,7 +1007,7 @@ Parser::OwningStmtResult Parser::ParseReturnStatement() { return StmtError(); } } - return Actions.ActOnReturnStmt(ReturnLoc, move_arg(R)); + return Actions.ActOnReturnStmt(ReturnLoc, move(R)); } /// FuzzyParseMicrosoftAsmStatement. When -fms-extensions is enabled, this @@ -1148,7 +1147,7 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) { return Actions.ActOnAsmStmt(AsmLoc, isSimple, isVolatile, NumOutputs, NumInputs, &Names[0], move_arg(Constraints), move_arg(Exprs), - move_arg(AsmString), move_arg(Clobbers), + move(AsmString), move_arg(Clobbers), RParenLoc); } @@ -1233,7 +1232,7 @@ Parser::DeclTy *Parser::ParseFunctionStatementBody(DeclTy *Decl, if (FnBody.isInvalid()) FnBody = Actions.ActOnCompoundStmt(L, R, MultiStmtArg(Actions), false); - return Actions.ActOnFinishFunctionBody(Decl, move_arg(FnBody)); + return Actions.ActOnFinishFunctionBody(Decl, move(FnBody)); } /// ParseCXXTryBlock - Parse a C++ try-block. @@ -1267,8 +1266,7 @@ Parser::OwningStmtResult Parser::ParseCXXTryBlock() { if (Handlers.empty()) return StmtError(); - return Actions.ActOnCXXTryBlock(TryLoc, move_arg(TryBlock), - move_arg(Handlers)); + return Actions.ActOnCXXTryBlock(TryLoc, move(TryBlock), move_arg(Handlers)); } /// ParseCXXCatchBlock - Parse a C++ catch block, called handler in the standard @@ -1319,5 +1317,5 @@ Parser::OwningStmtResult Parser::ParseCXXCatchBlock() { if (Block.isInvalid()) return move(Block); - return Actions.ActOnCXXCatchBlock(CatchLoc, ExceptionDecl, move_arg(Block)); + return Actions.ActOnCXXCatchBlock(CatchLoc, ExceptionDecl, move(Block)); } diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 2f7e2ea0fc..eb84a4a382 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -357,7 +357,7 @@ Parser::DeclTy *Parser::ParseExternalDeclaration() { "top-level asm block"); if (!Result.isInvalid()) - return Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), move_arg(Result)); + return Actions.ActOnFileScopeAsmDecl(Tok.getLocation(), move(Result)); return 0; } case tok::at: |