]> granicus.if.org Git - clang/commitdiff
Replace a bool with an enum for clarity, based on review comment from James Dennett.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 26 Sep 2013 04:19:11 +0000 (04:19 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 26 Sep 2013 04:19:11 +0000 (04:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191420 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/LiteralSupport.h
lib/Lex/LiteralSupport.cpp

index ccc29ae7e886a0394c3ad13d42b76d4c53706e5e..64d5aa2d59287f4a9ba39b34efe714c079f8dfbc 100644 (file)
@@ -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.
index e2ff6d6317b2d9d7b4b3bb3972275191991256e3..fce3ff3f5fa0cf632279871c9942d23bbac9fcea 100644 (file)
@@ -498,19 +498,19 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
       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::NumericLiteralParser(StringRef TokSpelling,
   }
 
   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::isValidUDSuffix(const LangOptions &LangOpts,
 }
 
 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 {