@@ -28,69 +28,6 @@ namespace lldb_private {
28
28
29
29
const char *ExpressionResultAsCString (lldb::ExpressionResults result);
30
30
31
- // / Going a bit against the spirit of llvm::Error,
32
- // / lldb_private::Status need to store errors long-term and sometimes
33
- // / copy them. This base class defines an interface for this
34
- // / operation.
35
- class CloneableError
36
- : public llvm::ErrorInfo<CloneableError, llvm::ErrorInfoBase> {
37
- public:
38
- using llvm::ErrorInfo<CloneableError, llvm::ErrorInfoBase>::ErrorInfo;
39
- CloneableError () : ErrorInfo() {}
40
- virtual std::unique_ptr<CloneableError> Clone () const = 0;
41
- static char ID;
42
- };
43
-
44
- // / Common base class for all error-code errors.
45
- class CloneableECError
46
- : public llvm::ErrorInfo<CloneableECError, CloneableError> {
47
- public:
48
- using llvm::ErrorInfo<CloneableECError, CloneableError>::ErrorInfo;
49
- CloneableECError () = delete ;
50
- CloneableECError (std::error_code ec) : ErrorInfo(), EC(ec) {}
51
- std::error_code convertToErrorCode () const override { return EC; }
52
- void log (llvm::raw_ostream &OS) const override { OS << EC.message (); }
53
- std::unique_ptr<CloneableError> Clone () const override ;
54
- static char ID;
55
-
56
- protected:
57
- std::error_code EC;
58
- };
59
-
60
- // / FIXME: Move these declarations closer to where they're used.
61
- class MachKernelError
62
- : public llvm::ErrorInfo<MachKernelError, CloneableECError> {
63
- public:
64
- using llvm::ErrorInfo<MachKernelError, CloneableECError>::ErrorInfo;
65
- MachKernelError (std::error_code ec) : ErrorInfo(ec) {}
66
- std::string message () const override ;
67
- std::unique_ptr<CloneableError> Clone () const override ;
68
- static char ID;
69
- };
70
-
71
- class Win32Error : public llvm ::ErrorInfo<Win32Error, CloneableECError> {
72
- public:
73
- using llvm::ErrorInfo<Win32Error, CloneableECError>::ErrorInfo;
74
- Win32Error (std::error_code ec, const llvm::Twine &msg = {}) : ErrorInfo(ec) {}
75
- std::string message () const override ;
76
- std::unique_ptr<CloneableError> Clone () const override ;
77
- static char ID;
78
- };
79
-
80
- class ExpressionError
81
- : public llvm::ErrorInfo<ExpressionError, CloneableECError> {
82
- public:
83
- using llvm::ErrorInfo<ExpressionError, CloneableECError>::ErrorInfo;
84
- ExpressionError (std::error_code ec, std::string msg = {})
85
- : ErrorInfo(ec), m_string(msg) {}
86
- std::unique_ptr<CloneableError> Clone () const override ;
87
- std::string message () const override { return m_string; }
88
- static char ID;
89
-
90
- protected:
91
- std::string m_string;
92
- };
93
-
94
31
// / \class Status Status.h "lldb/Utility/Status.h" An error handling class.
95
32
// /
96
33
// / This class is designed to be able to hold any error code that can be
@@ -163,7 +100,9 @@ class Status {
163
100
}
164
101
165
102
static Status FromExpressionError (lldb::ExpressionResults result,
166
- std::string msg);
103
+ std::string msg) {
104
+ return Status (result, lldb::eErrorTypeExpression, msg);
105
+ }
167
106
168
107
// / Set the current error to errno.
169
108
// /
@@ -176,7 +115,6 @@ class Status {
176
115
const Status &operator =(Status &&);
177
116
// / Avoid using this in new code. Migrate APIs to llvm::Expected instead.
178
117
static Status FromError (llvm::Error error);
179
-
180
118
// / FIXME: Replace this with a takeError() method.
181
119
llvm::Error ToError () const ;
182
120
// / Don't call this function in new code. Instead, redesign the API
@@ -211,20 +149,12 @@ class Status {
211
149
212
150
// / Access the error value.
213
151
// /
214
- // / If the internally stored \ref llvm::Error is an \ref
215
- // / llvm::ErrorList then this returns the error value of the first
216
- // / error.
217
- // /
218
152
// / \return
219
153
// / The error value.
220
154
ValueType GetError () const ;
221
155
222
156
// / Access the error type.
223
157
// /
224
- // / If the internally stored \ref llvm::Error is an \ref
225
- // / llvm::ErrorList then this returns the error value of the first
226
- // / error.
227
- // /
228
158
// / \return
229
159
// / The error type enumeration value.
230
160
lldb::ErrorType GetType () const ;
@@ -240,9 +170,12 @@ class Status {
240
170
bool Success () const ;
241
171
242
172
protected:
243
- Status (llvm::Error error) : m_error(std::move(error)) {}
244
- llvm::Error m_error;
245
- // / TODO: Replace this with just callling toString(m_error).
173
+ Status (llvm::Error error);
174
+ // / Status code as an integer value.
175
+ ValueType m_code = 0 ;
176
+ // / The type of the above error code.
177
+ lldb::ErrorType m_type = lldb::eErrorTypeInvalid;
178
+ // / A string representation of the error code.
246
179
mutable std::string m_string;
247
180
};
248
181
0 commit comments