[Lldb-commits] [lldb] [lldb] Change the implementation of Status to store an llvm::Error (NFC) (PR #106774)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 13 10:08:39 PDT 2024


================
@@ -94,25 +126,36 @@ Status Status::FromErrorStringWithFormat(const char *format, ...) {
   return Status(string);
 }
 
-Status Status::FromError(llvm::Error error) { return Status(std::move(error)); }
+Status Status::FromExpressionError(lldb::ExpressionResults result,
+                                   std::string msg) {
+  return Status(llvm::make_error<ExpressionError>(
+      std::error_code(result, expression_category()), msg));
+}
 
-llvm::Error Status::ToError() const {
-  if (Success())
+/// Creates a deep copy of all known errors and converts all other
+/// errors to a new llvm::StringError.
+static llvm::Error CloneError(const llvm::Error &error) {
+  std::vector<std::unique_ptr<llvm::ErrorInfoBase>> info;
+  llvm::visitErrors(error, [&](const llvm::ErrorInfoBase &error) {
+    if (error.isA<CloneableError>())
+      info.push_back(static_cast<const CloneableError *>(&error)->Clone());
----------------
adrian-prantl wrote:

Ah, I didn't realize that `joinErrors(success(), e) == e`

https://github.com/llvm/llvm-project/pull/106774


More information about the lldb-commits mailing list