From: Chris Lattner Date: Tue, 9 Oct 2007 18:02:16 +0000 (+0000) Subject: Switch lexer/pp over to new Token::is/isNot api X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22f6bbcafa8871f4f20c4402d9cbc5c024fee99a;p=clang Switch lexer/pp over to new Token::is/isNot api git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42799 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Lex/Lexer.cpp b/Lex/Lexer.cpp index 0c67d2ab73..a14e51fa6a 100644 --- a/Lex/Lexer.cpp +++ b/Lex/Lexer.cpp @@ -41,8 +41,8 @@ static void InitCharacterInfo(); /// isObjCAtKeyword - Return true if we have an ObjC keyword identifier. bool Token::isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const { - return getKind() == tok::identifier && - getIdentifierInfo()->getObjCKeywordID() == objcKey; + return is(tok::identifier) && + getIdentifierInfo()->getObjCKeywordID() == objcKey; } /// getObjCKeywordID - Return the ObjC keyword kind. @@ -979,7 +979,7 @@ void Lexer::LexIncludeFilename(Token &FilenameTok) { ParsingFilename = false; // No filename? - if (FilenameTok.getKind() == tok::eom) + if (FilenameTok.is(tok::eom)) Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); } @@ -1015,7 +1015,7 @@ std::string Lexer::ReadToEndOfLine() { // Next, lex the character, which should handle the EOM transition. Lex(Tmp); - assert(Tmp.getKind() == tok::eom && "Unexpected token!"); + assert(Tmp.is(tok::eom) && "Unexpected token!"); // Finally, we're done, return the string we found. return Result; @@ -1096,9 +1096,9 @@ unsigned Lexer::isNextPPTokenLParen() { // Restore the lexer back to non-skipping mode. LexingRawMode = false; - if (Tok.getKind() == tok::eof) + if (Tok.is(tok::eof)) return 2; - return Tok.getKind() == tok::l_paren; + return Tok.is(tok::l_paren); } diff --git a/Lex/LiteralSupport.cpp b/Lex/LiteralSupport.cpp index ae4c1a8fde..90a05f68b4 100644 --- a/Lex/LiteralSupport.cpp +++ b/Lex/LiteralSupport.cpp @@ -549,7 +549,7 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks, // literal, the result is a wide-string literal [C99 6.4.5p4]. MaxTokenLength = StringToks[0].getLength(); SizeBound = StringToks[0].getLength()-2; // -2 for "". - AnyWide = StringToks[0].getKind() == tok::wide_string_literal; + AnyWide = StringToks[0].is(tok::wide_string_literal); hadError = false; @@ -565,7 +565,7 @@ StringLiteralParser(const Token *StringToks, unsigned NumStringToks, MaxTokenLength = StringToks[i].getLength(); // Remember if we see any wide strings. - AnyWide |= StringToks[i].getKind() == tok::wide_string_literal; + AnyWide |= StringToks[i].is(tok::wide_string_literal); } diff --git a/Lex/MacroExpander.cpp b/Lex/MacroExpander.cpp index 19e39e3729..545d9c1e49 100644 --- a/Lex/MacroExpander.cpp +++ b/Lex/MacroExpander.cpp @@ -59,7 +59,7 @@ void MacroArgs::destroy() { /// argument. unsigned MacroArgs::getArgLength(const Token *ArgPtr) { unsigned NumArgTokens = 0; - for (; ArgPtr->getKind() != tok::eof; ++ArgPtr) + for (; ArgPtr->isNot(tok::eof); ++ArgPtr) ++NumArgTokens; return NumArgTokens; } @@ -75,7 +75,7 @@ const Token *MacroArgs::getUnexpArgument(unsigned Arg) const { // Scan to find Arg. for (; Arg; ++Result) { assert(Result < Start+NumUnexpArgTokens && "Invalid arg #"); - if (Result->getKind() == tok::eof) + if (Result->is(tok::eof)) --Arg; } return Result; @@ -88,7 +88,7 @@ bool MacroArgs::ArgNeedsPreexpansion(const Token *ArgTok, Preprocessor &PP) const { // If there are no identifiers in the argument list, or if the identifiers are // known to not be macros, pre-expansion won't modify it. - for (; ArgTok->getKind() != tok::eof; ++ArgTok) + for (; ArgTok->isNot(tok::eof); ++ArgTok) if (IdentifierInfo *II = ArgTok->getIdentifierInfo()) { if (II->hasMacroDefinition() && PP.getMacroInfo(II)->isEnabled()) // Return true even though the macro could be a function-like macro @@ -124,7 +124,7 @@ MacroArgs::getPreExpArgument(unsigned Arg, Preprocessor &PP) { do { Result.push_back(Token()); PP.Lex(Result.back()); - } while (Result.back().getKind() != tok::eof); + } while (Result.back().isNot(tok::eof)); // Pop the token stream off the top of the stack. We know that the internal // pointer inside of it is to the "end" of the token stream, but the stack @@ -152,7 +152,7 @@ static Token StringifyArgument(const Token *ArgToks, std::string Result = "\""; // FIXME: Optimize this loop to not use std::strings. bool isFirst = true; - for (; ArgToks->getKind() != tok::eof; ++ArgToks) { + for (; ArgToks->isNot(tok::eof); ++ArgToks) { const Token &Tok = *ArgToks; if (!isFirst && (Tok.hasLeadingSpace() || Tok.isAtStartOfLine())) Result += ' '; @@ -160,9 +160,9 @@ static Token StringifyArgument(const Token *ArgToks, // If this is a string or character constant, escape the token as specified // by 6.10.3.2p2. - if (Tok.getKind() == tok::string_literal || // "foo" - Tok.getKind() == tok::wide_string_literal || // L"foo" - Tok.getKind() == tok::char_constant) { // 'x' and L'x'. + if (Tok.is(tok::string_literal) || // "foo" + Tok.is(tok::wide_string_literal) || // L"foo" + Tok.is(tok::char_constant)) { // 'x' and L'x'. Result += Lexer::Stringify(PP.getSpelling(Tok)); } else { // Otherwise, just append the token. @@ -223,7 +223,7 @@ const Token &MacroArgs::getStringifiedArgument(unsigned ArgNo, memset(&StringifiedArgs[0], 0, sizeof(StringifiedArgs[0])*getNumArguments()); } - if (StringifiedArgs[ArgNo].getKind() != tok::string_literal) + if (StringifiedArgs[ArgNo].isNot(tok::string_literal)) StringifiedArgs[ArgNo] = StringifyArgument(getUnexpArgument(ArgNo), PP); return StringifiedArgs[ArgNo]; } @@ -320,12 +320,12 @@ void MacroExpander::ExpandFunctionArguments() { // preprocessor already verified that the following token is a macro name // when the #define was parsed. const Token &CurTok = MacroTokens[i]; - if (CurTok.getKind() == tok::hash || CurTok.getKind() == tok::hashat) { + if (CurTok.is(tok::hash) || CurTok.is(tok::hashat)) { int ArgNo = Macro->getArgumentNum(MacroTokens[i+1].getIdentifierInfo()); assert(ArgNo != -1 && "Token following # is not an argument?"); Token Res; - if (CurTok.getKind() == tok::hash) // Stringify + if (CurTok.is(tok::hash)) // Stringify Res = ActualArgs->getStringifiedArgument(ArgNo, PP); else { // 'charify': don't bother caching these. @@ -366,8 +366,8 @@ void MacroExpander::ExpandFunctionArguments() { // Otherwise, this is a use of the argument. Find out if there is a paste // (##) operator before or after the argument. bool PasteBefore = - !ResultToks.empty() && ResultToks.back().getKind() == tok::hashhash; - bool PasteAfter = i+1 != e && MacroTokens[i+1].getKind() == tok::hashhash; + !ResultToks.empty() && ResultToks.back().is(tok::hashhash); + bool PasteAfter = i+1 != e && MacroTokens[i+1].is(tok::hashhash); // If it is not the LHS/RHS of a ## operator, we must pre-expand the // argument and substitute the expanded tokens into the result. This is @@ -384,7 +384,7 @@ void MacroExpander::ExpandFunctionArguments() { ResultArgToks = ArgTok; // Use non-preexpanded tokens. // If the arg token expanded into anything, append it. - if (ResultArgToks->getKind() != tok::eof) { + if (ResultArgToks->isNot(tok::eof)) { unsigned FirstResult = ResultToks.size(); unsigned NumToks = MacroArgs::getArgLength(ResultArgToks); ResultToks.append(ResultArgToks, ResultArgToks+NumToks); @@ -435,7 +435,7 @@ void MacroExpander::ExpandFunctionArguments() { // If this is on the RHS of a paste operator, we've already copied the // paste operator to the ResultToks list. Remove it. - assert(PasteBefore && ResultToks.back().getKind() == tok::hashhash); + assert(PasteBefore && ResultToks.back().is(tok::hashhash)); NextTokGetsSpace |= ResultToks.back().hasLeadingSpace(); ResultToks.pop_back(); @@ -444,7 +444,7 @@ void MacroExpander::ExpandFunctionArguments() { // the ## was a comma, remove the comma. if ((unsigned)ArgNo == Macro->getNumArgs()-1 && // is __VA_ARGS__ ActualArgs->isVarargsElidedUse() && // Argument elided. - !ResultToks.empty() && ResultToks.back().getKind() == tok::comma) { + !ResultToks.empty() && ResultToks.back().is(tok::comma)) { // Never add a space, even if the comma, ##, or arg had a space. NextTokGetsSpace = false; ResultToks.pop_back(); @@ -492,7 +492,7 @@ void MacroExpander::Lex(Token &Tok) { Tok = MacroTokens[CurToken++]; // If this token is followed by a token paste (##) operator, paste the tokens! - if (!isAtEnd() && MacroTokens[CurToken].getKind() == tok::hashhash) + if (!isAtEnd() && MacroTokens[CurToken].is(tok::hashhash)) PasteTokens(Tok); // The token's current location indicate where the token was lexed from. We @@ -566,10 +566,9 @@ void MacroExpander::PasteTokens(Token &Tok) { // Avoid testing /*, as the lexer would think it is the start of a comment // and emit an error that it is unterminated. - if (Tok.getKind() == tok::slash && RHS.getKind() == tok::star) { + if (Tok.is(tok::slash) && RHS.is(tok::star)) { isInvalid = true; - } else if (Tok.getKind() == tok::identifier && - RHS.getKind() == tok::identifier) { + } else if (Tok.is(tok::identifier) && RHS.is(tok::identifier)) { // Common paste case: identifier+identifier = identifier. Avoid creating // a lexer and other overhead. PP.IncrementPasteCounter(true); @@ -596,7 +595,7 @@ void MacroExpander::PasteTokens(Token &Tok) { // If we got an EOF token, we didn't form even ONE token. For example, we // did "/ ## /" to get "//". - IsComplete &= Result.getKind() != tok::eof; + IsComplete &= Result.isNot(tok::eof); isInvalid = !IsComplete; // We're now done with the temporary lexer. @@ -614,7 +613,7 @@ void MacroExpander::PasteTokens(Token &Tok) { } // Turn ## into 'other' to avoid # ## # from looking like a paste operator. - if (Result.getKind() == tok::hashhash) + if (Result.is(tok::hashhash)) Result.setKind(tok::unknown); // FIXME: Turn __VARRGS__ into "not a token"? @@ -625,12 +624,12 @@ void MacroExpander::PasteTokens(Token &Tok) { // Finally, replace LHS with the result, consume the RHS, and iterate. ++CurToken; Tok = Result; - } while (!isAtEnd() && MacroTokens[CurToken].getKind() == tok::hashhash); + } while (!isAtEnd() && MacroTokens[CurToken].is(tok::hashhash)); // Now that we got the result token, it will be subject to expansion. Since // token pasting re-lexes the result token in raw mode, identifier information // isn't looked up. As such, if the result is an identifier, look up id info. - if (Tok.getKind() == tok::identifier) { + if (Tok.is(tok::identifier)) { // Look up the identifier info for the token. We disabled identifier lookup // by saying we're skipping contents, so we need to do this manually. Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok)); @@ -644,5 +643,5 @@ unsigned MacroExpander::isNextTokenLParen() const { // Out of tokens? if (isAtEnd()) return 2; - return MacroTokens[CurToken].getKind() == tok::l_paren; + return MacroTokens[CurToken].is(tok::l_paren); } diff --git a/Lex/PPExpressions.cpp b/Lex/PPExpressions.cpp index e5f603f26e..ec20eb14c8 100644 --- a/Lex/PPExpressions.cpp +++ b/Lex/PPExpressions.cpp @@ -87,7 +87,7 @@ static bool EvaluateValue(llvm::APSInt &Result, Token &PeekTok, // Two options, it can either be a pp-identifier or a (. bool InParens = false; - if (PeekTok.getKind() == tok::l_paren) { + if (PeekTok.is(tok::l_paren)) { // Found a paren, remember we saw it and skip it. InParens = true; PP.LexUnexpandedToken(PeekTok); @@ -129,7 +129,7 @@ static bool EvaluateValue(llvm::APSInt &Result, Token &PeekTok, // If we are in parens, ensure we have a trailing ). if (InParens) { - if (PeekTok.getKind() != tok::r_paren) { + if (PeekTok.isNot(tok::r_paren)) { PP.Diag(PeekTok, diag::err_pp_missing_rparen); return true; } @@ -246,13 +246,13 @@ static bool EvaluateValue(llvm::APSInt &Result, Token &PeekTok, // If this is a silly value like (X), which doesn't need parens, check for // !(defined X). - if (PeekTok.getKind() == tok::r_paren) { + if (PeekTok.is(tok::r_paren)) { // Just use DT unmodified as our result. } else { if (EvaluateDirectiveSubExpr(Result, 1, PeekTok, ValueLive, PP)) return true; - if (PeekTok.getKind() != tok::r_paren) { + if (PeekTok.isNot(tok::r_paren)) { PP.Diag(PeekTok, diag::err_pp_expected_rparen); return true; } @@ -560,7 +560,7 @@ static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec, break; case tok::question: { // Parse the : part of the expression. - if (PeekTok.getKind() != tok::colon) { + if (PeekTok.isNot(tok::colon)) { PP.Diag(OpToken, diag::err_pp_question_without_colon); return true; } @@ -622,7 +622,7 @@ EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { DefinedTracker DT; if (EvaluateValue(ResVal, Tok, DT, true, *this)) { // Parse error, skip the rest of the macro line. - if (Tok.getKind() != tok::eom) + if (Tok.isNot(tok::eom)) DiscardUntilEndOfDirective(); return false; } @@ -630,7 +630,7 @@ EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { // If we are at the end of the expression after just parsing a value, there // must be no (unparenthesized) binary operators involved, so we can exit // directly. - if (Tok.getKind() == tok::eom) { + if (Tok.is(tok::eom)) { // If the expression we parsed was of the form !defined(macro), return the // macro in IfNDefMacro. if (DT.State == DefinedTracker::NotDefinedMacro) @@ -643,14 +643,14 @@ EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { // operator and the stuff after it. if (EvaluateDirectiveSubExpr(ResVal, 1, Tok, true, *this)) { // Parse error, skip the rest of the macro line. - if (Tok.getKind() != tok::eom) + if (Tok.isNot(tok::eom)) DiscardUntilEndOfDirective(); return false; } // If we aren't at the tok::eom token, something bad happened, like an extra // ')' token. - if (Tok.getKind() != tok::eom) { + if (Tok.isNot(tok::eom)) { Diag(Tok, diag::err_pp_expected_eol); DiscardUntilEndOfDirective(); } diff --git a/Lex/Pragma.cpp b/Lex/Pragma.cpp index 89725ae8e9..05e524c0c1 100644 --- a/Lex/Pragma.cpp +++ b/Lex/Pragma.cpp @@ -93,13 +93,12 @@ void Preprocessor::Handle_Pragma(Token &Tok) { // Read the '('. Lex(Tok); - if (Tok.getKind() != tok::l_paren) + if (Tok.isNot(tok::l_paren)) return Diag(PragmaLoc, diag::err__Pragma_malformed); // Read the '"..."'. Lex(Tok); - if (Tok.getKind() != tok::string_literal && - Tok.getKind() != tok::wide_string_literal) + if (Tok.isNot(tok::string_literal) && Tok.isNot(tok::wide_string_literal)) return Diag(PragmaLoc, diag::err__Pragma_malformed); // Remember the string. @@ -108,7 +107,7 @@ void Preprocessor::Handle_Pragma(Token &Tok) { // Read the ')'. Lex(Tok); - if (Tok.getKind() != tok::r_paren) + if (Tok.isNot(tok::r_paren)) return Diag(PragmaLoc, diag::err__Pragma_malformed); // The _Pragma is lexically sound. Destringize according to C99 6.10.9.1. @@ -194,10 +193,10 @@ void Preprocessor::HandlePragmaPoison(Token &PoisonTok) { if (CurLexer) CurLexer->LexingRawMode = false; // If we reached the end of line, we're done. - if (Tok.getKind() == tok::eom) return; + if (Tok.is(tok::eom)) return; // Can only poison identifiers. - if (Tok.getKind() != tok::identifier) { + if (Tok.isNot(tok::identifier)) { Diag(Tok, diag::err_pp_invalid_poison); return; } @@ -247,7 +246,7 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) { CurLexer->LexIncludeFilename(FilenameTok); // If the token kind is EOM, the error has already been diagnosed. - if (FilenameTok.getKind() == tok::eom) + if (FilenameTok.is(tok::eom)) return; // Reserve a buffer to get the spelling. @@ -280,7 +279,7 @@ void Preprocessor::HandlePragmaDependency(Token &DependencyTok) { // Lex tokens at the end of the message and include them in the message. std::string Message; Lex(DependencyTok); - while (DependencyTok.getKind() != tok::eom) { + while (DependencyTok.isNot(tok::eom)) { Message += getSpelling(DependencyTok) + " "; Lex(DependencyTok); } diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index 0391c503d6..f1e9b12efc 100644 --- a/Lex/Preprocessor.cpp +++ b/Lex/Preprocessor.cpp @@ -618,7 +618,7 @@ bool Preprocessor::isNextPPTokenLParen() { Token Tok; LexUnexpandedToken(Tok); - assert(Tok.getKind() == tok::l_paren && "Error computing l-paren-ness?"); + assert(Tok.is(tok::l_paren) && "Error computing l-paren-ness?"); return true; } @@ -767,7 +767,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, llvm::SmallVector ArgTokens; unsigned NumActuals = 0; - while (Tok.getKind() == tok::comma) { + while (Tok.is(tok::comma)) { // C99 6.10.3p11: Keep track of the number of l_parens we have seen. Note // that we already consumed the first one. unsigned NumParens = 0; @@ -777,18 +777,18 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, // an argument value in a macro could expand to ',' or '(' or ')'. LexUnexpandedToken(Tok); - if (Tok.getKind() == tok::eof) { + if (Tok.is(tok::eof)) { Diag(MacroName, diag::err_unterm_macro_invoc); // Do not lose the EOF. Return it to the client. MacroName = Tok; return 0; - } else if (Tok.getKind() == tok::r_paren) { + } else if (Tok.is(tok::r_paren)) { // If we found the ) token, the macro arg list is done. if (NumParens-- == 0) break; - } else if (Tok.getKind() == tok::l_paren) { + } else if (Tok.is(tok::l_paren)) { ++NumParens; - } else if (Tok.getKind() == tok::comma && NumParens == 0) { + } else if (Tok.is(tok::comma) && NumParens == 0) { // Comma ends this argument if there are more fixed arguments expected. if (NumFixedArgsLeft) break; @@ -801,7 +801,7 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName, return 0; } // Otherwise, continue to add the tokens to this variable argument. - } else if (Tok.getKind() == tok::comment && !KeepMacroComments) { + } else if (Tok.is(tok::comment) && !KeepMacroComments) { // If this is a comment token in the argument list and we're just in // -C mode (not -CC mode), discard the comment. continue; @@ -1005,7 +1005,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { /// identifier information for the token and install it into the token. IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token &Identifier, const char *BufPtr) { - assert(Identifier.getKind() == tok::identifier && "Not an identifier!"); + assert(Identifier.is(tok::identifier) && "Not an identifier!"); assert(Identifier.getIdentifierInfo() == 0 && "Identinfo already exists!"); // Look up this token, see if it is a macro, or if it is a language keyword. @@ -1174,7 +1174,7 @@ void Preprocessor::DiscardUntilEndOfDirective() { Token Tmp; do { LexUnexpandedToken(Tmp); - } while (Tmp.getKind() != tok::eom); + } while (Tmp.isNot(tok::eom)); } /// isCXXNamedOperator - Returns "true" if the token is a named operator in C++. @@ -1194,7 +1194,7 @@ void Preprocessor::ReadMacroName(Token &MacroNameTok, char isDefineUndef) { LexUnexpandedToken(MacroNameTok); // Missing macro name? - if (MacroNameTok.getKind() == tok::eom) + if (MacroNameTok.is(tok::eom)) return Diag(MacroNameTok, diag::err_pp_missing_macro_name); IdentifierInfo *II = MacroNameTok.getIdentifierInfo(); @@ -1235,10 +1235,10 @@ void Preprocessor::CheckEndOfDirective(const char *DirType) { Lex(Tmp); // There should be no tokens after the directive, but we allow them as an // extension. - while (Tmp.getKind() == tok::comment) // Skip comments in -C mode. + while (Tmp.is(tok::comment)) // Skip comments in -C mode. Lex(Tmp); - if (Tmp.getKind() != tok::eom) { + if (Tmp.isNot(tok::eom)) { Diag(Tmp, diag::ext_pp_extra_tokens_at_eol, DirType); DiscardUntilEndOfDirective(); } @@ -1272,7 +1272,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, CurLexer->Lex(Tok); // If this is the end of the buffer, we have an error. - if (Tok.getKind() == tok::eof) { + if (Tok.is(tok::eof)) { // Emit errors for each unterminated conditional on the stack, including // the current one. while (!CurLexer->ConditionalStack.empty()) { @@ -1286,7 +1286,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, } // If this token is not a preprocessor directive, just skip it. - if (Tok.getKind() != tok::hash || !Tok.isAtStartOfLine()) + if (Tok.isNot(tok::hash) || !Tok.isAtStartOfLine()) continue; // We just parsed a # character at the start of a line, so we're in @@ -1301,7 +1301,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, // If this isn't an identifier directive (e.g. is "# 1\n" or "#\n", or // something bogus), skip it. - if (Tok.getKind() != tok::identifier) { + if (Tok.isNot(tok::identifier)) { CurLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. CurLexer->KeepCommentMode = KeepComments; @@ -1586,8 +1586,8 @@ void Preprocessor::HandleIdentSCCSDirective(Token &Tok) { Lex(StrTok); // If the token kind isn't a string, it's a malformed directive. - if (StrTok.getKind() != tok::string_literal && - StrTok.getKind() != tok::wide_string_literal) + if (StrTok.isNot(tok::string_literal) && + StrTok.isNot(tok::wide_string_literal)) return Diag(StrTok, diag::err_pp_malformed_ident); // Verify that there is nothing after the string, other than EOM. @@ -1663,7 +1663,7 @@ static bool ConcatenateIncludeName(llvm::SmallVector &FilenameBuffer, Token CurTok; PP.Lex(CurTok); - while (CurTok.getKind() != tok::eom) { + while (CurTok.isNot(tok::eom)) { // Append the spelling of this token to the buffer. If there was a space // before it, add it now. if (CurTok.hasLeadingSpace()) @@ -1685,7 +1685,7 @@ static bool ConcatenateIncludeName(llvm::SmallVector &FilenameBuffer, FilenameBuffer.resize(PreAppendSize+ActualLen); // If we found the '>' marker, return success. - if (CurTok.getKind() == tok::greater) + if (CurTok.is(tok::greater)) return false; PP.Lex(CurTok); @@ -1842,7 +1842,7 @@ bool Preprocessor::ReadMacroDefinitionArgList(MacroInfo *MI) { // Lex the token after the identifier. LexUnexpandedToken(Tok); - if (Tok.getKind() != tok::r_paren) { + if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_pp_missing_rparen_in_macro_def); return true; } @@ -1893,7 +1893,7 @@ bool Preprocessor::ReadMacroDefinitionArgList(MacroInfo *MI) { // Lex the token after the identifier. LexUnexpandedToken(Tok); - if (Tok.getKind() != tok::r_paren) { + if (Tok.isNot(tok::r_paren)) { Diag(Tok, diag::err_pp_missing_rparen_in_macro_def); return true; } @@ -1918,7 +1918,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok, ReadMacroName(MacroNameTok, 1); // Error reading macro name? If so, diagnostic already issued. - if (MacroNameTok.getKind() == tok::eom) + if (MacroNameTok.is(tok::eom)) return; // If we are supposed to keep comments in #defines, reenable comment saving @@ -1939,9 +1939,9 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok, // If this is a function-like macro definition, parse the argument list, // marking each of the identifiers as being used as macro arguments. Also, // check other constraints on the first token of the macro body. - if (Tok.getKind() == tok::eom) { + if (Tok.is(tok::eom)) { // If there is no body to this macro, we have no special handling here. - } else if (Tok.getKind() == tok::l_paren && !Tok.hasLeadingSpace()) { + } else if (Tok.is(tok::l_paren) && !Tok.hasLeadingSpace()) { // This is a function-like macro definition. Read the argument list. MI->setIsFunctionLike(); if (ReadMacroDefinitionArgList(MI)) { @@ -1982,7 +1982,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok, // Read the rest of the macro body. if (MI->isObjectLike()) { // Object-like macros are very simple, just read their body. - while (Tok.getKind() != tok::eom) { + while (Tok.isNot(tok::eom)) { MI->AddTokenToBody(Tok); // Get the next token of the macro. LexUnexpandedToken(Tok); @@ -1991,12 +1991,12 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok, } else { // Otherwise, read the body of a function-like macro. This has to validate // the # (stringize) operator. - while (Tok.getKind() != tok::eom) { + while (Tok.isNot(tok::eom)) { MI->AddTokenToBody(Tok); // Check C99 6.10.3.2p1: ensure that # operators are followed by macro // parameters in function-like macro expansions. - if (Tok.getKind() != tok::hash) { + if (Tok.isNot(tok::hash)) { // Get the next token of the macro. LexUnexpandedToken(Tok); continue; @@ -2032,12 +2032,12 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok, // replacement list. unsigned NumTokens = MI->getNumTokens(); if (NumTokens != 0) { - if (MI->getReplacementToken(0).getKind() == tok::hashhash) { + if (MI->getReplacementToken(0).is(tok::hashhash)) { Diag(MI->getReplacementToken(0), diag::err_paste_at_start); delete MI; return; } - if (MI->getReplacementToken(NumTokens-1).getKind() == tok::hashhash) { + if (MI->getReplacementToken(NumTokens-1).is(tok::hashhash)) { Diag(MI->getReplacementToken(NumTokens-1), diag::err_paste_at_end); delete MI; return; @@ -2074,7 +2074,7 @@ void Preprocessor::HandleDefineOtherTargetDirective(Token &Tok) { ReadMacroName(MacroNameTok, 1); // Error reading macro name? If so, diagnostic already issued. - if (MacroNameTok.getKind() == tok::eom) + if (MacroNameTok.is(tok::eom)) return; // Check to see if this is the last token on the #undef line. @@ -2101,7 +2101,7 @@ void Preprocessor::HandleUndefDirective(Token &UndefTok) { ReadMacroName(MacroNameTok, 2); // Error reading macro name? If so, diagnostic already issued. - if (MacroNameTok.getKind() == tok::eom) + if (MacroNameTok.is(tok::eom)) return; // Check to see if this is the last token on the #undef line. @@ -2143,7 +2143,7 @@ void Preprocessor::HandleIfdefDirective(Token &Result, bool isIfndef, ReadMacroName(MacroNameTok); // Error reading macro name? If so, diagnostic already issued. - if (MacroNameTok.getKind() == tok::eom) { + if (MacroNameTok.is(tok::eom)) { // Skip code until we get to #endif. This helps with recovery by not // emitting an error when the #endif is reached. SkipExcludedConditionalBlock(DirectiveTok.getLocation(),