11#include "llvm/Support/ErrorHandling.h"
22 const char *
name() const noexcept
override {
23 return "LLDBExpressionCategory";
25 std::string
message(
int __ev)
const override {
31 return g_expression_category;
36 std::vector<DiagnosticDetail> details)
50 llvm_unreachable(
"switch needs another case for lldb::Severity enum");
56 llvm::raw_string_ostream os(str);
66 return llvm::inconvertibleErrorCode();
72 return std::make_unique<ExpressionError>(
79 llvm::raw_string_ostream stream(str);
85 llvm::StringRef message = diagnostic->GetMessage();
86 std::string searchable_message = message.lower();
87 auto severity_pos = message.find(severity);
88 stream << message.take_front(severity_pos);
90 if (severity_pos != llvm::StringRef::npos)
91 stream << message.drop_front(severity_pos + severity.size());
106 if (!str.empty() && str.back() ==
'\n')
113 llvm::Twine message)
const {
114 std::vector<DiagnosticDetail> details;
116 details.push_back(diag->GetDetail());
117 return llvm::make_error<ExpressionError>(result, message.str(), details);
123 uint32_t compiler_id) {
134 va_start(args, format);
144 llvm::StringRef str) {
151 bool precede_with_newline) {
152 if (precede_with_newline) {
static llvm::StringRef StringForSeverity(lldb::Severity severity)
ExpressionCategory & expression_category()
A std::error_code category for eErrorTypeExpression.
const char * name() const noexcept override
std::string message(int __ev) const override
size_t void PutString(lldb::Severity severity, llvm::StringRef str)
llvm::Error GetAsError(lldb::ExpressionResults result, llvm::Twine message={}) const
Returns an ExpressionError with arg as error code.
std::string GetString(char separator='\n')
DiagnosticList m_diagnostics
const DiagnosticList & Diagnostics()
void AddDiagnostic(llvm::StringRef message, lldb::Severity severity, DiagnosticOrigin origin, uint32_t compiler_id=LLDB_INVALID_COMPILER_ID)
size_t Printf(lldb::Severity severity, const char *format,...) __attribute__((format(printf
DiagnosticDetail m_detail
void AppendMessage(llvm::StringRef message, bool precede_with_newline=true)
std::vector< DiagnosticDetail > m_details
void log(llvm::raw_ostream &OS) const override
std::unique_ptr< CloneableError > Clone() const override
ExpressionError(lldb::ExpressionResults result, std::string msg, std::vector< DiagnosticDetail > details={})
std::error_code convertToErrorCode() const override
std::string message() const override
void PutString(llvm::StringRef str)
llvm::StringRef GetString() const
size_t size_t PrintfVarArg(const char *format, va_list args)
A class that represents a running process on the host machine.
const char * toString(AppleArm64ExceptionClass EC)
Severity
Used for expressing severity in logs and diagnostics.
ExpressionResults
The results of expression evaluation.
A compiler-independent representation of an lldb_private::Diagnostic.
std::string rendered
Contains the fully rendered error message, without "error: ", but including the source context.
std::string message
Contains "use of undeclared identifier 'foo'" in the example above.