[llvm] [Support] Fix some issues in LSP Transport (PR #160010)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 21 13:28:01 PDT 2025
https://github.com/aganea created https://github.com/llvm/llvm-project/pull/160010
When building with latest MSVC on Windows, this fixes some compile-time warnings from last week's integration in https://github.com/llvm/llvm-project/pull/157885:
```
[321/5941] Building CXX object lib\Support\LSP\CMakeFiles\LLVMSupportLSP.dir\Transport.cpp.obj
C:\git\llvm-project\llvm\lib\Support\LSP\Transport.cpp(123): warning C4930: 'std::lock_guard<std::mutex> responseHandlersLock(llvm::lsp::MessageHandler::ResponseHandlerTy)': prototyped function not called (was a variable definition intended?)
[384/5941] Building CXX object unittests\Support\LSP\CMakeFiles\LLVMSupportLSPTests.dir\Transport.cpp.obj
C:\git\llvm-project\llvm\unittests\Support\LSP\Transport.cpp(190): warning C4804: '+=': unsafe use of type 'bool' in operation
```
>From be6550c095ecf5aafdef052995950f484a514202 Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <alex_toresh at yahoo.fr>
Date: Sun, 21 Sep 2025 16:24:36 -0400
Subject: [PATCH] [Support] Fix some issues in LSP Transport
This fixes:
```
[321/5941] Building CXX object lib\Support\LSP\CMakeFiles\LLVMSupportLSP.dir\Transport.cpp.obj
C:\git\llvm-project\llvm\lib\Support\LSP\Transport.cpp(123): warning C4930: 'std::lock_guard<std::mutex> responseHandlersLock(llvm::lsp::MessageHandler::ResponseHandlerTy)': prototyped function not called (was a variable definition intended?)
[384/5941] Building CXX object unittests\Support\LSP\CMakeFiles\LLVMSupportLSPTests.dir\Transport.cpp.obj
C:\git\llvm-project\llvm\unittests\Support\LSP\Transport.cpp(190): warning C4804: '+=': unsafe use of type 'bool' in operation
```
---
llvm/lib/Support/LSP/Transport.cpp | 2 +-
llvm/unittests/Support/LSP/Transport.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Support/LSP/Transport.cpp b/llvm/lib/Support/LSP/Transport.cpp
index e71f17701636b..31b5a89f9b5e0 100644
--- a/llvm/lib/Support/LSP/Transport.cpp
+++ b/llvm/lib/Support/LSP/Transport.cpp
@@ -120,7 +120,7 @@ bool MessageHandler::onReply(llvm::json::Value Id,
// mapping and erase it.
ResponseHandlerTy ResponseHandler;
{
- std::lock_guard<std::mutex> responseHandlersLock(ResponseHandlerTy);
+ std::lock_guard<std::mutex> responseHandlersLock(ResponseHandlersMutex);
auto It = ResponseHandlers.find(debugString(Id));
if (It != ResponseHandlers.end()) {
ResponseHandler = std::move(It->second);
diff --git a/llvm/unittests/Support/LSP/Transport.cpp b/llvm/unittests/Support/LSP/Transport.cpp
index 514e93e983523..0172dee1d603d 100644
--- a/llvm/unittests/Support/LSP/Transport.cpp
+++ b/llvm/unittests/Support/LSP/Transport.cpp
@@ -174,7 +174,7 @@ TEST_F(TransportInputTest, OutgoingRequest) {
TEST_F(TransportInputTest, OutgoingRequestJSONParseFailure) {
// Make an outgoing request that expects a failure response.
- bool responseCallbackInvoked = false;
+ unsigned responseCallbackInvoked = 0;
auto callFn = getMessageHandler().outgoingRequest<CompletionList, Position>(
"outgoing-request-json-parse-failure",
[&responseCallbackInvoked](const llvm::json::Value &id,
More information about the llvm-commits
mailing list