[Lldb-commits] [lldb] [lldb] Fix ambiguous ProtocolDescriptor in the MCP unit tests under C++20 (PR #237270)

David Young via lldb-commits lldb-commits at lists.llvm.org
Sat Oct 31 11:34:40 PDT 2026


https://github.com/youngd007 updated https://github.com/llvm/llvm-project/pull/237270

>From 0398fc3a6a5e3a9dc92782f55664748e4cba926f Mon Sep 17 00:00:00 2001
From: David Young <davidayoung at meta.com>
Date: Fri, 30 Oct 2026 09:08:50 -0700
Subject: [PATCH 1/2] [lldb] Fix ambiguous ProtocolDescriptor in the MCP unit
 tests under C++20

When building as C++20, lldb/Host/JSONTransport.h declares the concept
lldb_private::transport::ProtocolDescriptor. MCPClientTest.cpp and
ProtocolMCPServerTest.cpp have using-directives for both that namespace
and lldb_protocol::mcp, so an unqualified ProtocolDescriptor is
ambiguous between the concept and lldb_protocol::mcp::ProtocolDescriptor,
and the tests fail to compile. Qualify the six uses, as
ProtocolMCPServerTest.cpp already does elsewhere. No change under C++17.

assisted with: claude
---
 lldb/unittests/Protocol/MCPClientTest.cpp         |  6 ++++--
 lldb/unittests/Protocol/ProtocolMCPServerTest.cpp | 13 +++++++++----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lldb/unittests/Protocol/MCPClientTest.cpp b/lldb/unittests/Protocol/MCPClientTest.cpp
index c7fa7bb93d9c3f..9f01c9b96fc95e 100644
--- a/lldb/unittests/Protocol/MCPClientTest.cpp
+++ b/lldb/unittests/Protocol/MCPClientTest.cpp
@@ -96,10 +96,12 @@ class MCPClientTest : public testing::Test {
   MainLoop loop;
   std::unique_ptr<Server> server;
   std::unique_ptr<Client> client;
-  TestTransport<ProtocolDescriptor> *client_transport = nullptr;
+  TestTransport<lldb_protocol::mcp::ProtocolDescriptor> *client_transport =
+      nullptr;
 
   void SetUp() override {
-    auto pair = TestTransport<ProtocolDescriptor>::createConnectedPair(loop);
+    auto pair = TestTransport<
+        lldb_protocol::mcp::ProtocolDescriptor>::createConnectedPair(loop);
     client_transport = pair.first.get();
 
     server = std::make_unique<Server>("lldb-mcp", "0.1.0");
diff --git a/lldb/unittests/Protocol/ProtocolMCPServerTest.cpp b/lldb/unittests/Protocol/ProtocolMCPServerTest.cpp
index 4b07682bc5df7a..5adaa5ca961d0b 100644
--- a/lldb/unittests/Protocol/ProtocolMCPServerTest.cpp
+++ b/lldb/unittests/Protocol/ProtocolMCPServerTest.cpp
@@ -426,14 +426,17 @@ TEST_F(ProtocolServerMCPTest, ResourcesReadError) {
 }
 
 TEST_F(ProtocolServerMCPTest, Accept) {
-  auto transports = TestTransport<ProtocolDescriptor>::createPair(loop);
+  auto transports =
+      TestTransport<lldb_protocol::mcp::ProtocolDescriptor>::createPair(loop);
   EXPECT_THAT_ERROR(server_up->Accept(std::move(transports.second)),
                     Succeeded());
 }
 
 TEST_F(ProtocolServerMCPTest, AcceptErrorAndDisconnect) {
-  auto transports = TestTransport<ProtocolDescriptor>::createPair(loop);
-  TestTransport<ProtocolDescriptor> *server_transport = transports.second.get();
+  auto transports =
+      TestTransport<lldb_protocol::mcp::ProtocolDescriptor>::createPair(loop);
+  TestTransport<lldb_protocol::mcp::ProtocolDescriptor> *server_transport =
+      transports.second.get();
   EXPECT_THAT_ERROR(server_up->Accept(std::move(transports.second)),
                     Succeeded());
 
@@ -448,7 +451,9 @@ TEST_F(ProtocolServerMCPTest, AcceptErrorAndDisconnect) {
 }
 
 TEST_F(ProtocolServerMCPTest, AcceptRegisterFailure) {
-  auto transport = std::make_unique<TestTransport<ProtocolDescriptor>>(loop);
+  auto transport =
+      std::make_unique<TestTransport<lldb_protocol::mcp::ProtocolDescriptor>>(
+          loop);
   transport->SetRegisterMessageHandlerShouldFail(true);
   EXPECT_THAT_ERROR(server_up->Accept(std::move(transport)), Failed());
 }

>From 23398f3c008493b8bcf3cf90e33de272c7a2c865 Mon Sep 17 00:00:00 2001
From: David Young <davidayoung at meta.com>
Date: Sat, 31 Oct 2026 11:33:35 -0700
Subject: [PATCH 2/2] [lldb] Use an alias for the MCP test transport

Address review feedback: spelling out
TestTransport<lldb_protocol::mcp::ProtocolDescriptor> made several
declarations wrap. Add an MCPTestTransport alias in MCPClientTest.cpp,
and rename ProtocolMCPServerTest.cpp's existing Transport alias to it.
The old name couldn't be used in the TEST_F bodies, which are outside
the unnamed namespace, because lldb_protocol::mcp::Transport is visible
there too.

assisted with: claude
---
 lldb/unittests/Protocol/MCPClientTest.cpp     |  8 +++----
 .../Protocol/ProtocolMCPServerTest.cpp        | 21 +++++++------------
 2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/lldb/unittests/Protocol/MCPClientTest.cpp b/lldb/unittests/Protocol/MCPClientTest.cpp
index 9f01c9b96fc95e..062a9dc2facfe2 100644
--- a/lldb/unittests/Protocol/MCPClientTest.cpp
+++ b/lldb/unittests/Protocol/MCPClientTest.cpp
@@ -89,6 +89,8 @@ class TestResourceProvider : public ResourceProvider {
   }
 };
 
+using MCPTestTransport = TestTransport<lldb_protocol::mcp::ProtocolDescriptor>;
+
 class MCPClientTest : public testing::Test {
 public:
   SubsystemRAII<FileSystem, HostInfo, Socket> subsystems;
@@ -96,12 +98,10 @@ class MCPClientTest : public testing::Test {
   MainLoop loop;
   std::unique_ptr<Server> server;
   std::unique_ptr<Client> client;
-  TestTransport<lldb_protocol::mcp::ProtocolDescriptor> *client_transport =
-      nullptr;
+  MCPTestTransport *client_transport = nullptr;
 
   void SetUp() override {
-    auto pair = TestTransport<
-        lldb_protocol::mcp::ProtocolDescriptor>::createConnectedPair(loop);
+    auto pair = MCPTestTransport::createConnectedPair(loop);
     client_transport = pair.first.get();
 
     server = std::make_unique<Server>("lldb-mcp", "0.1.0");
diff --git a/lldb/unittests/Protocol/ProtocolMCPServerTest.cpp b/lldb/unittests/Protocol/ProtocolMCPServerTest.cpp
index 5adaa5ca961d0b..cef48d89abed2a 100644
--- a/lldb/unittests/Protocol/ProtocolMCPServerTest.cpp
+++ b/lldb/unittests/Protocol/ProtocolMCPServerTest.cpp
@@ -157,7 +157,7 @@ class TestServer : public Server {
   using Server::Server;
 };
 
-using Transport = TestTransport<lldb_protocol::mcp::ProtocolDescriptor>;
+using MCPTestTransport = TestTransport<lldb_protocol::mcp::ProtocolDescriptor>;
 
 class ProtocolServerMCPTest : public testing::Test {
 public:
@@ -166,11 +166,11 @@ class ProtocolServerMCPTest : public testing::Test {
   MainLoop loop;
   lldb_private::MainLoop::ReadHandleUP handles[2];
 
-  std::unique_ptr<Transport> to_server;
+  std::unique_ptr<MCPTestTransport> to_server;
   MCPBinderUP binder;
   std::unique_ptr<TestServer> server_up;
 
-  std::unique_ptr<Transport> to_client;
+  std::unique_ptr<MCPTestTransport> to_client;
   MockMessageHandler<lldb_protocol::mcp::ProtocolDescriptor> client;
 
   std::vector<std::string> logged_messages;
@@ -184,7 +184,7 @@ class ProtocolServerMCPTest : public testing::Test {
   }
 
   void SetUp() override {
-    std::tie(to_client, to_server) = Transport::createPair(loop);
+    std::tie(to_client, to_server) = MCPTestTransport::createPair(loop);
 
     server_up = std::make_unique<TestServer>(
         "lldb-mcp", "0.1.0",
@@ -426,17 +426,14 @@ TEST_F(ProtocolServerMCPTest, ResourcesReadError) {
 }
 
 TEST_F(ProtocolServerMCPTest, Accept) {
-  auto transports =
-      TestTransport<lldb_protocol::mcp::ProtocolDescriptor>::createPair(loop);
+  auto transports = MCPTestTransport::createPair(loop);
   EXPECT_THAT_ERROR(server_up->Accept(std::move(transports.second)),
                     Succeeded());
 }
 
 TEST_F(ProtocolServerMCPTest, AcceptErrorAndDisconnect) {
-  auto transports =
-      TestTransport<lldb_protocol::mcp::ProtocolDescriptor>::createPair(loop);
-  TestTransport<lldb_protocol::mcp::ProtocolDescriptor> *server_transport =
-      transports.second.get();
+  auto transports = MCPTestTransport::createPair(loop);
+  MCPTestTransport *server_transport = transports.second.get();
   EXPECT_THAT_ERROR(server_up->Accept(std::move(transports.second)),
                     Succeeded());
 
@@ -451,9 +448,7 @@ TEST_F(ProtocolServerMCPTest, AcceptErrorAndDisconnect) {
 }
 
 TEST_F(ProtocolServerMCPTest, AcceptRegisterFailure) {
-  auto transport =
-      std::make_unique<TestTransport<lldb_protocol::mcp::ProtocolDescriptor>>(
-          loop);
+  auto transport = std::make_unique<MCPTestTransport>(loop);
   transport->SetRegisterMessageHandlerShouldFail(true);
   EXPECT_THAT_ERROR(server_up->Accept(std::move(transport)), Failed());
 }



More information about the lldb-commits mailing list