]> granicus.if.org Git - clang/commitdiff
factor a common predicate into a static method.
authorChris Lattner <sabre@nondot.org>
Mon, 16 Jul 2007 06:16:59 +0000 (06:16 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 16 Jul 2007 06:16:59 +0000 (06:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39903 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Lexer.h

index eda96080163f74e1582bdf2128e235321b1a0b28..4a8965efa2a486c4eed62ebb0f7ccf22b589cd69 100644 (file)
@@ -216,6 +216,13 @@ private:
   // 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 @@ private:
   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 @@ private:
   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 @@ private:
                                           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;
     }