[cfe-commits] r39903 - /cfe/trunk/include/clang/Lex/Lexer.h

Chris Lattner sabre at nondot.org
Sun Jul 15 23:17:00 PDT 2007


Author: lattner
Date: Mon Jul 16 01:16:59 2007
New Revision: 39903

URL: http://llvm.org/viewvc/llvm-project?rev=39903&view=rev
Log:
factor a common predicate into a static method.

Modified:
    cfe/trunk/include/clang/Lex/Lexer.h

Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=39903&r1=39902&r2=39903&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Mon Jul 16 01:16:59 2007
@@ -216,6 +216,13 @@
   // trigraphs), knowing that they only are emitted if the character is
   // consumed.
   
+  /// isObviouslySimpleCharacter - Return true if the specified character is
+  /// obviously the same in translation phase 1 and translation phase 3.  This
+  /// can return false for characters that end up being the same, but it will
+  /// never return true for something that needs to be mapped.
+  static bool isObviouslySimpleCharacter(char C) {
+    return C != '?' && C != '\\';
+  }
   
   /// getAndAdvanceChar - Read a single 'character' from the specified buffer,
   /// advance over it, and return it.  This is tricky in several cases.  Here we
@@ -224,7 +231,7 @@
   inline char getAndAdvanceChar(const char *&Ptr, LexerToken &Tok) {
     // If this is not a trigraph and not a UCN or escaped newline, return
     // quickly.
-    if (Ptr[0] != '?' && Ptr[0] != '\\') return *Ptr++;
+    if (isObviouslySimpleCharacter(Ptr[0])) return *Ptr++;
     
     unsigned Size = 0;
     char C = getCharAndSizeSlow(Ptr, Size, &Tok);
@@ -255,7 +262,7 @@
   inline char getCharAndSize(const char *Ptr, unsigned &Size) {
     // If this is not a trigraph and not a UCN or escaped newline, return
     // quickly.
-    if (Ptr[0] != '?' && Ptr[0] != '\\') {
+    if (isObviouslySimpleCharacter(Ptr[0])) {
       Size = 1;
       return *Ptr;
     }
@@ -274,7 +281,7 @@
                                           const LangOptions &Features) {
     // If this is not a trigraph and not a UCN or escaped newline, return
     // quickly.
-    if (Ptr[0] != '?' && Ptr[0] != '\\') {
+    if (isObviouslySimpleCharacter(Ptr[0])) {
       Size = 1;
       return *Ptr;
     }





More information about the cfe-commits mailing list