[Lldb-commits] [lldb] [LLDB] Add `ScalarLiteralNode` and literal parsing in DIL (PR #152308)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 26 03:52:51 PDT 2025


================
@@ -175,7 +185,27 @@ TEST(DILLexerTests, NumbersTest) {
     EXPECT_THAT_EXPECTED(maybe_lexer, llvm::Succeeded());
     DILLexer lexer(*maybe_lexer);
     Token token = lexer.GetCurrentToken();
-    EXPECT_TRUE(token.IsNot(Token::numeric_constant));
+    EXPECT_TRUE(token.IsNot(Token::integer_constant));
     EXPECT_TRUE(token.IsOneOf({Token::eof, Token::identifier}));
   }
+
+  // Verify that '-' and '+' are not lexed if they're not part of a number
+  std::vector<std::string> expressions = {"1+e",     "0x1+p",      "1.1+e",
----------------
labath wrote:

Yes, that was a surprise to me as well. It seems that msvc accepts this (recognizes it as addition of two integers) but gcc and clang do reject it. I asked around, and it seems that gcc&clang are correct here (the [standard] even explicitly states that `0xe+foo` is a single token).

Given that, I'm not going to insist on this interpretation. I think what you have is fine (we're a different language after all, and I believe C++'s woes come mainly from the preprocessor, which I hope we won't have), but I'd be also fine with reverting those changes for the sake of (bug) compatibility with c++.

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


More information about the lldb-commits mailing list