Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

mikerice1969
Copy link
Contributor

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

Address static verifier concerns about dead code in DoubleUnderscore
check. Replace it with an assert.
@mikerice1969 mikerice1969 requested a review from Sirraide June 25, 2024 00:38
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jun 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 25, 2024

@llvm/pr-subscribers-clang

Author: Mike Rice (mikerice1969)

Changes

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

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mikerice1969 mikerice1969 merged commit 54b61ad into llvm:main Jun 25, 2024
10 checks passed
@mikerice1969 mikerice1969 deleted the double-underscore-assert branch June 25, 2024 14:14
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…rt (llvm#96579)

Address static verifier concerns about dead code in DoubleUnderscore
check. Replace it with an assert.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants