[cfe-commits] r56876 - /cfe/trunk/lib/Lex/LiteralSupport.cpp

Chris Lattner sabre at nondot.org
Tue Sep 30 13:45:40 PDT 2008


Author: lattner
Date: Tue Sep 30 15:45:40 2008
New Revision: 56876

URL: http://llvm.org/viewvc/llvm-project?rev=56876&view=rev
Log:
Document assumptions that NumericLiteralParser makes with an assertion.

Modified:
    cfe/trunk/lib/Lex/LiteralSupport.cpp

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=56876&r1=56875&r2=56876&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue Sep 30 15:45:40 2008
@@ -86,7 +86,8 @@
     for (; ThisTokBuf != ThisTokEnd; ++ThisTokBuf) {
       int CharVal = HexDigitValue(ThisTokBuf[0]);
       if (CharVal == -1) break;
-      Overflow |= (ResultChar & 0xF0000000) ? true : false;  // About to shift out a digit?
+      // About to shift out a digit?
+      Overflow |= (ResultChar & 0xF0000000) ? true : false;
       ResultChar <<= 4;
       ResultChar |= CharVal;
     }
@@ -196,6 +197,14 @@
 NumericLiteralParser(const char *begin, const char *end,
                      SourceLocation TokLoc, Preprocessor &pp)
   : PP(pp), ThisTokBegin(begin), ThisTokEnd(end) {
+    
+  // This routine assumes that the range begin/end matches the regex for integer
+  // and FP constants (specifically, the 'pp-number' regex), and assumes that
+  // the byte at "*end" is both valid and not part of the regex.  Because of
+  // this, it doesn't have to check for 'overscan' in various places.
+  assert(!isalnum(*end) && *end != '.' && *end != '_' &&
+         "Lexer didn't maximally munch?");
+    
   s = DigitsBegin = begin;
   saw_exponent = false;
   saw_period = false;





More information about the cfe-commits mailing list