]> granicus.if.org Git - clang/commitdiff
Document assumptions that NumericLiteralParser makes with an assertion.
authorChris Lattner <sabre@nondot.org>
Tue, 30 Sep 2008 20:45:40 +0000 (20:45 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 30 Sep 2008 20:45:40 +0000 (20:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56876 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/LiteralSupport.cpp

index a66aaa2010a3a10da0c200209c115c167c7c22bb..f63e6cfffc0dd4073bff44f443b255edc4b1d98b 100644 (file)
@@ -86,7 +86,8 @@ static unsigned ProcessCharEscape(const char *&ThisTokBuf,
     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::
 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;