@@ -28,69 +28,6 @@ namespace lldb_private {
2828
2929const char *ExpressionResultAsCString (lldb::ExpressionResults result);
3030
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-
9431// / \class Status Status.h "lldb/Utility/Status.h" An error handling class.
9532// /
9633// / This class is designed to be able to hold any error code that can be
@@ -163,7 +100,9 @@ class Status {
163100 }
164101
165102 static Status FromExpressionError (lldb::ExpressionResults result,
166- std::string msg);
103+ std::string msg) {
104+ return Status (result, lldb::eErrorTypeExpression, msg);
105+ }
167106
168107 // / Set the current error to errno.
169108 // /
@@ -176,7 +115,6 @@ class Status {
176115 const Status &operator =(Status &&);
177116 // / Avoid using this in new code. Migrate APIs to llvm::Expected instead.
178117 static Status FromError (llvm::Error error);
179-
180118 // / FIXME: Replace this with a takeError() method.
181119 llvm::Error ToError () const ;
182120 // / Don't call this function in new code. Instead, redesign the API
@@ -211,20 +149,12 @@ class Status {
211149
212150 // / Access the error value.
213151 // /
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- // /
218152 // / \return
219153 // / The error value.
220154 ValueType GetError () const ;
221155
222156 // / Access the error type.
223157 // /
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- // /
228158 // / \return
229159 // / The error type enumeration value.
230160 lldb::ErrorType GetType () const ;
@@ -240,9 +170,12 @@ class Status {
240170 bool Success () const ;
241171
242172protected:
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.
246179 mutable std::string m_string;
247180};
248181
0 commit comments