[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 26 18:27:12 PDT 2024


================
@@ -56,19 +56,41 @@ class Status {
   ///
   /// \param[in] type
   ///     The type for \a err.
-  explicit Status(ValueType err,
-                  lldb::ErrorType type = lldb::eErrorTypeGeneric);
+  explicit Status(ValueType err, lldb::ErrorType type = lldb::eErrorTypeGeneric,
+                  llvm::StringRef msg = {});
 
   Status(std::error_code EC);
 
-  explicit Status(const char *format, ...)
-      __attribute__((format(printf, 2, 3)));
+  /// Create a generic error with the message err_str.
+  explicit Status(std::string &&err_str);
+  /// Create a generic error with the message err_str.
+  explicit Status(llvm::StringRef err_str);
+
+  static Status FromErrorString(const char *format) {
+    if (format)
+      return Status(std::string(format));
+    return Status(std::string("null error"));
----------------
medismailben wrote:

```suggestion
    return Status(llvm::StringRef("null error"));
```

This should be more efficient.

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


More information about the lldb-commits mailing list