Il 05/12/2010 08:42, Abramo Bagnara ha scritto:
> Il 05/12/2010 00:26, Chris Lattner ha scritto:
>> On Dec 4, 2010, at 2:36 AM, Abramo Bagnara wrote:
>>> Currently, during lexing in LexingRawMode only the literal text is
>>> collected (setLiteralData/getLiteralData), while the identifier text is
>>> lost.
>>
>> Hi Abramo,
>>
>> I'm not sure what you're trying to accomplish here: it sounds like you want
>> to get the "identifier text" from the token itself without getting the
>> spelling. Is this correct? If so, are you looking for a performance win, a
>> functionality improvement, or something else? What problem are you trying
>> to solve?
>
> Yes, the idea is to have access to identifier text just like we have now
> access to LiteralData.
>
> We are looking for a performance win (and secondarily for a simmetric
> interface wrt literals) for our raw lexer clients (currently they need
> to use something like the above to get the text for each identifier):
>
> token_begin = sm.getSpellingLoc(token_begin);
>
> const char* current_char = sm.getCharacterData(token_begin);
> const char* end = current_char + length;
>
> while (current_char < end) {
> char c = clang::Lexer::getCharAndSizeNoWarn(current_char, length, lo);
> output += c;
> current_char += length;
> }
I've attached the working patch for approval.
Index: include/clang/Basic/TokenKinds.def
===================================================================
--- include/clang/Basic/TokenKinds.def (revision 120900)
+++ include/clang/Basic/TokenKinds.def (working copy)
@@ -103,6 +103,7 @@
// C99 6.4.2: Identifiers.
TOK(identifier) // abcde123
+TOK(raw_identifier) // Used only in raw lexing mode.
// C99 6.4.4.1: Integer Constants
// C99 6.4.4.2: Floating Constants
Index: include/clang/Lex/Token.h
===================================================================
--- include/clang/Lex/Token.h (revision 120900)
+++ include/clang/Lex/Token.h (working copy)
@@ -88,6 +88,12 @@
bool is(tok::TokenKind K) const { return Kind == (unsigned) K; }
bool isNot(tok::TokenKind K) const { return Kind != (unsigned) K; }
+ /// isIdentifier - Return true if this is a raw identifier (when lexing
+ /// in raw mode) or a non-keyword identifier (when lexing in non-raw mode).
+ bool isIdentifier() const {
+ return is(tok::identifier) || is(tok::raw_identifier);
+ }
+
/// isLiteral - Return true if this is a "literal", like a numeric
/// constant, string, etc.
bool isLiteral() const {
@@ -155,6 +161,7 @@
IdentifierInfo *getIdentifierInfo() const {
assert(!isAnnotation() && "Used IdentInfo on annotation token!");
+ if (is(tok::raw_identifier)) return 0;
if (isLiteral()) return 0;
return (IdentifierInfo*) PtrData;
}
@@ -162,6 +169,18 @@
PtrData = (void*) II;
}
+ /// getRawIdentifierData - For a raw identifier token (i.e., an identifier
+ /// lexed in raw mode), returns a pointer to the start of it in the text
+ /// buffer if known, null otherwise.
+ const char *getRawIdentifierData() const {
+ assert(is(tok::raw_identifier));
+ return reinterpret_cast<const char*>(PtrData);
+ }
+ void setRawIdentifierData(const char *Ptr) {
+ assert(is(tok::raw_identifier));
+ PtrData = const_cast<char*>(Ptr);
+ }
+
/// getLiteralData - For a literal token (numeric constant, string, etc), this
/// returns a pointer to the start of it in the text buffer if known, null
/// otherwise.
Index: tools/libclang/CIndex.cpp
===================================================================
--- tools/libclang/CIndex.cpp (revision 120900)
+++ tools/libclang/CIndex.cpp (working copy)
@@ -3964,7 +3964,7 @@
if (Tok.isLiteral()) {
CXTok.int_data[0] = CXToken_Literal;
CXTok.ptr_data = (void *)Tok.getLiteralData();
- } else if (Tok.is(tok::identifier)) {
+ } else if (Tok.isIdentifier()) {
// Lookup the identifier to determine whether we have a keyword.
std::pair<FileID, unsigned> LocInfo
= SourceMgr.getDecomposedLoc(Tok.getLocation());
Index: lib/Frontend/CacheTokens.cpp
===================================================================
--- lib/Frontend/CacheTokens.cpp (revision 120900)
+++ lib/Frontend/CacheTokens.cpp (working copy)
@@ -299,7 +299,7 @@
ParsingPreprocessorDirective = false;
}
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
PP.LookUpIdentifierInfo(Tok);
EmitToken(Tok);
continue;
@@ -325,7 +325,7 @@
Tok = NextTok;
// Did we see 'include'/'import'/'include_next'?
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
EmitToken(Tok);
continue;
}
@@ -352,7 +352,7 @@
L.LexIncludeFilename(Tok);
L.setParsingPreprocessorDirective(false);
assert(!Tok.isAtStartOfLine());
- if (Tok.is(tok::identifier))
+ if (Tok.isIdentifier())
PP.LookUpIdentifierInfo(Tok);
break;
Index: lib/Rewrite/TokenRewriter.cpp
===================================================================
--- lib/Rewrite/TokenRewriter.cpp (revision 120900)
+++ lib/Rewrite/TokenRewriter.cpp (working copy)
@@ -34,7 +34,7 @@
RawLex.LexFromRawLexer(RawTok);
while (RawTok.isNot(tok::eof)) {
#if 0
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier())) {
// Look up the identifier info for the token. This should use
// IdentifierTable directly instead of PP.
Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok));
Index: lib/Rewrite/HTMLRewrite.cpp
===================================================================
--- lib/Rewrite/HTMLRewrite.cpp (revision 120900)
+++ lib/Rewrite/HTMLRewrite.cpp (working copy)
@@ -378,7 +378,8 @@
unsigned TokLen = Tok.getLength();
switch (Tok.getKind()) {
default: break;
- case tok::identifier: {
+ case tok::identifier:
+ case tok::raw_identifier: {
// Fill in Result.IdentifierInfo, looking up the identifier in the
// identifier table.
const IdentifierInfo *II =
@@ -473,7 +474,7 @@
// If this raw token is an identifier, the raw lexer won't have looked up
// the corresponding identifier info for it. Do this now so that it will be
// macro expanded when we re-preprocess it.
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
// Change the kind of this identifier to the appropriate token kind, e.g.
// turning "for" into a keyword.
Tok.setKind(PP.LookUpIdentifierInfo(Tok)->getTokenID());
Index: lib/Rewrite/RewriteMacros.cpp
===================================================================
--- lib/Rewrite/RewriteMacros.cpp (revision 120900)
+++ lib/Rewrite/RewriteMacros.cpp (working copy)
@@ -78,7 +78,7 @@
// If we have an identifier with no identifier info for our raw token, look
// up the indentifier info. This is important for equality comparison of
// identifier tokens.
- if (RawTok.is(tok::identifier) && !RawTok.getIdentifierInfo())
+ if (RawTok.isIdentifier() && !RawTok.getIdentifierInfo())
PP.LookUpIdentifierInfo(RawTok);
RawTokens.push_back(RawTok);
@@ -127,13 +127,13 @@
if (RawTok.is(tok::hash) && RawTok.isAtStartOfLine()) {
// If this is a #warning directive or #pragma mark (GNU extensions),
// comment the line out.
- if (RawTokens[CurRawTok].is(tok::identifier)) {
+ if (RawTokens[CurRawTok].isIdentifier()) {
const IdentifierInfo *II = RawTokens[CurRawTok].getIdentifierInfo();
if (II->getName() == "warning") {
// Comment out #warning.
RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//");
} else if (II->getName() == "pragma" &&
- RawTokens[CurRawTok+1].is(tok::identifier) &&
+ RawTokens[CurRawTok+1].isIdentifier() &&
(RawTokens[CurRawTok+1].getIdentifierInfo()->getName() ==
"mark")) {
// Comment out #pragma mark.
Index: lib/Lex/PPDirectives.cpp
===================================================================
--- lib/Lex/PPDirectives.cpp (revision 120900)
+++ lib/Lex/PPDirectives.cpp (working copy)
@@ -245,7 +245,7 @@
// If this isn't an identifier directive (e.g. is "# 1\n" or "#\n", or
// something bogus), skip it.
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
CurPPLexer->ParsingPreprocessorDirective = false;
// Restore comment saving mode.
if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments);
Index: lib/Lex/Pragma.cpp
===================================================================
--- lib/Lex/Pragma.cpp (revision 120900)
+++ lib/Lex/Pragma.cpp (working copy)
@@ -292,7 +292,7 @@
if (Tok.is(tok::eom)) return;
// Can only poison identifiers.
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_pp_invalid_poison);
return;
}
@@ -415,7 +415,7 @@
// Read the identifier.
Lex(Tok);
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(CommentLoc, diag::err_pragma_comment_malformed);
return;
}
@@ -773,7 +773,7 @@
Token &DepToken) {
Token Tok;
PP.LexUnexpandedToken(Tok);
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
return;
}
@@ -812,7 +812,7 @@
Token &DiagToken) {
Token Tok;
PP.LexUnexpandedToken(Tok);
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
PP.Diag(Tok, diag::warn_pragma_diagnostic_invalid);
return;
}
@@ -938,7 +938,7 @@
Token Tok;
PP.LexUnexpandedToken(Tok);
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
PP.Diag(Tok, diag::ext_stdc_pragma_syntax);
return STDC_INVALID;
}
Index: lib/Lex/Lexer.cpp
===================================================================
--- lib/Lex/Lexer.cpp (revision 120900)
+++ lib/Lex/Lexer.cpp (working copy)
@@ -473,7 +473,7 @@
// we don't have an identifier table available. Instead, just look at
// the raw identifier to recognize and categorize preprocessor directives.
TheLexer.LexFromRawLexer(TheTok);
- if (TheTok.getKind() == tok::identifier && !TheTok.needsCleaning()) {
+ if (TheTok.isIdentifier() && !TheTok.needsCleaning()) {
const char *IdStart = Buffer->getBufferStart()
+ TheTok.getLocation().getRawEncoding() - 1;
llvm::StringRef Keyword(IdStart, TheTok.getLength());
@@ -1050,7 +1050,11 @@
// If we are in raw mode, return this identifier raw. There is no need to
// look up identifier information or attempt to macro expand it.
- if (LexingRawMode) return;
+ if (LexingRawMode) {
+ Result.setKind(tok::raw_identifier);
+ Result.setRawIdentifierData(IdStart);
+ return;
+ }
// Fill in Result.IdentifierInfo, looking up the identifier in the
// identifier table.
Index: lib/Lex/TokenLexer.cpp
===================================================================
--- lib/Lex/TokenLexer.cpp (revision 120900)
+++ lib/Lex/TokenLexer.cpp (working copy)
@@ -435,7 +435,7 @@
// Lex the resultant pasted token into Result.
Token Result;
- if (Tok.is(tok::identifier) && RHS.is(tok::identifier)) {
+ if (Tok.isIdentifier() && RHS.isIdentifier()) {
// Common paste case: identifier+identifier = identifier. Avoid creating
// a lexer and other overhead.
PP.IncrementPasteCounter(true);
@@ -524,7 +524,7 @@
// 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.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
// 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.
PP.LookUpIdentifierInfo(Tok, ResultTokStrPtr);
Index: lib/Lex/Preprocessor.cpp
===================================================================
--- lib/Lex/Preprocessor.cpp (revision 120900)
+++ lib/Lex/Preprocessor.cpp (working copy)
@@ -369,11 +369,11 @@
// Lexer Event Handling.
//===----------------------------------------------------------------------===//
-/// LookUpIdentifierInfo - Given a tok::identifier token, look up the
+/// LookUpIdentifierInfo - Given a (raw) identifier token, look up the
/// identifier information for the token and install it into the token.
IdentifierInfo *Preprocessor::LookUpIdentifierInfo(Token &Identifier,
const char *BufPtr) const {
- assert(Identifier.is(tok::identifier) && "Not an identifier!");
+ assert(Identifier.isIdentifier() && "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.
@@ -387,6 +387,7 @@
llvm::StringRef CleanedStr = getSpelling(Identifier, IdentifierBuffer);
II = getIdentifierInfo(CleanedStr);
}
+ Identifier.setKind(tok::identifier);
Identifier.setIdentifierInfo(II);
return II;
}
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp (revision 120900)
+++ lib/Lex/PPMacroExpansion.cpp (working copy)
@@ -826,7 +826,7 @@
if (Tok.is(tok::l_paren)) {
// Read the identifier
Lex(Tok);
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
FeatureII = Tok.getIdentifierInfo();
// Read the ')'.
Index: lib/Lex/TokenConcatenation.cpp
===================================================================
--- lib/Lex/TokenConcatenation.cpp (revision 120900)
+++ lib/Lex/TokenConcatenation.cpp (working copy)
@@ -167,6 +167,7 @@
switch (PrevKind) {
default: assert(0 && "InitAvoidConcatTokenInfo built wrong");
case tok::identifier: // id+id or id+number or id+L"foo".
+ case tok::raw_identifier:
// id+'.'... will not append.
if (Tok.is(tok::numeric_constant))
return GetFirstChar(PP, Tok) != '.';
Index: lib/Parse/ParseTentative.cpp
===================================================================
--- lib/Parse/ParseTentative.cpp (revision 120900)
+++ lib/Parse/ParseTentative.cpp (working copy)
@@ -503,7 +503,7 @@
// ptr-operator declarator
while (1) {
- if (Tok.is(tok::coloncolon) || Tok.is(tok::identifier))
+ if (Tok.is(tok::coloncolon) || Tok.isIdentifier())
if (TryAnnotateCXXScopeToken(true))
return TPResult::Error();
@@ -523,8 +523,8 @@
// direct-declarator:
// direct-abstract-declarator:
- if ((Tok.is(tok::identifier) ||
- (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::identifier))) &&
+ if ((Tok.isIdentifier() ||
+ (Tok.is(tok::annot_cxxscope) && NextToken().isIdentifier())) &&
mayHaveIdentifier) {
// declarator-id
if (Tok.is(tok::annot_cxxscope))
@@ -801,6 +801,7 @@
Parser::TPResult Parser::isCXXDeclarationSpecifier() {
switch (Tok.getKind()) {
case tok::identifier: // foo::bar
+ case tok::raw_identifier:
// Check for need to substitute AltiVec __vector keyword
// for "vector" identifier.
if (TryAltiVecVectorToken())
@@ -811,7 +812,7 @@
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return TPResult::Error();
- if (Tok.is(tok::identifier))
+ if (Tok.isIdentifier())
return TPResult::False();
return isCXXDeclarationSpecifier();
@@ -1027,7 +1028,7 @@
assert(Tok.is(tok::less) && "Expected '<' for qualifier list");
ConsumeToken();
do {
- if (Tok.isNot(tok::identifier))
+ if (!Tok.isIdentifier())
return TPResult::Error();
ConsumeToken();
Index: lib/Parse/ParseInit.cpp
===================================================================
--- lib/Parse/ParseInit.cpp (revision 120900)
+++ lib/Parse/ParseInit.cpp (working copy)
@@ -31,6 +31,7 @@
case tok::l_square: // designator: array-designator
return true;
case tok::identifier: // designation: identifier ':'
+ case tok::raw_identifier:
return PP.LookAhead(0).is(tok::colon);
}
}
@@ -78,7 +79,7 @@
// designation ::= identifier ':'
// Handle it as a field designator. Otherwise, this must be the start of a
// normal expression.
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
const IdentifierInfo *FieldName = Tok.getIdentifierInfo();
llvm::SmallString<256> NewSyntax;
@@ -111,7 +112,7 @@
// designator: '.' identifier
SourceLocation DotLoc = ConsumeToken();
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok.getLocation(), diag::err_expected_field_designator);
return ExprError();
}
@@ -148,7 +149,7 @@
// much more complicated parsing.
if (getLang().ObjC1 && getLang().CPlusPlus) {
// Send to 'super'.
- if (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_super &&
+ if (Tok.isIdentifier() && Tok.getIdentifierInfo() == Ident_super &&
NextToken().isNot(tok::period) &&
getCurScope()->isInObjcMethodScope()) {
CheckArrayDesignatorSyntax(*this, StartLoc, Desig);
@@ -181,7 +182,7 @@
// adopt the expression for further analysis below.
// FIXME: potentially-potentially evaluated expression above?
Idx = ExprResult(static_cast<Expr*>(TypeOrExpr));
- } else if (getLang().ObjC1 && Tok.is(tok::identifier)) {
+ } else if (getLang().ObjC1 && Tok.isIdentifier()) {
IdentifierInfo *II = Tok.getIdentifierInfo();
SourceLocation IILoc = Tok.getLocation();
ParsedType ReceiverType;
Index: lib/Parse/ParsePragma.cpp
===================================================================
--- lib/Parse/ParsePragma.cpp (revision 120900)
+++ lib/Parse/ParsePragma.cpp (working copy)
@@ -99,7 +99,7 @@
return;
PP.Lex(Tok);
- } else if (Tok.is(tok::identifier)) {
+ } else if (Tok.isIdentifier()) {
const IdentifierInfo *II = Tok.getIdentifierInfo();
if (II->isStr("show")) {
Kind = Sema::PPK_Show;
@@ -124,7 +124,7 @@
return;
PP.Lex(Tok);
- } else if (Tok.is(tok::identifier)) {
+ } else if (Tok.isIdentifier()) {
Name = Tok.getIdentifierInfo();
PP.Lex(Tok);
@@ -174,7 +174,7 @@
if (IsOptions) {
PP.Lex(Tok);
- if (Tok.isNot(tok::identifier) ||
+ if (!Tok.isIdentifier() ||
!Tok.getIdentifierInfo()->isStr("align")) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_options_expected_align);
return;
@@ -189,7 +189,7 @@
}
PP.Lex(Tok);
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
<< (IsOptions ? "options" : "align");
return;
@@ -263,7 +263,7 @@
PP.Lex(Tok);
if (LexID) {
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
Identifiers.push_back(Tok);
LexID = false;
continue;
@@ -316,7 +316,7 @@
Token Tok;
PP.Lex(Tok);
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier) << "weak";
return;
}
@@ -327,7 +327,7 @@
PP.Lex(Tok);
if (Tok.is(tok::equal)) {
PP.Lex(Tok);
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
<< "weak";
return;
Index: lib/Parse/ParseDecl.cpp
===================================================================
--- lib/Parse/ParseDecl.cpp (revision 120900)
+++ lib/Parse/ParseDecl.cpp (working copy)
@@ -99,7 +99,7 @@
return CurrAttr;
}
// Parse the attribute-list. e.g. __attribute__(( weak, alias("__f") ))
- while (Tok.is(tok::identifier) || isDeclarationSpecifier() ||
+ while (Tok.isIdentifier() || isDeclarationSpecifier() ||
Tok.is(tok::comma)) {
if (Tok.is(tok::comma)) {
@@ -115,7 +115,7 @@
if (Tok.is(tok::l_paren)) {
ConsumeParen(); // ignore the left paren loc for now
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
IdentifierInfo *ParmName = Tok.getIdentifierInfo();
SourceLocation ParmLoc = ConsumeToken();
@@ -749,7 +749,7 @@
bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
const ParsedTemplateInfo &TemplateInfo,
AccessSpecifier AS) {
- assert(Tok.is(tok::identifier) && "should have identifier");
+ assert(Tok.isIdentifier() && "should have identifier");
SourceLocation Loc = Tok.getLocation();
// If we see an identifier that is not a type name, we normally would
@@ -1030,7 +1030,7 @@
ConsumeToken(); // The typename
}
- if (Next.isNot(tok::identifier))
+ if (!Next.isIdentifier())
goto DoneWithDeclSpec;
// If we're in a context where the identifier could be a class name,
@@ -1104,7 +1104,8 @@
}
// typedef-name
- case tok::identifier: {
+ case tok::identifier:
+ case tok::raw_identifier: {
// In C++, check to see if this is a scope specifier like foo::bar::, if
// so handle it as such. This is important for ctor parsing.
if (getLang().CPlusPlus) {
@@ -1113,7 +1114,7 @@
DS.SetTypeSpecError();
goto DoneWithDeclSpec;
}
- if (!Tok.is(tok::identifier))
+ if (!Tok.isIdentifier())
continue;
}
@@ -1513,6 +1514,7 @@
switch (Tok.getKind()) {
case tok::identifier: // foo::bar
+ case tok::raw_identifier:
// If we already have a type specifier, this identifier is not a type.
if (DS.getTypeSpecType() != DeclSpec::TST_unspecified ||
DS.getTypeSpecWidth() != DeclSpec::TSW_unspecified ||
@@ -1527,7 +1529,7 @@
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return true;
- if (Tok.is(tok::identifier))
+ if (Tok.isIdentifier())
return false;
return ParseOptionalTypeSpecifier(DS, isInvalid, PrevSpec, DiagID,
TemplateInfo, SuppressDeclarations);
@@ -1879,7 +1881,7 @@
}
ConsumeToken();
ExpectAndConsume(tok::l_paren, diag::err_expected_lparen);
- if (!Tok.is(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::semi, true);
continue;
@@ -1968,7 +1970,7 @@
if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false))
return;
- if (SS.isSet() && Tok.isNot(tok::identifier)) {
+ if (SS.isSet() && !Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
if (Tok.isNot(tok::l_brace)) {
// Has no name and is not a definition.
@@ -1990,7 +1992,7 @@
}
// Must have either 'enum name' or 'enum {...}'.
- if (Tok.isNot(tok::identifier) && Tok.isNot(tok::l_brace)) {
+ if (!Tok.isIdentifier() && Tok.isNot(tok::l_brace)) {
Diag(Tok, diag::err_expected_ident_lbrace);
// Skip the rest of this declarator, up until the comma or semicolon.
@@ -2001,7 +2003,7 @@
// If an identifier is present, consume and remember it.
IdentifierInfo *Name = 0;
SourceLocation NameLoc;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
Name = Tok.getIdentifierInfo();
NameLoc = ConsumeToken();
}
@@ -2180,7 +2182,7 @@
Decl *LastEnumConstDecl = 0;
// Parse the enumerator-list.
- while (Tok.is(tok::identifier)) {
+ while (Tok.isIdentifier()) {
IdentifierInfo *Ident = Tok.getIdentifierInfo();
SourceLocation IdentLoc = ConsumeToken();
@@ -2207,7 +2209,7 @@
EnumConstantDecls.push_back(EnumConstDecl);
LastEnumConstDecl = EnumConstDecl;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
// We're missing a comma between enumerators.
SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
Diag(Loc, diag::err_enumerator_list_missing_comma)
@@ -2219,7 +2221,7 @@
break;
SourceLocation CommaLoc = ConsumeToken();
- if (Tok.isNot(tok::identifier) &&
+ if (!Tok.isIdentifier() &&
!(getLang().C99 || getLang().CPlusPlus0x))
Diag(CommaLoc, diag::ext_enumerator_list_comma)
<< getLang().CPlusPlus
@@ -2303,6 +2305,7 @@
default: return false;
case tok::identifier: // foo::bar
+ case tok::raw_identifier:
if (TryAltiVecVectorToken())
return true;
// Fall through.
@@ -2311,7 +2314,7 @@
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return true;
- if (Tok.is(tok::identifier))
+ if (Tok.isIdentifier())
return false;
return isTypeSpecifierQualifier();
@@ -2392,6 +2395,7 @@
default: return false;
case tok::identifier: // foo::bar
+ case tok::raw_identifier:
// Unfortunate hack to support "Class.factoryMethod" notation.
if (getLang().ObjC1 && NextToken().is(tok::period))
return false;
@@ -2403,7 +2407,7 @@
// recurse to handle whatever we get.
if (TryAnnotateTypeOrScopeToken())
return true;
- if (Tok.is(tok::identifier))
+ if (Tok.isIdentifier())
return false;
// If we're in Objective-C and we have an Objective-C class type followed
@@ -2515,7 +2519,7 @@
}
// Parse the constructor name.
- if (Tok.is(tok::identifier) || Tok.is(tok::annot_template_id)) {
+ if (Tok.isIdentifier() || Tok.is(tok::annot_template_id)) {
// We already know that we have a constructor name; just consume
// the token.
ConsumeToken();
@@ -2677,7 +2681,7 @@
// Member pointers get special handling, since there's no place for the
// scope spec in the generic path below.
if (getLang().CPlusPlus &&
- (Tok.is(tok::coloncolon) || Tok.is(tok::identifier) ||
+ (Tok.is(tok::coloncolon) || Tok.isIdentifier() ||
Tok.is(tok::annot_cxxscope))) {
CXXScopeSpec SS;
ParseOptionalCXXScopeSpecifier(SS, ParsedType(), true); // ignore fail
@@ -2849,7 +2853,7 @@
DeclScopeObj.EnterDeclaratorScope();
}
- if (Tok.is(tok::identifier) || Tok.is(tok::kw_operator) ||
+ if (Tok.isIdentifier() || Tok.is(tok::kw_operator) ||
Tok.is(tok::annot_template_id) || Tok.is(tok::tilde)) {
// We found something that indicates the start of an unqualified-id.
// Parse that unqualified-id.
@@ -2883,7 +2887,7 @@
}
goto PastIdentifier;
}
- } else if (Tok.is(tok::identifier) && D.mayHaveIdentifier()) {
+ } else if (Tok.isIdentifier() && D.mayHaveIdentifier()) {
assert(!getLang().CPlusPlus &&
"There's a C++-specific check for tok::identifier above");
assert(Tok.getIdentifierInfo() && "Not an identifier?");
@@ -3149,7 +3153,7 @@
// Alternatively, this parameter list may be an identifier list form for a
// K&R-style function: void foo(a,b,c)
- if (!getLang().CPlusPlus && Tok.is(tok::identifier)
+ if (!getLang().CPlusPlus && Tok.isIdentifier()
&& !TryAltiVecVectorToken()) {
if (TryAnnotateTypeOrScopeToken() || !Tok.is(tok::annot_typename)) {
// K&R identifier lists can't have typedefs as identifiers, per
@@ -3423,7 +3427,7 @@
ConsumeToken();
// If this isn't an identifier, report the error and skip until ')'.
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::r_paren);
return;
@@ -3660,6 +3664,7 @@
Tok.setKind(tok::kw___vector);
return true;
case tok::identifier:
+ case tok::raw_identifier:
if (Next.getIdentifierInfo() == Ident_pixel) {
Tok.setKind(tok::kw___vector);
return true;
@@ -3688,6 +3693,7 @@
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID);
return true;
case tok::identifier:
+ case tok::raw_identifier:
if (Next.getIdentifierInfo() == Ident_pixel) {
isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID);
return true;
Index: lib/Parse/ParseTemplate.cpp
===================================================================
--- lib/Parse/ParseTemplate.cpp (revision 120900)
+++ lib/Parse/ParseTemplate.cpp (working copy)
@@ -368,6 +368,7 @@
return true;
case tok::identifier:
+ case tok::raw_identifier:
// This may be either a type-parameter or an elaborated-type-specifier.
// We have to look further.
break;
@@ -400,7 +401,7 @@
Token Next = NextToken();
// If we have an identifier, skip over it.
- if (Next.getKind() == tok::identifier)
+ if (Next.isIdentifier())
Next = GetLookAheadToken(2);
switch (Next.getKind()) {
@@ -473,7 +474,7 @@
// Grab the template parameter name (if given)
SourceLocation NameLoc;
IdentifierInfo* ParamName = 0;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
ParamName = Tok.getIdentifierInfo();
NameLoc = ConsumeToken();
} else if (Tok.is(tok::equal) || Tok.is(tok::comma) ||
@@ -534,7 +535,7 @@
// Get the identifier, if given.
SourceLocation NameLoc;
IdentifierInfo* ParamName = 0;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
ParamName = Tok.getIdentifierInfo();
NameLoc = ConsumeToken();
} else if (Tok.is(tok::equal) || Tok.is(tok::comma) || Tok.is(tok::greater)) {
@@ -885,7 +886,7 @@
/// \brief Parse a C++ template template argument.
ParsedTemplateArgument Parser::ParseTemplateTemplateArgument() {
- if (!Tok.is(tok::identifier) && !Tok.is(tok::coloncolon) &&
+ if (!Tok.isIdentifier() && !Tok.is(tok::coloncolon) &&
!Tok.is(tok::annot_cxxscope))
return ParsedTemplateArgument();
@@ -909,7 +910,7 @@
// nested-name-specifier.
SourceLocation TemplateLoc = ConsumeToken();
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
// We appear to have a dependent template name.
UnqualifiedId Name;
Name.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
@@ -927,7 +928,7 @@
Template))
return ParsedTemplateArgument(SS, Template, Name.StartLocation);
}
- } else if (Tok.is(tok::identifier)) {
+ } else if (Tok.isIdentifier()) {
// We may have a (non-dependent) template name.
TemplateTy Template;
UnqualifiedId Name;
Index: lib/Parse/ParseObjc.cpp
===================================================================
--- lib/Parse/ParseObjc.cpp (revision 120900)
+++ lib/Parse/ParseObjc.cpp (working copy)
@@ -72,7 +72,7 @@
while (1) {
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::semi);
return 0;
@@ -136,7 +136,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident); // missing class or category name.
return 0;
}
@@ -155,7 +155,7 @@
}
// For ObjC2, the category name is optional (not an error).
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
categoryId = Tok.getIdentifierInfo();
categoryLoc = ConsumeToken();
}
@@ -209,7 +209,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident); // missing super class name.
return 0;
}
@@ -624,6 +624,7 @@
}
case tok::identifier:
+ case tok::raw_identifier:
case tok::kw_asm:
case tok::kw_auto:
case tok::kw_bool:
@@ -704,7 +705,7 @@
// FIXME: May have to do additional look-ahead to only allow for
// valid tokens following an 'in'; such as an identifier, unary operators,
// '[' etc.
- return (getLang().ObjC2 && Tok.is(tok::identifier) &&
+ return (getLang().ObjC2 && Tok.isIdentifier() &&
Tok.getIdentifierInfo() == ObjCTypeQuals[objc_in]);
}
@@ -723,7 +724,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.isNot(tok::identifier))
+ if (!Tok.isIdentifier())
return;
const IdentifierInfo *II = Tok.getIdentifierInfo();
@@ -909,7 +910,7 @@
break;
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident); // missing argument name.
break;
}
@@ -1006,7 +1007,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::greater);
return true;
@@ -1197,7 +1198,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident); // missing protocol name.
return 0;
}
@@ -1219,7 +1220,7 @@
// Parse the list of forward declarations.
while (1) {
ConsumeToken(); // the ','
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::semi);
return 0;
@@ -1283,7 +1284,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident); // missing class or category name.
return 0;
}
@@ -1302,7 +1303,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
categoryId = Tok.getIdentifierInfo();
categoryLoc = ConsumeToken();
} else {
@@ -1328,7 +1329,7 @@
if (Tok.is(tok::colon)) {
// We have a super class
ConsumeToken();
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident); // missing super class name.
return 0;
}
@@ -1381,13 +1382,13 @@
assert(Tok.isObjCAtKeyword(tok::objc_compatibility_alias) &&
"ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
ConsumeToken(); // consume compatibility_alias
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
return 0;
}
IdentifierInfo *aliasId = Tok.getIdentifierInfo();
SourceLocation aliasLoc = ConsumeToken(); // consume alias-name
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
return 0;
}
@@ -1423,7 +1424,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_synthesized_property_name);
SkipUntil(tok::semi);
return 0;
@@ -1443,7 +1444,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
break;
}
@@ -1482,7 +1483,7 @@
ConsumeCodeCompletionToken();
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::semi);
return 0;
@@ -1811,7 +1812,7 @@
bool Parser::ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr) {
InMessageExpressionRAIIObject InMessage(*this, true);
- if (Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
+ if (Tok.isIdentifier() || Tok.is(tok::coloncolon) ||
Tok.is(tok::kw_typename) || Tok.is(tok::annot_cxxscope))
TryAnnotateTypeOrScopeToken();
@@ -1881,12 +1882,12 @@
bool Parser::isSimpleObjCMessageExpression() {
assert(Tok.is(tok::l_square) && getLang().ObjC1 &&
"Incorrect start for isSimpleObjCMessageExpression");
- return GetLookAheadToken(1).is(tok::identifier) &&
- GetLookAheadToken(2).is(tok::identifier);
+ return GetLookAheadToken(1).isIdentifier() &&
+ GetLookAheadToken(2).isIdentifier();
}
bool Parser::isStartOfObjCClassMessageMissingOpenBracket() {
- if (!getLang().ObjC1 || !NextToken().is(tok::identifier) ||
+ if (!getLang().ObjC1 || !NextToken().isIdentifier() ||
InMessageExpression)
return false;
@@ -1895,7 +1896,7 @@
if (Tok.is(tok::annot_typename))
Type = getTypeAnnotation(Tok);
- else if (Tok.is(tok::identifier))
+ else if (Tok.isIdentifier())
Type = Actions.getTypeName(*Tok.getIdentifierInfo(), Tok.getLocation(),
getCurScope());
else
@@ -1904,7 +1905,7 @@
if (!Type.get().isNull() && Type.get()->isObjCObjectOrInterfaceType()) {
const Token &AfterNext = GetLookAheadToken(2);
if (AfterNext.is(tok::colon) || AfterNext.is(tok::r_square)) {
- if (Tok.is(tok::identifier))
+ if (Tok.isIdentifier())
TryAnnotateTypeOrScopeToken();
return Tok.is(tok::annot_typename);
@@ -1943,7 +1944,7 @@
// Handle send to super.
// FIXME: This doesn't benefit from the same typo-correction we
// get in Objective-C.
- if (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_super &&
+ if (Tok.isIdentifier() && Tok.getIdentifierInfo() == Ident_super &&
NextToken().isNot(tok::period) && getCurScope()->isInObjcMethodScope())
return ParseObjCMessageExpressionBody(LBracLoc, ConsumeToken(),
ParsedType(), 0);
@@ -1966,7 +1967,7 @@
0);
}
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
IdentifierInfo *Name = Tok.getIdentifierInfo();
SourceLocation NameLoc = Tok.getLocation();
ParsedType ReceiverType;
@@ -2179,7 +2180,7 @@
}
if (Tok.isNot(tok::r_square)) {
- if (Tok.is(tok::identifier))
+ if (Tok.isIdentifier())
Diag(Tok, diag::err_expected_colon);
else
Diag(Tok, diag::err_expected_rsquare);
@@ -2281,7 +2282,7 @@
SourceLocation LParenLoc = ConsumeParen();
- if (Tok.isNot(tok::identifier))
+ if (!Tok.isIdentifier())
return ExprError(Diag(Tok, diag::err_expected_ident));
IdentifierInfo *protocolId = Tok.getIdentifierInfo();
Index: lib/Parse/ParseExpr.cpp
===================================================================
--- lib/Parse/ParseExpr.cpp (revision 120900)
+++ lib/Parse/ParseExpr.cpp (working copy)
@@ -609,7 +609,9 @@
case tok::kw_nullptr:
return Actions.ActOnCXXNullPtrLiteral(ConsumeToken());
- case tok::identifier: { // primary-expression: identifier
+ case tok::identifier:
+ case tok::raw_identifier: { // primary-expression: identifier
+ // primary-expression: identifier
// unqualified-id: identifier
// constant: enumeration-constant
// Turn a potentially qualified name into a annot_typename or
@@ -625,7 +627,7 @@
// If TryAnnotateTypeOrScopeToken annotates the token, tail recurse.
if (TryAnnotateTypeOrScopeToken())
return ExprError();
- if (!Tok.is(tok::identifier))
+ if (!Tok.isIdentifier())
return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
}
}
@@ -642,7 +644,7 @@
(&II == Ident_super && getCurScope()->isInObjcMethodScope()))) {
SourceLocation DotLoc = ConsumeToken();
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_property_name);
return ExprError();
}
@@ -660,7 +662,7 @@
// bracket. Treat it as such.
if (getLang().ObjC1 && &II == Ident_super && !InMessageExpression &&
getCurScope()->isInObjcMethodScope() &&
- ((Tok.is(tok::identifier) &&
+ ((Tok.isIdentifier() &&
(NextToken().is(tok::colon) || NextToken().is(tok::r_square))) ||
Tok.is(tok::code_completion))) {
Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc, ParsedType(),
@@ -671,7 +673,7 @@
// If we have an Objective-C class name followed by an identifier and
// either ':' or ']', this is an Objective-C class message send that's
// missing the opening '['. Recovery appropriately.
- if (getLang().ObjC1 && Tok.is(tok::identifier) && !InMessageExpression) {
+ if (getLang().ObjC1 && Tok.isIdentifier() && !InMessageExpression) {
const Token& Next = NextToken();
if (Next.is(tok::colon) || Next.is(tok::r_square))
if (ParsedType Typ = Actions.getTypeName(II, ILoc, getCurScope()))
@@ -786,7 +788,7 @@
return ParseSizeofAlignofExpression();
case tok::ampamp: { // unary-expression: '&&' identifier
SourceLocation AmpAmpLoc = ConsumeToken();
- if (Tok.isNot(tok::identifier))
+ if (!Tok.isIdentifier())
return ExprError(Diag(Tok, diag::err_expected_ident));
Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
@@ -1047,6 +1049,7 @@
break;
case tok::identifier:
+ case tok::raw_identifier:
// If we see identifier: after an expression, and we're not already in a
// message send, then this is probably a message send with a missing
// opening bracket '['.
@@ -1384,7 +1387,7 @@
return ExprError();
// We must have at least one identifier here.
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::r_paren);
return ExprError();
@@ -1406,7 +1409,7 @@
Comps.back().isBrackets = false;
Comps.back().LocStart = ConsumeToken();
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::r_paren);
return ExprError();
@@ -1569,7 +1572,7 @@
// If our type is followed by an identifier and either ':' or ']', then
// this is probably an Objective-C message send where the leading '[' is
// missing. Recover as if that were the case.
- if (!Ty.isInvalid() && Tok.is(tok::identifier) && !InMessageExpression &&
+ if (!Ty.isInvalid() && Tok.isIdentifier() && !InMessageExpression &&
getLang().ObjC1 && !Ty.get().get().isNull() &&
(NextToken().is(tok::colon) || NextToken().is(tok::r_square)) &&
Ty.get().get()->isObjCObjectOrInterfaceType()) {
@@ -1602,7 +1605,7 @@
return ExprResult();
// Reject the cast of super idiom in ObjC.
- if (Tok.is(tok::identifier) && getLang().ObjC1 &&
+ if (Tok.isIdentifier() && getLang().ObjC1 &&
Tok.getIdentifierInfo() == Ident_super &&
getCurScope()->isInObjcMethodScope() &&
GetLookAheadToken(1).isNot(tok::period)) {
Index: lib/Parse/ParseStmt.cpp
===================================================================
--- lib/Parse/ParseStmt.cpp (revision 120900)
+++ lib/Parse/ParseStmt.cpp (working copy)
@@ -104,6 +104,7 @@
return ParseStatementOrDeclaration(Stmts, OnlyStatement);
case tok::identifier:
+ case tok::raw_identifier:
if (NextToken().is(tok::colon)) { // C99 6.8.1: labeled-statement
// identifier ':' statement
return ParseLabeledStatement(AttrList);
@@ -221,7 +222,7 @@
/// [GNU] identifier ':' attributes[opt] statement
///
StmtResult Parser::ParseLabeledStatement(AttributeList *Attr) {
- assert(Tok.is(tok::identifier) && Tok.getIdentifierInfo() &&
+ assert(Tok.isIdentifier() && Tok.getIdentifierInfo() &&
"Not an identifier!");
Token IdentTok = Tok; // Save the whole token.
@@ -1144,7 +1145,7 @@
SourceLocation GotoLoc = ConsumeToken(); // eat the 'goto'.
StmtResult Res;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
Res = Actions.ActOnGotoStmt(GotoLoc, Tok.getLocation(),
Tok.getIdentifierInfo());
ConsumeToken();
@@ -1421,7 +1422,7 @@
if (Tok.is(tok::l_square)) {
SourceLocation Loc = ConsumeBracket();
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::r_paren);
return true;
Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp (revision 120900)
+++ lib/Parse/ParseDeclCXX.cpp (working copy)
@@ -63,7 +63,7 @@
Token attrTok;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
Ident = Tok.getIdentifierInfo();
IdentLoc = ConsumeToken(); // eat the identifier.
}
@@ -156,7 +156,7 @@
// Parse (optional) nested-name-specifier.
ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false);
- if (SS.isInvalid() || Tok.isNot(tok::identifier)) {
+ if (SS.isInvalid() || !Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_namespace_name);
// Skip to end of the definition and eat the ';'.
SkipUntil(tok::semi);
@@ -306,7 +306,7 @@
SourceLocation IdentLoc = SourceLocation();
// Parse namespace-name.
- if (SS.isInvalid() || Tok.isNot(tok::identifier)) {
+ if (SS.isInvalid() || !Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_namespace_name);
// If there was invalid namespace name, skip to end of decl, and eat ';'.
SkipUntil(tok::semi);
@@ -541,7 +541,7 @@
// Fall through to produce an error below.
}
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_class_name);
return true;
}
@@ -729,7 +729,7 @@
if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), true))
DS.SetTypeSpecError();
if (SS.isSet())
- if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id))
+ if (!Tok.isIdentifier() && Tok.isNot(tok::annot_template_id))
Diag(Tok, diag::err_expected_ident);
}
@@ -739,7 +739,7 @@
IdentifierInfo *Name = 0;
SourceLocation NameLoc;
TemplateIdAnnotation *TemplateId = 0;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
Name = Tok.getIdentifierInfo();
NameLoc = ConsumeToken();
@@ -1059,6 +1059,7 @@
case tok::star: // struct foo {...} * P;
case tok::amp: // struct foo {...} & R = ...
case tok::identifier: // struct foo {...} V ;
+ case tok::raw_identifier:
case tok::r_paren: //(struct foo {...} ) {4}
case tok::annot_cxxscope: // struct foo {...} a:: b;
case tok::annot_typename: // struct foo {...} a ::b;
@@ -1297,11 +1298,11 @@
ParsingDeclRAIIObject *TemplateDiags) {
// Access declarations.
if (!TemplateInfo.Kind &&
- (Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) &&
+ (Tok.isIdentifier() || Tok.is(tok::coloncolon)) &&
!TryAnnotateCXXScopeToken() &&
Tok.is(tok::annot_cxxscope)) {
bool isAccessDecl = false;
- if (NextToken().is(tok::identifier))
+ if (NextToken().isIdentifier())
isAccessDecl = GetLookAheadToken(2).is(tok::semi);
else
isAccessDecl = NextToken().is(tok::kw_operator);
@@ -1791,7 +1792,7 @@
break;
// If the next token looks like a base or member initializer, assume that
// we're just missing a comma.
- else if (Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) {
+ else if (Tok.isIdentifier() || Tok.is(tok::coloncolon)) {
SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
Diag(Loc, diag::err_ctor_init_missing_comma)
<< FixItHint::CreateInsertion(Loc, ", ");
@@ -1834,14 +1835,14 @@
TemplateTypeTy = getTypeAnnotation(Tok);
}
}
- if (!TemplateTypeTy && Tok.isNot(tok::identifier)) {
+ if (!TemplateTypeTy && !Tok.isIdentifier()) {
Diag(Tok, diag::err_expected_member_or_base_name);
return true;
}
// Get the identifier. This may be a member name or a class name,
// but we'll let the semantic analysis determine which it is.
- IdentifierInfo *II = Tok.is(tok::identifier) ? Tok.getIdentifierInfo() : 0;
+ IdentifierInfo *II = Tok.isIdentifier() ? Tok.getIdentifierInfo() : 0;
SourceLocation IdLoc = ConsumeToken();
// Parse the '('.
@@ -2047,7 +2048,7 @@
ConsumeToken();
}
- while (Tok.is(tok::identifier) || Tok.is(tok::comma)) {
+ while (Tok.isIdentifier() || Tok.is(tok::comma)) {
// attribute not present
if (Tok.is(tok::comma)) {
ConsumeToken();
@@ -2061,7 +2062,7 @@
if (Tok.is(tok::coloncolon)) {
ConsumeToken();
- if (!Tok.is(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok.getLocation(), diag::err_expected_ident);
SkipUntil(tok::r_square, tok::comma, true, true);
continue;
Index: lib/Parse/ParseExprCXX.cpp
===================================================================
--- lib/Parse/ParseExprCXX.cpp (revision 120900)
+++ lib/Parse/ParseExprCXX.cpp (working copy)
@@ -130,7 +130,7 @@
SourceLocation TemplateKWLoc = ConsumeToken();
UnqualifiedId TemplateName;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
// Consume the identifier.
TemplateName.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
ConsumeToken();
@@ -230,7 +230,7 @@
// The rest of the nested-name-specifier possibilities start with
// tok::identifier.
- if (Tok.isNot(tok::identifier))
+ if (!Tok.isIdentifier())
break;
IdentifierInfo &II = *Tok.getIdentifierInfo();
@@ -249,7 +249,7 @@
// If the token after the colon isn't an identifier, it's still an
// error, but they probably meant something else strange so don't
// recover like this.
- PP.LookAhead(1).is(tok::identifier)) {
+ PP.LookAhead(1).isIdentifier()) {
Diag(Next, diag::err_unexected_colon_in_nested_name_spec)
<< FixItHint::CreateReplacement(Next.getLocation(), "::");
@@ -613,7 +613,7 @@
// been coalesced into a template-id annotation token.
UnqualifiedId FirstTypeName;
SourceLocation CCLoc;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
FirstTypeName.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
ConsumeToken();
assert(Tok.is(tok::coloncolon) &&"ParseOptionalCXXScopeSpecifier fail");
@@ -631,7 +631,7 @@
// Parse the tilde.
assert(Tok.is(tok::tilde) && "ParseOptionalCXXScopeSpecifier fail");
SourceLocation TildeLoc = ConsumeToken();
- if (!Tok.is(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_destructor_tilde_identifier);
return ExprError();
}
@@ -904,6 +904,7 @@
switch (Tok.getKind()) {
case tok::identifier: // foo::bar
+ case tok::raw_identifier:
case tok::coloncolon: // ::foo::bar
assert(0 && "Annotation token should already be formed!");
default:
@@ -1356,7 +1357,7 @@
Diag(Tok.getLocation(), diag::err_operator_string_not_empty);
ConsumeStringToken();
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok.getLocation(), diag::err_expected_ident);
return true;
}
@@ -1447,7 +1448,7 @@
// unqualified-id:
// identifier
// template-id (when it hasn't already been annotated)
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
// Consume the identifier.
IdentifierInfo *Id = Tok.getIdentifierInfo();
SourceLocation IdLoc = ConsumeToken();
@@ -1555,7 +1556,7 @@
SourceLocation TildeLoc = ConsumeToken();
// Parse the class-name.
- if (Tok.isNot(tok::identifier)) {
+ if (!Tok.isIdentifier()) {
Diag(Tok, diag::err_destructor_tilde_identifier);
return true;
}
Index: lib/Parse/Parser.cpp
===================================================================
--- lib/Parse/Parser.cpp (revision 120900)
+++ lib/Parse/Parser.cpp (working copy)
@@ -992,7 +992,7 @@
/// Note that this routine emits an error if you call it with ::new or ::delete
/// as the current tokens, so only call it in contexts where these are invalid.
bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext) {
- assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)
+ assert((Tok.isIdentifier() || Tok.is(tok::coloncolon)
|| Tok.is(tok::kw_typename) || Tok.is(tok::annot_cxxscope)) &&
"Cannot be a type or scope token!");
@@ -1013,7 +1013,7 @@
}
TypeResult Ty;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
// FIXME: check whether the next token is '<', first!
Ty = Actions.ActOnTypenameType(getCurScope(), TypenameLoc, SS,
*Tok.getIdentifierInfo(),
@@ -1059,7 +1059,7 @@
if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(), EnteringContext))
return true;
- if (Tok.is(tok::identifier)) {
+ if (Tok.isIdentifier()) {
// Determine whether the identifier is a type name.
if (ParsedType Ty = Actions.getTypeName(*Tok.getIdentifierInfo(),
Tok.getLocation(), getCurScope(),
@@ -1159,7 +1159,7 @@
bool Parser::TryAnnotateCXXScopeToken(bool EnteringContext) {
assert(getLang().CPlusPlus &&
"Call sites of this function should be guarded by checking for C++");
- assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon)) &&
+ assert((Tok.isIdentifier() || Tok.is(tok::coloncolon)) &&
"Cannot be a type or scope token!");
CXXScopeSpec SS;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits