marsupial created this revision.

The fix in r303372 exposed a problem when using **Parser::ConsumeToken** from 
client code in DEBUG.
**ConsumeToken** will assert for all **isTokenSpecial()** cases, but there is 
no way to call the proper method.

The isToken methods are just convenient.


https://reviews.llvm.org/D36702

Files:
  include/clang/Parse/Parser.h


Index: include/clang/Parse/Parser.h
===================================================================
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -348,11 +348,6 @@
     return Actions.getNullabilityKeyword(nullability);
   }
 
-private:
-  
//===--------------------------------------------------------------------===//
-  // Low-Level token peeking and consumption methods.
-  //
-
   /// isTokenParen - Return true if the cur token is '(' or ')'.
   bool isTokenParen() const {
     return Tok.isOneOf(tok::l_paren, tok::r_paren);
@@ -375,19 +370,6 @@
            isTokenBrace() || Tok.is(tok::code_completion) || 
Tok.isAnnotation();
   }
 
-  /// \brief Returns true if the current token is '=' or is a type of '='.
-  /// For typos, give a fixit to '='
-  bool isTokenEqualOrEqualTypo();
-
-  /// \brief Return the current token to the token stream and make the given
-  /// token the current token.
-  void UnconsumeToken(Token &Consumed) {
-      Token Next = Tok;
-      PP.EnterToken(Consumed);
-      PP.Lex(Tok);
-      PP.EnterToken(Next);
-  }
-
   /// ConsumeAnyToken - Dispatch to the right Consume* method based on the
   /// current token type.  This should only be used in cases where the type of
   /// the token really isn't known, e.g. in error recovery.
@@ -481,6 +463,24 @@
     return PrevTokLocation;
   }
 
+private:
+  
//===--------------------------------------------------------------------===//
+  // Low-Level token peeking and consumption methods.
+  //
+
+  /// \brief Returns true if the current token is '=' or is a type of '='.
+  /// For typos, give a fixit to '='
+  bool isTokenEqualOrEqualTypo();
+
+  /// \brief Return the current token to the token stream and make the given
+  /// token the current token.
+  void UnconsumeToken(Token &Consumed) {
+      Token Next = Tok;
+      PP.EnterToken(Consumed);
+      PP.Lex(Tok);
+      PP.EnterToken(Next);
+  }
+
   ///\ brief When we are consuming a code-completion token without having
   /// matched specific position in the grammar, provide code-completion results
   /// based on context.


Index: include/clang/Parse/Parser.h
===================================================================
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -348,11 +348,6 @@
     return Actions.getNullabilityKeyword(nullability);
   }
 
-private:
-  //===--------------------------------------------------------------------===//
-  // Low-Level token peeking and consumption methods.
-  //
-
   /// isTokenParen - Return true if the cur token is '(' or ')'.
   bool isTokenParen() const {
     return Tok.isOneOf(tok::l_paren, tok::r_paren);
@@ -375,19 +370,6 @@
            isTokenBrace() || Tok.is(tok::code_completion) || Tok.isAnnotation();
   }
 
-  /// \brief Returns true if the current token is '=' or is a type of '='.
-  /// For typos, give a fixit to '='
-  bool isTokenEqualOrEqualTypo();
-
-  /// \brief Return the current token to the token stream and make the given
-  /// token the current token.
-  void UnconsumeToken(Token &Consumed) {
-      Token Next = Tok;
-      PP.EnterToken(Consumed);
-      PP.Lex(Tok);
-      PP.EnterToken(Next);
-  }
-
   /// ConsumeAnyToken - Dispatch to the right Consume* method based on the
   /// current token type.  This should only be used in cases where the type of
   /// the token really isn't known, e.g. in error recovery.
@@ -481,6 +463,24 @@
     return PrevTokLocation;
   }
 
+private:
+  //===--------------------------------------------------------------------===//
+  // Low-Level token peeking and consumption methods.
+  //
+
+  /// \brief Returns true if the current token is '=' or is a type of '='.
+  /// For typos, give a fixit to '='
+  bool isTokenEqualOrEqualTypo();
+
+  /// \brief Return the current token to the token stream and make the given
+  /// token the current token.
+  void UnconsumeToken(Token &Consumed) {
+      Token Next = Tok;
+      PP.EnterToken(Consumed);
+      PP.Lex(Tok);
+      PP.EnterToken(Next);
+  }
+
   ///\ brief When we are consuming a code-completion token without having
   /// matched specific position in the grammar, provide code-completion results
   /// based on context.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to