@@ -43,13 +43,32 @@ const char *ExpressionResultAsCString(lldb::ExpressionResults result);
4343// / of themselves for printing results and error codes. The string value will
4444// / be fetched on demand and its string value will be cached until the error
4545// / is cleared of the value of the error changes.
46+ // /
47+ // / API design notes:
48+ // /
49+ // / Most APIs that currently vend a Status would be better served by
50+ // / returning llvm::Expected<> instead. If possibles APIs should be
51+ // / refactored to avoid Status. The only legitimate long-term uses of
52+ // / Status are objects that need to store an error for a long time
53+ // / (which should be questioned as a design decision, too).
54+ // /
55+ // / Implementation notes:
56+ // /
57+ // / Internally, Status stores an llvm::Error.
58+ // / eErrorTypeInvalid
59+ // / eErrorTypeGeneric llvm::StringError
60+ // / eErrorTypePOSIX llvm::ECError
61+ // / eErrorTypeMachKernel MachKernelError
62+ // / eErrorTypeExpression llvm::ErrorList<ExpressionError>
63+ // / eErrorTypeWin32 Win32Error
64+
4665class Status {
4766public:
48- // / Every error value that this object can contain needs to be able to fit
4967 // / into ValueType.
5068 typedef uint32_t ValueType;
5169
5270 Status ();
71+ Status (Status &&other) = default ;
5372
5473 // / Initialize the error object with a generic success value.
5574 // /
@@ -93,10 +112,14 @@ class Status {
93112
94113 ~Status ();
95114
115+ const Status &operator =(Status &&);
96116 // / Avoid using this in new code. Migrate APIs to llvm::Expected instead.
97117 static Status FromError (llvm::Error error);
98- // / FIXME: Replace this with a takeError method.
118+ // / FIXME: Replace this with a takeError() method.
99119 llvm::Error ToError () const ;
120+ // / Don't call this function in new code. Instead, redesign the API
121+ // / to use llvm::Expected instead of Status.
122+ Status Clone () const { return Status (ToError ()); }
100123
101124 // / Get the error string associated with the current error.
102125 //
0 commit comments