#ifndef MLIR_TOOLS_MLIRQUERY_MATCHER_DIAGNOSTICS_H
#define MLIR_TOOLS_MLIRQUERY_MATCHER_DIAGNOSTICS_H
#include "mlir/Query/Matcher/ErrorBuilder.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
#include <vector>
namespace mlir::query::matcher::internal {
class Diagnostics {
public:
class ArgStream {
public:
ArgStream(std::vector<std::string> *out) : out(out) {}
template <class T>
ArgStream &operator<<(const T &arg) {
return operator<<(llvm::Twine(arg));
}
ArgStream &operator<<(const llvm::Twine &arg);
private:
std::vector<std::string> *out;
};
ArgStream addError(SourceRange range, ErrorType error);
void print(llvm::raw_ostream &os) const;
private:
struct ContextFrame {
SourceRange range;
std::vector<std::string> args;
};
struct ErrorContent {
std::vector<ContextFrame> contextStack;
struct Message {
SourceRange range;
ErrorType type;
std::vector<std::string> args;
};
std::vector<Message> messages;
};
void printMessage(const ErrorContent::Message &message,
const llvm::Twine Prefix, llvm::raw_ostream &os) const;
void printErrorContent(const ErrorContent &content,
llvm::raw_ostream &os) const;
std::vector<ContextFrame> contextStack;
std::vector<ErrorContent> errorValues;
};
}
#endif