Author: John Harrison
Date: 2025-04-25T13:24:13-07:00
New Revision: a3b6423d506f1340782db62d23fb0d1a845a9411

URL: 
https://github.com/llvm/llvm-project/commit/a3b6423d506f1340782db62d23fb0d1a845a9411
DIFF: 
https://github.com/llvm/llvm-project/commit/a3b6423d506f1340782db62d23fb0d1a845a9411.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/tools/lldb-dap/DAP.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 2e30285694010..f015b7b6ff3d0 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -847,8 +847,10 @@ static std::optional<T> getArgumentsIfRequest(const 
Message &pm,
 }
 
 llvm::Error DAP::Loop() {
-  std::future<llvm::Error> queue_reader =
-      std::async(std::launch::async, [&]() -> llvm::Error {
+  // Can't use \a std::future<llvm::Error> because it doesn't compile on
+  // Windows.
+  std::future<lldb::SBError> queue_reader =
+      std::async(std::launch::async, [&]() -> lldb::SBError {
         llvm::set_thread_name(transport.GetClientName() + 
".transport_handler");
         auto cleanup = llvm::make_scope_exit([&]() {
           // Ensure we're marked as disconnecting when the reader exits.
@@ -870,8 +872,11 @@ llvm::Error DAP::Loop() {
             continue;
           }
 
-          if (llvm::Error err = next.takeError())
-            return err;
+          if (llvm::Error err = next.takeError()) {
+            lldb::SBError errWrapper;
+            errWrapper.SetErrorString(llvm::toString(std::move(err)).c_str());
+            return errWrapper;
+          }
 
           if (const protocol::Request *req =
                   std::get_if<protocol::Request>(&*next);
@@ -909,7 +914,7 @@ llvm::Error DAP::Loop() {
           m_queue_cv.notify_one();
         }
 
-        return llvm::Error::success();
+        return lldb::SBError();
       });
 
   auto cleanup = llvm::make_scope_exit([&]() {
@@ -933,7 +938,7 @@ llvm::Error DAP::Loop() {
                                      "unhandled packet");
   }
 
-  return queue_reader.get();
+  return ToError(queue_reader.get());
 }
 
 lldb::SBError DAP::WaitForProcessToStop(std::chrono::seconds seconds) {


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to