[clang] 54b61ad - [NFC][clang] Replace unreachable code in literal processing with assert (#96579)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 07:15:09 PDT 2024


Author: Mike Rice
Date: 2024-06-25T07:14:40-07:00
New Revision: 54b61adc0cbefb7f923ef43c407704ba9f9d8b69

URL: https://github.com/llvm/llvm-project/commit/54b61adc0cbefb7f923ef43c407704ba9f9d8b69
DIFF: https://github.com/llvm/llvm-project/commit/54b61adc0cbefb7f923ef43c407704ba9f9d8b69.diff

LOG: [NFC][clang] Replace unreachable code in literal processing with assert (#96579)

Address static verifier concerns about dead code in DoubleUnderscore
check. Replace it with an assert.

Added: 
    

Modified: 
    clang/lib/Lex/LiteralSupport.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index 3df0391bdda77..9d2720af5dbd9 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1123,8 +1123,9 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
         break; // Invalid for floats
       if (HasSize)
         break;
-      if (DoubleUnderscore)
-        break; // Cannot be repeated.
+      // There is currently no way to reach this with DoubleUnderscore set.
+      // If new double underscope literals are added handle it here as above.
+      assert(!DoubleUnderscore && "unhandled double underscore case");
       if (LangOpts.CPlusPlus && s + 2 < ThisTokEnd &&
           s[1] == '_') { // s + 2 < ThisTokEnd to ensure some character exists
                          // after __


        


More information about the cfe-commits mailing list