@@ -26,6 +26,8 @@ class raw_ostream;
2626
2727namespace lldb_private {
2828
29+ const char *ExecutionResultAsCString (lldb::ExpressionResults result);
30+
2931// / \class Status Status.h "lldb/Utility/Status.h" An error handling class.
3032// /
3133// / This class is designed to be able to hold any error code that can be
@@ -41,13 +43,32 @@ namespace lldb_private {
4143// / of themselves for printing results and error codes. The string value will
4244// / be fetched on demand and its string value will be cached until the error
4345// / 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+
4465class Status {
4566public:
46- // / Every error value that this object can contain needs to be able to fit
4767 // / into ValueType.
4868 typedef uint32_t ValueType;
4969
5070 Status ();
71+ Status (Status &&other) = default ;
5172
5273 // / Initialize the error object with a generic success value.
5374 // /
@@ -91,10 +112,14 @@ class Status {
91112
92113 ~Status ();
93114
115+ const Status &operator =(Status &&);
94116 // / Avoid using this in new code. Migrate APIs to llvm::Expected instead.
95117 static Status FromError (llvm::Error error);
96- // / FIXME: Replace this with a takeError method.
118+ // / FIXME: Replace this with a takeError() method.
97119 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 ()); }
98123
99124 // / Get the error string associated with the current error.
100125 //
0 commit comments