Skip to content

Commit da55134

Browse files
authored
[Support] Fix some warnings in LSP Transport (llvm#160010)
When building with latest MSVC on Windows, this fixes some compile-time warnings from last week's integration in llvm#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 ```
1 parent e9db38c commit da55134

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/lib/Support/LSP/Transport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool MessageHandler::onReply(llvm::json::Value Id,
120120
// mapping and erase it.
121121
ResponseHandlerTy ResponseHandler;
122122
{
123-
std::lock_guard<std::mutex> responseHandlersLock(ResponseHandlerTy);
123+
std::lock_guard<std::mutex> responseHandlersLock(ResponseHandlersMutex);
124124
auto It = ResponseHandlers.find(debugString(Id));
125125
if (It != ResponseHandlers.end()) {
126126
ResponseHandler = std::move(It->second);

llvm/unittests/Support/LSP/Transport.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ TEST_F(TransportInputTest, OutgoingRequest) {
174174

175175
TEST_F(TransportInputTest, OutgoingRequestJSONParseFailure) {
176176
// Make an outgoing request that expects a failure response.
177-
bool responseCallbackInvoked = false;
177+
unsigned responseCallbackInvoked = 0;
178178
auto callFn = getMessageHandler().outgoingRequest<CompletionList, Position>(
179179
"outgoing-request-json-parse-failure",
180180
[&responseCallbackInvoked](const llvm::json::Value &id,
@@ -190,7 +190,7 @@ TEST_F(TransportInputTest, OutgoingRequestJSONParseFailure) {
190190
responseCallbackInvoked += 1;
191191
});
192192
callFn({}, 109);
193-
EXPECT_EQ(responseCallbackInvoked, 0);
193+
EXPECT_EQ(responseCallbackInvoked, 0u);
194194

195195
// The request receives multiple responses, but only the first one triggers
196196
// the response callback. The first response has erroneous JSON that causes a
@@ -200,6 +200,6 @@ TEST_F(TransportInputTest, OutgoingRequestJSONParseFailure) {
200200
"{\"jsonrpc\":\"2.0\",\"id\":109,\"result\":{\"line\":3,"
201201
"\"character\":2}}\n");
202202
runTransport();
203-
EXPECT_EQ(responseCallbackInvoked, 1);
203+
EXPECT_EQ(responseCallbackInvoked, 1u);
204204
}
205205
} // namespace

0 commit comments

Comments
 (0)