Skip to content

Commit 8f1e049

Browse files
committed
[lldb-dap] Mitigate a build error on Windows.
When building with MSVC 2019 using `std::future<llvm::Error>` causes a compile time build error. ``` C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\future(196): error C2248: 'llvm::Error::Error': cannot access protected member declared in class 'llvm::Error' C:\work\main\llvm-project\llvm\include\llvm/Support/Error.h(181): note: see declaration of 'llvm::Error::Error' C:\work\main\llvm-project\llvm\include\llvm/Support/FormatVariadicDetails.h(20): note: see declaration of 'llvm::Error' C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\include\future(193): note: while compiling class template member function 'std::_Associated_state<_Ty>::_Associated_state(std::_Deleter_base<_Ty> *)' with [ _Ty=llvm::Error ] C:\work\main\llvm-project\lldb\tools\lldb-dap\DAP.cpp(854): note: see reference to class template instantiation 'std::future<llvm::Error>' being compiled ``` To work around this, swapping to a lldb::SBError for now.
1 parent 332e181 commit 8f1e049

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,10 @@ static std::optional<T> getArgumentsIfRequest(const Message &pm,
844844
}
845845

846846
llvm::Error DAP::Loop() {
847-
std::future<llvm::Error> queue_reader =
848-
std::async(std::launch::async, [&]() -> llvm::Error {
847+
// Can't use \a std::future<llvm::Error> because it doesn't compile on
848+
// Windows.
849+
std::future<lldb::SBError> queue_reader =
850+
std::async(std::launch::async, [&]() -> lldb::SBError {
849851
llvm::set_thread_name(transport.GetClientName() + ".transport_handler");
850852
auto cleanup = llvm::make_scope_exit([&]() {
851853
// Ensure we're marked as disconnecting when the reader exits.
@@ -867,8 +869,11 @@ llvm::Error DAP::Loop() {
867869
continue;
868870
}
869871

870-
if (llvm::Error err = next.takeError())
871-
return err;
872+
if (llvm::Error err = next.takeError()) {
873+
lldb::SBError errWrapper;
874+
errWrapper.SetErrorString(llvm::toString(std::move(err)).c_str());
875+
return errWrapper;
876+
}
872877

873878
if (const protocol::Request *req =
874879
std::get_if<protocol::Request>(&*next);
@@ -906,7 +911,7 @@ llvm::Error DAP::Loop() {
906911
m_queue_cv.notify_one();
907912
}
908913

909-
return llvm::Error::success();
914+
return lldb::SBError();
910915
});
911916

912917
auto cleanup = llvm::make_scope_exit([&]() {
@@ -930,7 +935,7 @@ llvm::Error DAP::Loop() {
930935
"unhandled packet");
931936
}
932937

933-
return queue_reader.get();
938+
return ToError(queue_reader.get());
934939
}
935940

936941
lldb::SBError DAP::WaitForProcessToStop(std::chrono::seconds seconds) {

0 commit comments

Comments
 (0)