From: Chris Lattner Date: Tue, 9 Oct 2007 17:41:39 +0000 (+0000) Subject: switch more code to use Token::is/isNot where possible. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e1d99a8a4d2958f0858f4baac68066af2c5cf17;p=clang switch more code to use Token::is/isNot where possible. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42797 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Parse/ParseExpr.cpp b/Parse/ParseExpr.cpp index 1b261aae26..8a576edab0 100644 --- a/Parse/ParseExpr.cpp +++ b/Parse/ParseExpr.cpp @@ -214,7 +214,7 @@ ParseExpressionWithLeadingIdentifier(const Token &IdTok) { // Let the actions module handle the identifier. ExprResult Res = Actions.ActOnIdentifierExpr(CurScope, IdTok.getLocation(), *IdTok.getIdentifierInfo(), - Tok.getKind() == tok::l_paren); + Tok.is(tok::l_paren)); // Because we have to parse an entire cast-expression before starting the // ParseRHSOfBinaryExpression method (which parses any trailing binops), we @@ -245,7 +245,7 @@ ParseAssignmentExprWithLeadingIdentifier(const Token &IdTok) { // Let the actions module handle the identifier. ExprResult Res = Actions.ActOnIdentifierExpr(CurScope, IdTok.getLocation(), *IdTok.getIdentifierInfo(), - Tok.getKind() == tok::l_paren); + Tok.is(tok::l_paren)); // Because we have to parse an entire cast-expression before starting the // ParseRHSOfBinaryExpression method (which parses any trailing binops), we @@ -321,7 +321,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec) { // Special case handling for the ternary operator. ExprResult TernaryMiddle(true); if (NextTokPrec == prec::Conditional) { - if (Tok.getKind() != tok::colon) { + if (Tok.isNot(tok::colon)) { // Handle this production specially: // logical-OR-expression '?' expression ':' conditional-expression // In particular, the RHS of the '?' is 'expression', not @@ -338,7 +338,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec) { Diag(Tok, diag::ext_gnu_conditional_expr); } - if (Tok.getKind() != tok::colon) { + if (Tok.isNot(tok::colon)) { Diag(Tok, diag::err_expected_colon); Diag(OpToken, diag::err_matching, "?"); Actions.DeleteExpr(LHS.Val); @@ -525,8 +525,7 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) { // not. IdentifierInfo &II = *Tok.getIdentifierInfo(); SourceLocation L = ConsumeToken(); - Res = Actions.ActOnIdentifierExpr(CurScope, L, II, - Tok.getKind() == tok::l_paren); + Res = Actions.ActOnIdentifierExpr(CurScope, L, II, Tok.is(tok::l_paren)); // These can be followed by postfix-expr pieces. return ParsePostfixExpressionSuffix(Res); } @@ -584,7 +583,7 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) { return ParseSizeofAlignofExpression(); case tok::ampamp: { // unary-expression: '&&' identifier SourceLocation AmpAmpLoc = ConsumeToken(); - if (Tok.getKind() != tok::identifier) { + if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected_ident); return ExprResult(true); } @@ -648,7 +647,7 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { SourceLocation RLoc = Tok.getLocation(); - if (!LHS.isInvalid && !Idx.isInvalid && Tok.getKind() == tok::r_square) + if (!LHS.isInvalid && !Idx.isInvalid && Tok.is(tok::r_square)) LHS = Actions.ActOnArraySubscriptExpr(LHS.Val, Loc, Idx.Val, RLoc); else LHS = ExprResult(true); @@ -664,7 +663,7 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { Loc = ConsumeParen(); - if (Tok.getKind() != tok::r_paren) { + if (Tok.isNot(tok::r_paren)) { while (1) { ExprResult ArgExpr = ParseAssignmentExpression(); if (ArgExpr.isInvalid) { @@ -673,7 +672,7 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { } else ArgExprs.push_back(ArgExpr.Val); - if (Tok.getKind() != tok::comma) + if (Tok.isNot(tok::comma)) break; // Move to the next argument, remember where the comma was. CommaLocs.push_back(ConsumeToken()); @@ -681,7 +680,7 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { } // Match the ')'. - if (!LHS.isInvalid && Tok.getKind() == tok::r_paren) { + if (!LHS.isInvalid && Tok.is(tok::r_paren)) { assert((ArgExprs.size() == 0 || ArgExprs.size()-1 == CommaLocs.size())&& "Unexpected number of commas!"); LHS = Actions.ActOnCallExpr(LHS.Val, Loc, &ArgExprs[0], ArgExprs.size(), @@ -696,7 +695,7 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { tok::TokenKind OpKind = Tok.getKind(); SourceLocation OpLoc = ConsumeToken(); // Eat the "." or "->" token. - if (Tok.getKind() != tok::identifier) { + if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected_ident); return ExprResult(true); } @@ -727,15 +726,14 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { /// [GNU] '__alignof' unary-expression /// [GNU] '__alignof' '(' type-name ')' Parser::ExprResult Parser::ParseSizeofAlignofExpression() { - assert((Tok.getKind() == tok::kw_sizeof || - Tok.getKind() == tok::kw___alignof) && + assert((Tok.is(tok::kw_sizeof) || Tok.is(tok::kw___alignof)) && "Not a sizeof/alignof expression!"); Token OpTok = Tok; ConsumeToken(); // If the operand doesn't start with an '(', it must be an expression. ExprResult Operand; - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { Operand = ParseCastExpression(true); } else { // If it starts with a '(', we know that it is either a parenthesized @@ -751,7 +749,7 @@ Parser::ExprResult Parser::ParseSizeofAlignofExpression() { // sizeof/alignof a type. Otherwise, it is sizeof/alignof an expression. if (ExprType == CastExpr) { return Actions.ActOnSizeOfAlignOfTypeExpr(OpTok.getLocation(), - OpTok.getKind() == tok::kw_sizeof, + OpTok.is(tok::kw_sizeof), LParenLoc, CastTy, RParenLoc); } } @@ -785,7 +783,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() { SourceLocation StartLoc = ConsumeToken(); // Eat the builtin identifier. // All of these start with an open paren. - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { Diag(Tok, diag::err_expected_lparen_after, BuiltinII->getName()); return ExprResult(true); } @@ -818,7 +816,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() { return ExprResult(true); // We must have at least one identifier here. - if (Tok.getKind() != tok::identifier) { + if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected_ident); SkipUntil(tok::r_paren); return true; @@ -833,13 +831,13 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() { Comps.back().LocStart = Comps.back().LocEnd = ConsumeToken(); while (1) { - if (Tok.getKind() == tok::period) { + if (Tok.is(tok::period)) { // offsetof-member-designator: offsetof-member-designator '.' identifier Comps.push_back(Action::OffsetOfComponent()); Comps.back().isBrackets = false; Comps.back().LocStart = ConsumeToken(); - if (Tok.getKind() != tok::identifier) { + if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected_ident); SkipUntil(tok::r_paren); return true; @@ -847,7 +845,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() { Comps.back().U.IdentInfo = Tok.getIdentifierInfo(); Comps.back().LocEnd = ConsumeToken(); - } else if (Tok.getKind() == tok::l_square) { + } else if (Tok.is(tok::l_square)) { // offsetof-member-designator: offsetof-member-design '[' expression ']' Comps.push_back(Action::OffsetOfComponent()); Comps.back().isBrackets = true; @@ -861,7 +859,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() { Comps.back().LocEnd = MatchRHSPunctuation(tok::r_square, Comps.back().LocStart); - } else if (Tok.getKind() == tok::r_paren) { + } else if (Tok.is(tok::r_paren)) { Res = Actions.ActOnBuiltinOffsetOf(StartLoc, TypeLoc, Ty, &Comps[0], Comps.size(), ConsumeParen()); break; @@ -894,7 +892,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() { SkipUntil(tok::r_paren); return Expr2; } - if (Tok.getKind() != tok::r_paren) { + if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_expected_rparen); return ExprResult(true); } @@ -910,7 +908,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() { TypeTy *Ty2 = ParseTypeName(); - if (Tok.getKind() != tok::r_paren) { + if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_expected_rparen); return ExprResult(true); } @@ -939,18 +937,18 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() { Parser::ExprResult Parser::ParseParenExpression(ParenParseOption &ExprType, TypeTy *&CastTy, SourceLocation &RParenLoc) { - assert(Tok.getKind() == tok::l_paren && "Not a paren expr!"); + assert(Tok.is(tok::l_paren) && "Not a paren expr!"); SourceLocation OpenLoc = ConsumeParen(); ExprResult Result(true); CastTy = 0; - if (ExprType >= CompoundStmt && Tok.getKind() == tok::l_brace) { + if (ExprType >= CompoundStmt && Tok.is(tok::l_brace)) { Diag(Tok, diag::ext_gnu_statement_expr); Parser::StmtResult Stmt = ParseCompoundStatement(true); ExprType = CompoundStmt; // If the substmt parsed correctly, build the AST node. - if (!Stmt.isInvalid && Tok.getKind() == tok::r_paren) + if (!Stmt.isInvalid && Tok.is(tok::r_paren)) Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.Val, Tok.getLocation()); } else if (ExprType >= CompoundLiteral && isTypeSpecifierQualifier()) { @@ -958,12 +956,12 @@ Parser::ExprResult Parser::ParseParenExpression(ParenParseOption &ExprType, TypeTy *Ty = ParseTypeName(); // Match the ')'. - if (Tok.getKind() == tok::r_paren) + if (Tok.is(tok::r_paren)) RParenLoc = ConsumeParen(); else MatchRHSPunctuation(tok::r_paren, OpenLoc); - if (Tok.getKind() == tok::l_brace) { + if (Tok.is(tok::l_brace)) { if (!getLang().C99) // Compound literals don't exist in C90. Diag(OpenLoc, diag::ext_c99_compound_literal); Result = ParseInitializer(); @@ -984,7 +982,7 @@ Parser::ExprResult Parser::ParseParenExpression(ParenParseOption &ExprType, } else { Result = ParseExpression(); ExprType = SimpleExpr; - if (!Result.isInvalid && Tok.getKind() == tok::r_paren) + if (!Result.isInvalid && Tok.is(tok::r_paren)) Result = Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), Result.Val); } @@ -992,7 +990,7 @@ Parser::ExprResult Parser::ParseParenExpression(ParenParseOption &ExprType, if (Result.isInvalid) SkipUntil(tok::r_paren); else { - if (Tok.getKind() == tok::r_paren) + if (Tok.is(tok::r_paren)) RParenLoc = ConsumeParen(); else MatchRHSPunctuation(tok::r_paren, OpenLoc); diff --git a/Parse/ParseExprCXX.cpp b/Parse/ParseExprCXX.cpp index 192172d242..1fc456e2d3 100644 --- a/Parse/ParseExprCXX.cpp +++ b/Parse/ParseExprCXX.cpp @@ -52,7 +52,7 @@ Parser::ExprResult Parser::ParseCXXCasts() { SourceLocation LParenLoc = Tok.getLocation(), RParenLoc; - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { Diag(Tok, diag::err_expected_lparen_after, CastName); return ExprResult(true); } diff --git a/Parse/ParseStmt.cpp b/Parse/ParseStmt.cpp index 7dc6a62e84..ad6f3932f6 100644 --- a/Parse/ParseStmt.cpp +++ b/Parse/ParseStmt.cpp @@ -107,7 +107,7 @@ Parser::StmtResult Parser::ParseStatementOrDeclaration(bool OnlyStatement) { default: if (!OnlyStatement && isDeclarationSpecifier()) { return Actions.ActOnDeclStmt(ParseDeclaration(Declarator::BlockContext)); - } else if (Tok.getKind() == tok::r_brace) { + } else if (Tok.is(tok::r_brace)) { Diag(Tok, diag::err_expected_statement); return true; } else { @@ -173,7 +173,7 @@ Parser::StmtResult Parser::ParseStatementOrDeclaration(bool OnlyStatement) { } // If we reached this code, the statement must end in a semicolon. - if (Tok.getKind() == tok::semi) { + if (Tok.is(tok::semi)) { ConsumeToken(); } else { Diag(Tok, diag::err_expected_semi_after, SemiError); @@ -195,19 +195,19 @@ Parser::StmtResult Parser::ParseStatementOrDeclaration(bool OnlyStatement) { /// expression[opt] ';' /// Parser::StmtResult Parser::ParseIdentifierStatement(bool OnlyStatement) { - assert(Tok.getKind() == tok::identifier && Tok.getIdentifierInfo() && + assert(Tok.is(tok::identifier) && Tok.getIdentifierInfo() && "Not an identifier!"); Token IdentTok = Tok; // Save the whole token. ConsumeToken(); // eat the identifier. // identifier ':' statement - if (Tok.getKind() == tok::colon) { + if (Tok.is(tok::colon)) { SourceLocation ColonLoc = ConsumeToken(); // Read label attributes, if present. DeclTy *AttrList = 0; - if (Tok.getKind() == tok::kw___attribute) + if (Tok.is(tok::kw___attribute)) // TODO: save these somewhere. AttrList = ParseAttributes(); @@ -241,7 +241,7 @@ Parser::StmtResult Parser::ParseIdentifierStatement(bool OnlyStatement) { // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };" // declaration-specifiers init-declarator-list[opt] ';' - if (Tok.getKind() == tok::semi) { + if (Tok.is(tok::semi)) { // TODO: emit error on 'int;' or 'const enum foo;'. // if (!DS.isMissingDeclaratorOk()) Diag(...); @@ -263,7 +263,7 @@ Parser::StmtResult Parser::ParseIdentifierStatement(bool OnlyStatement) { if (Res.isInvalid) { SkipUntil(tok::semi); return true; - } else if (Tok.getKind() != tok::semi) { + } else if (Tok.isNot(tok::semi)) { Diag(Tok, diag::err_expected_semi_after, "expression"); SkipUntil(tok::semi); return true; @@ -282,7 +282,7 @@ Parser::StmtResult Parser::ParseIdentifierStatement(bool OnlyStatement) { /// Note that this does not parse the 'statement' at the end. /// Parser::StmtResult Parser::ParseCaseStatement() { - assert(Tok.getKind() == tok::kw_case && "Not a case stmt!"); + assert(Tok.is(tok::kw_case) && "Not a case stmt!"); SourceLocation CaseLoc = ConsumeToken(); // eat the 'case'. ExprResult LHS = ParseConstantExpression(); @@ -294,7 +294,7 @@ Parser::StmtResult Parser::ParseCaseStatement() { // GNU case range extension. SourceLocation DotDotDotLoc; ExprTy *RHSVal = 0; - if (Tok.getKind() == tok::ellipsis) { + if (Tok.is(tok::ellipsis)) { Diag(Tok, diag::ext_gnu_case_range); DotDotDotLoc = ConsumeToken(); @@ -306,7 +306,7 @@ Parser::StmtResult Parser::ParseCaseStatement() { RHSVal = RHS.Val; } - if (Tok.getKind() != tok::colon) { + if (Tok.isNot(tok::colon)) { Diag(Tok, diag::err_expected_colon_after, "'case'"); SkipUntil(tok::colon); return true; @@ -315,7 +315,7 @@ Parser::StmtResult Parser::ParseCaseStatement() { SourceLocation ColonLoc = ConsumeToken(); // Diagnose the common error "switch (X) { case 4: }", which is not valid. - if (Tok.getKind() == tok::r_brace) { + if (Tok.is(tok::r_brace)) { Diag(Tok, diag::err_label_end_of_compound_statement); return true; } @@ -336,10 +336,10 @@ Parser::StmtResult Parser::ParseCaseStatement() { /// Note that this does not parse the 'statement' at the end. /// Parser::StmtResult Parser::ParseDefaultStatement() { - assert(Tok.getKind() == tok::kw_default && "Not a default stmt!"); + assert(Tok.is(tok::kw_default) && "Not a default stmt!"); SourceLocation DefaultLoc = ConsumeToken(); // eat the 'default'. - if (Tok.getKind() != tok::colon) { + if (Tok.isNot(tok::colon)) { Diag(Tok, diag::err_expected_colon_after, "'default'"); SkipUntil(tok::colon); return true; @@ -348,7 +348,7 @@ Parser::StmtResult Parser::ParseDefaultStatement() { SourceLocation ColonLoc = ConsumeToken(); // Diagnose the common error "switch (X) {... default: }", which is not valid. - if (Tok.getKind() == tok::r_brace) { + if (Tok.is(tok::r_brace)) { Diag(Tok, diag::err_label_end_of_compound_statement); return true; } @@ -389,7 +389,7 @@ Parser::StmtResult Parser::ParseDefaultStatement() { /// [OMP] flush-directive /// Parser::StmtResult Parser::ParseCompoundStatement(bool isStmtExpr) { - assert(Tok.getKind() == tok::l_brace && "Not a compount stmt!"); + assert(Tok.is(tok::l_brace) && "Not a compount stmt!"); // Enter a scope to hold everything within the compound stmt. Compound // statements can always hold declarations. @@ -414,16 +414,16 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { // only allowed at the start of a compound stmt regardless of the language. llvm::SmallVector Stmts; - while (Tok.getKind() != tok::r_brace && Tok.getKind() != tok::eof) { + while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) { StmtResult R; - if (Tok.getKind() != tok::kw___extension__) { + if (Tok.isNot(tok::kw___extension__)) { R = ParseStatementOrDeclaration(false); } else { // __extension__ can start declarations and it can also be a unary // operator for expressions. Consume multiple __extension__ markers here // until we can determine which is which. SourceLocation ExtLoc = ConsumeToken(); - while (Tok.getKind() == tok::kw___extension__) + while (Tok.is(tok::kw___extension__)) ConsumeToken(); // If this is the start of a declaration, parse it as such. @@ -457,7 +457,7 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { } // We broke out of the while loop because we found a '}' or EOF. - if (Tok.getKind() != tok::r_brace) { + if (Tok.isNot(tok::r_brace)) { Diag(Tok, diag::err_expected_rbrace); return 0; } @@ -473,10 +473,10 @@ Parser::StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { /// 'if' '(' expression ')' statement 'else' statement /// Parser::StmtResult Parser::ParseIfStatement() { - assert(Tok.getKind() == tok::kw_if && "Not an if stmt!"); + assert(Tok.is(tok::kw_if) && "Not an if stmt!"); SourceLocation IfLoc = ConsumeToken(); // eat the 'if'. - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { Diag(Tok, diag::err_expected_lparen_after, "if"); SkipUntil(tok::semi); return true; @@ -499,7 +499,7 @@ Parser::StmtResult Parser::ParseIfStatement() { // 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 // if the body isn't a compound statement to avoid push/pop in common cases. - bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace; + bool NeedsInnerScope = getLang().C99 && Tok.isNot(tok::l_brace); if (NeedsInnerScope) EnterScope(Scope::DeclScope); // Read the if condition. @@ -515,14 +515,14 @@ Parser::StmtResult Parser::ParseIfStatement() { // If it has an else, parse it. SourceLocation ElseLoc; StmtResult ElseStmt(false); - if (Tok.getKind() == tok::kw_else) { + if (Tok.is(tok::kw_else)) { ElseLoc = ConsumeToken(); // 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 if the body isn't a compound statement to avoid push/pop in common // cases. - NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace; + NeedsInnerScope = getLang().C99 && Tok.isNot(tok::l_brace); if (NeedsInnerScope) EnterScope(Scope::DeclScope); ElseStmt = ParseStatement(); @@ -545,10 +545,10 @@ Parser::StmtResult Parser::ParseIfStatement() { /// switch-statement: /// 'switch' '(' expression ')' statement Parser::StmtResult Parser::ParseSwitchStatement() { - assert(Tok.getKind() == tok::kw_switch && "Not a switch stmt!"); + assert(Tok.is(tok::kw_switch) && "Not a switch stmt!"); SourceLocation SwitchLoc = ConsumeToken(); // eat the 'switch'. - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { Diag(Tok, diag::err_expected_lparen_after, "switch"); SkipUntil(tok::semi); return true; @@ -574,7 +574,7 @@ Parser::StmtResult Parser::ParseSwitchStatement() { // 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 // if the body isn't a compound statement to avoid push/pop in common cases. - bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace; + bool NeedsInnerScope = getLang().C99 && Tok.isNot(tok::l_brace); if (NeedsInnerScope) EnterScope(Scope::DeclScope); // Read the body statement. @@ -597,11 +597,11 @@ Parser::StmtResult Parser::ParseSwitchStatement() { /// while-statement: [C99 6.8.5.1] /// 'while' '(' expression ')' statement Parser::StmtResult Parser::ParseWhileStatement() { - assert(Tok.getKind() == tok::kw_while && "Not a while stmt!"); + assert(Tok.is(tok::kw_while) && "Not a while stmt!"); SourceLocation WhileLoc = Tok.getLocation(); ConsumeToken(); // eat the 'while'. - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { Diag(Tok, diag::err_expected_lparen_after, "while"); SkipUntil(tok::semi); return true; @@ -620,7 +620,7 @@ Parser::StmtResult Parser::ParseWhileStatement() { // 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 // if the body isn't a compound statement to avoid push/pop in common cases. - bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace; + bool NeedsInnerScope = getLang().C99 && Tok.isNot(tok::l_brace); if (NeedsInnerScope) EnterScope(Scope::DeclScope); // Read the body statement. @@ -641,7 +641,7 @@ Parser::StmtResult Parser::ParseWhileStatement() { /// 'do' statement 'while' '(' expression ')' ';' /// Note: this lets the caller parse the end ';'. Parser::StmtResult Parser::ParseDoStatement() { - assert(Tok.getKind() == tok::kw_do && "Not a do stmt!"); + assert(Tok.is(tok::kw_do) && "Not a do stmt!"); SourceLocation DoLoc = ConsumeToken(); // eat the 'do'. // C99 6.8.5p5 - In C99, the do statement is a block. This is not @@ -654,7 +654,7 @@ Parser::StmtResult Parser::ParseDoStatement() { // 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 // if the body isn't a compound statement to avoid push/pop in common cases. - bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace; + bool NeedsInnerScope = getLang().C99 && Tok.isNot(tok::l_brace); if (NeedsInnerScope) EnterScope(Scope::DeclScope); // Read the body statement. @@ -663,7 +663,7 @@ Parser::StmtResult Parser::ParseDoStatement() { // Pop the body scope if needed. if (NeedsInnerScope) ExitScope(); - if (Tok.getKind() != tok::kw_while) { + if (Tok.isNot(tok::kw_while)) { ExitScope(); Diag(Tok, diag::err_expected_while); Diag(DoLoc, diag::err_matching, "do"); @@ -672,7 +672,7 @@ Parser::StmtResult Parser::ParseDoStatement() { } SourceLocation WhileLoc = ConsumeToken(); - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { ExitScope(); Diag(Tok, diag::err_expected_lparen_after, "do/while"); SkipUntil(tok::semi); @@ -694,10 +694,10 @@ Parser::StmtResult Parser::ParseDoStatement() { /// 'for' '(' expr[opt] ';' expr[opt] ';' expr[opt] ')' statement /// 'for' '(' declaration expr[opt] ';' expr[opt] ')' statement Parser::StmtResult Parser::ParseForStatement() { - assert(Tok.getKind() == tok::kw_for && "Not a for stmt!"); + assert(Tok.is(tok::kw_for) && "Not a for stmt!"); SourceLocation ForLoc = ConsumeToken(); // eat the 'for'. - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { Diag(Tok, diag::err_expected_lparen_after, "for"); SkipUntil(tok::semi); return true; @@ -718,7 +718,7 @@ Parser::StmtResult Parser::ParseForStatement() { StmtTy *ThirdPart = 0; // Parse the first part of the for specifier. - if (Tok.getKind() == tok::semi) { // for (; + if (Tok.is(tok::semi)) { // for (; // no first part, eat the ';'. ConsumeToken(); } else if (isDeclarationSpecifier()) { // for (int X = 4; @@ -738,7 +738,7 @@ Parser::StmtResult Parser::ParseForStatement() { FirstPart = R.Val; } - if (Tok.getKind() == tok::semi) { + if (Tok.is(tok::semi)) { ConsumeToken(); } else { if (!Value.isInvalid) Diag(Tok, diag::err_expected_semi_for); @@ -747,7 +747,7 @@ Parser::StmtResult Parser::ParseForStatement() { } // Parse the second part of the for specifier. - if (Tok.getKind() == tok::semi) { // for (...;; + if (Tok.is(tok::semi)) { // for (...;; // no second part. Value = ExprResult(); } else { @@ -756,7 +756,7 @@ Parser::StmtResult Parser::ParseForStatement() { SecondPart = Value.Val; } - if (Tok.getKind() == tok::semi) { + if (Tok.is(tok::semi)) { ConsumeToken(); } else { if (!Value.isInvalid) Diag(Tok, diag::err_expected_semi_for); @@ -764,7 +764,7 @@ Parser::StmtResult Parser::ParseForStatement() { } // Parse the third part of the for specifier. - if (Tok.getKind() == tok::r_paren) { // for (...;...;) + if (Tok.is(tok::r_paren)) { // for (...;...;) // no third part. Value = ExprResult(); } else { @@ -783,7 +783,7 @@ Parser::StmtResult Parser::ParseForStatement() { // 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 // if the body isn't a compound statement to avoid push/pop in common cases. - bool NeedsInnerScope = getLang().C99 && Tok.getKind() != tok::l_brace; + bool NeedsInnerScope = getLang().C99 && Tok.isNot(tok::l_brace); if (NeedsInnerScope) EnterScope(Scope::DeclScope); // Read the body statement. @@ -810,15 +810,15 @@ Parser::StmtResult Parser::ParseForStatement() { /// Note: this lets the caller parse the end ';'. /// Parser::StmtResult Parser::ParseGotoStatement() { - assert(Tok.getKind() == tok::kw_goto && "Not a goto stmt!"); + assert(Tok.is(tok::kw_goto) && "Not a goto stmt!"); SourceLocation GotoLoc = ConsumeToken(); // eat the 'goto'. StmtResult Res; - if (Tok.getKind() == tok::identifier) { + if (Tok.is(tok::identifier)) { Res = Actions.ActOnGotoStmt(GotoLoc, Tok.getLocation(), Tok.getIdentifierInfo()); ConsumeToken(); - } else if (Tok.getKind() == tok::star && !getLang().NoExtensions) { + } else if (Tok.is(tok::star) && !getLang().NoExtensions) { // GNU indirect goto extension. Diag(Tok, diag::ext_gnu_indirect_goto); SourceLocation StarLoc = ConsumeToken(); @@ -862,11 +862,11 @@ Parser::StmtResult Parser::ParseBreakStatement() { /// jump-statement: /// 'return' expression[opt] ';' Parser::StmtResult Parser::ParseReturnStatement() { - assert(Tok.getKind() == tok::kw_return && "Not a return stmt!"); + assert(Tok.is(tok::kw_return) && "Not a return stmt!"); SourceLocation ReturnLoc = ConsumeToken(); // eat the 'return'. ExprResult R(0); - if (Tok.getKind() != tok::semi) { + if (Tok.isNot(tok::semi)) { R = ParseExpression(); if (R.isInvalid) { // Skip to the semicolon, but don't consume it. SkipUntil(tok::semi, false, true); @@ -892,7 +892,7 @@ Parser::StmtResult Parser::ParseReturnStatement() { /// asm-clobbers ',' asm-string-literal /// Parser::StmtResult Parser::ParseAsmStatement() { - assert(Tok.getKind() == tok::kw_asm && "Not an asm stmt"); + assert(Tok.is(tok::kw_asm) && "Not an asm stmt"); ConsumeToken(); DeclSpec DS; @@ -908,7 +908,7 @@ Parser::StmtResult Parser::ParseAsmStatement() { // Remember if this was a volatile asm. //bool isVolatile = DS.TypeQualifiers & DeclSpec::TQ_volatile; - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { Diag(Tok, diag::err_expected_lparen_after, "asm"); SkipUntil(tok::r_paren); return true; @@ -924,7 +924,7 @@ Parser::StmtResult Parser::ParseAsmStatement() { ParseAsmOperandsOpt(); // Parse the clobbers, if present. - if (Tok.getKind() == tok::colon) { + if (Tok.is(tok::colon)) { ConsumeToken(); if (isTokenStringLiteral()) { @@ -932,7 +932,7 @@ Parser::StmtResult Parser::ParseAsmStatement() { while (1) { ParseAsmStringLiteral(); - if (Tok.getKind() != tok::comma) break; + if (Tok.isNot(tok::comma)) break; ConsumeToken(); } } @@ -958,19 +958,19 @@ Parser::StmtResult Parser::ParseAsmStatement() { /// void Parser::ParseAsmOperandsOpt() { // Only do anything if this operand is present. - if (Tok.getKind() != tok::colon) return; + if (Tok.isNot(tok::colon)) return; ConsumeToken(); // 'asm-operands' isn't present? - if (!isTokenStringLiteral() && Tok.getKind() != tok::l_square) + if (!isTokenStringLiteral() && Tok.isNot(tok::l_square)) return; while (1) { // Read the [id] if present. - if (Tok.getKind() == tok::l_square) { + if (Tok.is(tok::l_square)) { SourceLocation Loc = ConsumeBracket(); - if (Tok.getKind() != tok::identifier) { + if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_expected_ident); SkipUntil(tok::r_paren); return; @@ -980,7 +980,7 @@ void Parser::ParseAsmOperandsOpt() { ParseAsmStringLiteral(); - if (Tok.getKind() != tok::l_paren) { + if (Tok.isNot(tok::l_paren)) { Diag(Tok, diag::err_expected_lparen_after, "asm operand"); SkipUntil(tok::r_paren); return; @@ -994,7 +994,7 @@ void Parser::ParseAsmOperandsOpt() { } // Eat the comma and continue parsing if it exists. - if (Tok.getKind() != tok::comma) return; + if (Tok.isNot(tok::comma)) return; ConsumeToken(); } } diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj index 951688f92a..b5cf88f72c 100644 --- a/clang.xcodeproj/project.pbxproj +++ b/clang.xcodeproj/project.pbxproj @@ -481,16 +481,16 @@ isa = PBXGroup; children = ( 84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */, + DE17336D0B068DC20080B521 /* DeclSpec.cpp */, DE3461260AFE68BE00DBC861 /* MinimalAction.cpp */, DE06D42F0A8BB52D0050E87E /* Parser.cpp */, - DE3460040AFDCC6500DBC861 /* ParseInit.cpp */, DE34600E0AFDCCCE00DBC861 /* ParseDecl.cpp */, DE2255FB0C8004E600D370A5 /* ParseDeclCXX.cpp */, DE3460120AFDCCDA00DBC861 /* ParseExpr.cpp */, DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */, - DE34600A0AFDCCBF00DBC861 /* ParseStmt.cpp */, + DE3460040AFDCC6500DBC861 /* ParseInit.cpp */, DE345FFF0AFDCC1900DBC861 /* ParseObjc.cpp */, - DE17336D0B068DC20080B521 /* DeclSpec.cpp */, + DE34600A0AFDCCBF00DBC861 /* ParseStmt.cpp */, ); name = Parse; sourceTree = "";