[Lldb-commits] [lldb] [LLDB] Update DIL to pass current 'frame var' tests. (PR #145055)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 23 02:32:18 PDT 2025


================
@@ -178,11 +178,40 @@ ASTNodeUP DILParser::ParsePrimaryExpression() {
   }
 
   if (CurToken().Is(Token::l_paren)) {
-    m_dil_lexer.Advance();
-    auto expr = ParseExpression();
-    Expect(Token::r_paren);
-    m_dil_lexer.Advance();
-    return expr;
+    // Check in case this is an anonynmous namespace
+    if (m_dil_lexer.LookAhead(1).Is(Token::identifier) &&
+        (m_dil_lexer.LookAhead(1).GetSpelling() == "anonymous") &&
+        m_dil_lexer.LookAhead(2).Is(Token::identifier) &&
+        (m_dil_lexer.LookAhead(2).GetSpelling() == "namespace") &&
+        m_dil_lexer.LookAhead(3).Is(Token::r_paren) &&
+        m_dil_lexer.LookAhead(4).Is(Token::coloncolon)) {
+      m_dil_lexer.Advance(4);
+
+      std::string identifier = "(anonymous namespace)";
+      Expect(Token::coloncolon);
+      // Save the source location for the diagnostics message.
+      uint32_t loc = CurToken().GetLocation();
+      m_dil_lexer.Advance();
+      assert(
+          (CurToken().Is(Token::identifier) || CurToken().Is(Token::l_paren)) &&
+          "Expected an identifier or anonymous namespeace, but not found.");
----------------
labath wrote:

```
(lldb) frame variable 'lldb::(anonymous namespace)::a'
lldb: /home/pavelo/ll/mono/lldb/source/ValueObject/DILParser.cpp:235: std::string lldb_private::dil::DILP
arser::ParseNestedNameSpecifier(): Assertion `(CurToken().Is(Token::identifier) || CurToken().Is(Token::l
_paren)) && "Expected an identifier or anonymous namespace, but not found."' failed.
```

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


More information about the lldb-commits mailing list