Skip to content

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