Skip to content

Commit a3b6423

Browse files
authored
[lldb-dap] Mitigate a build error on Windows. (#137388)
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 b60ee39 commit a3b6423

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
@@ -847,8 +847,10 @@ static std::optional<T> getArgumentsIfRequest(const Message &pm,
847847
}
848848

849849
llvm::Error DAP::Loop() {
850-
std::future<llvm::Error> queue_reader =
851-
std::async(std::launch::async, [&]() -> llvm::Error {
850+
// Can't use \a std::future<llvm::Error> because it doesn't compile on
851+
// Windows.
852+
std::future<lldb::SBError> queue_reader =
853+
std::async(std::launch::async, [&]() -> lldb::SBError {
852854
llvm::set_thread_name(transport.GetClientName() + ".transport_handler");
853855
auto cleanup = llvm::make_scope_exit([&]() {
854856
// Ensure we're marked as disconnecting when the reader exits.
@@ -870,8 +872,11 @@ llvm::Error DAP::Loop() {
870872
continue;
871873
}
872874

873-
if (llvm::Error err = next.takeError())
874-
return err;
875+
if (llvm::Error err = next.takeError()) {
876+
lldb::SBError errWrapper;
877+
errWrapper.SetErrorString(llvm::toString(std::move(err)).c_str());
878+
return errWrapper;
879+
}
875880

876881
if (const protocol::Request *req =
877882
std::get_if<protocol::Request>(&*next);
@@ -909,7 +914,7 @@ llvm::Error DAP::Loop() {
909914
m_queue_cv.notify_one();
910915
}
911916

912-
return llvm::Error::success();
917+
return lldb::SBError();
913918
});
914919

915920
auto cleanup = llvm::make_scope_exit([&]() {
@@ -933,7 +938,7 @@ llvm::Error DAP::Loop() {
933938
"unhandled packet");
934939
}
935940

936-
return queue_reader.get();
941+
return ToError(queue_reader.get());
937942
}
938943

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

0 commit comments

Comments
 (0)