r191420 - Replace a bool with an enum for clarity, based on review comment from James Dennett.

Richard Smith richard-llvm at metafoo.co.uk
Wed Sep 25 21:19:11 PDT 2013


Author: rsmith
Date: Wed Sep 25 23:19:11 2013
New Revision: 191420

URL: http://llvm.org/viewvc/llvm-project?rev=191420&view=rev
Log:
Replace a bool with an enum for clarity, based on review comment from James Dennett.

Modified:
    cfe/trunk/include/clang/Lex/LiteralSupport.h
    cfe/trunk/lib/Lex/LiteralSupport.cpp

Modified: cfe/trunk/include/clang/Lex/LiteralSupport.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/LiteralSupport.h?rev=191420&r1=191419&r2=191420&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/LiteralSupport.h (original)
+++ cfe/trunk/include/clang/Lex/LiteralSupport.h Wed Sep 25 23:19:11 2013
@@ -102,9 +102,11 @@ private:
 
   static bool isDigitSeparator(char C) { return C == '\''; }
 
+  enum CheckSeparatorKind { CSK_BeforeDigits, CSK_AfterDigits };
+
   /// \brief Ensure that we don't have a digit separator here.
   void checkSeparator(SourceLocation TokLoc, const char *Pos,
-                      bool IsAfterDigits);
+                      CheckSeparatorKind IsAfterDigits);
 
   /// SkipHexDigits - Read and skip over any hex digits, up to End.
   /// Return a pointer to the first non-hex digit or End.

Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=191420&r1=191419&r2=191420&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Wed Sep 25 23:19:11 2013
@@ -498,19 +498,19 @@ NumericLiteralParser::NumericLiteralPars
       hadError = true;
       return;
     } else if (*s == '.') {
-      checkSeparator(TokLoc, s, true);
+      checkSeparator(TokLoc, s, CSK_AfterDigits);
       s++;
       saw_period = true;
-      checkSeparator(TokLoc, s, false);
+      checkSeparator(TokLoc, s, CSK_BeforeDigits);
       s = SkipDigits(s);
     }
     if ((*s == 'e' || *s == 'E')) { // exponent
-      checkSeparator(TokLoc, s, true);
+      checkSeparator(TokLoc, s, CSK_AfterDigits);
       const char *Exponent = s;
       s++;
       saw_exponent = true;
       if (*s == '+' || *s == '-')  s++; // sign
-      checkSeparator(TokLoc, s, false);
+      checkSeparator(TokLoc, s, CSK_BeforeDigits);
       const char *first_non_digit = SkipDigits(s);
       if (first_non_digit != s) {
         s = first_non_digit;
@@ -524,7 +524,7 @@ NumericLiteralParser::NumericLiteralPars
   }
 
   SuffixBegin = s;
-  checkSeparator(TokLoc, s, true);
+  checkSeparator(TokLoc, s, CSK_AfterDigits);
 
   // Parse the suffix.  At this point we can classify whether we have an FP or
   // integer constant.
@@ -682,8 +682,9 @@ bool NumericLiteralParser::isValidUDSuff
 }
 
 void NumericLiteralParser::checkSeparator(SourceLocation TokLoc,
-                                          const char *Pos, bool IsAfterDigits) {
-  if (IsAfterDigits) {
+                                          const char *Pos,
+                                          CheckSeparatorKind IsAfterDigits) {
+  if (IsAfterDigits == CSK_AfterDigits) {
     assert(Pos != ThisTokBegin);
     --Pos;
   } else {





More information about the cfe-commits mailing list