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

via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 24 17:38:36 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Mike Rice (mikerice1969)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/96579.diff


1 Files Affected:

- (modified) clang/lib/Lex/LiteralSupport.cpp (+3-2) 


``````````diff
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 __

``````````

</details>


https://github.com/llvm/llvm-project/pull/96579


More information about the cfe-commits mailing list