14 Diagnostics::ArgStream Diagnostics::pushContextFrame(ContextType Type,
16 ContextStack.emplace_back();
17 ContextFrame& data = ContextStack.back();
20 return ArgStream(&data.Args);
24 StringRef MatcherName,
31 StringRef MatcherName,
35 Error->pushContextFrame(
CT_MatcherArg, MatcherRange) << ArgNumber
42 : Error(Error), BeginIndex(Error->Errors.size()) {}
46 if (BeginIndex < Error->Errors.size()) {
48 for (
size_t i = BeginIndex + 1, e = Error->Errors.size();
i < e; ++
i) {
49 Dest.
Messages.push_back(Error->Errors[
i].Messages[0]);
51 Error->Errors.resize(BeginIndex + 1);
57 Error->Errors.resize(BeginIndex);
61 Out->push_back(Arg.str());
67 Errors.emplace_back();
79 return "Error building matcher $0.";
81 return "Error parsing argument $0 for matcher $1.";
83 llvm_unreachable(
"Unknown ContextType value.");
89 return "Matcher not found: $0";
91 return "Incorrect argument count. (Expected = $0) != (Actual = $1)";
93 return "Incorrect type for arg $0. (Expected = $1) != (Actual = $2)";
95 return "Matcher does not support binding.";
98 return "Ambiguous matcher overload.";
100 return "Value not found: $0";
103 return "Error parsing string token: <$0>";
105 return "Error parsing matcher. Found token <$0> while looking for '('.";
107 return "Error parsing matcher. Found end-of-code while looking for ')'.";
109 return "Error parsing matcher. Found token <$0> while looking for ','.";
111 return "End of code found while looking for token.";
113 return "Input value is not a matcher expression.";
115 return "Invalid token <$0> found when looking for a value.";
117 return "Malformed bind() expression.";
119 return "Expected end of code.";
121 return "Error parsing numeric literal: <$0>";
123 return "Input value has unresolved overloaded type: $0";
128 llvm_unreachable(
"Unknown ErrorType value.");
133 llvm::raw_ostream &OS) {
134 while (!FormatString.empty()) {
135 std::pair<StringRef, StringRef> Pieces = FormatString.split(
"$");
136 OS << Pieces.first.str();
137 if (Pieces.second.empty())
break;
139 const char Next = Pieces.second.front();
140 FormatString = Pieces.second.drop_front();
141 if (Next >=
'0' && Next <=
'9') {
142 const unsigned Index = Next -
'0';
143 if (Index < Args.size()) {
146 OS <<
"<Argument_Not_Provided>";
153 llvm::raw_ostream &OS) {
160 llvm::raw_ostream &OS) {
167 const Twine Prefix, llvm::raw_ostream &OS) {
174 llvm::raw_ostream &OS) {
178 for (
size_t i = 0, e = Content.
Messages.size();
i != e; ++
i) {
179 if (
i != 0) OS <<
"\n";
181 "Candidate " + Twine(
i + 1) +
": ", OS);
187 for (
size_t i = 0, e = Errors.size();
i != e; ++
i) {
188 if (
i != 0) OS <<
"\n";
195 llvm::raw_string_ostream OS(S);
201 for (
size_t i = 0, e = Errors.size();
i != e; ++
i) {
202 if (
i != 0) OS <<
"\n";
214 llvm::raw_string_ostream OS(S);
static void printErrorContentToStream(const Diagnostics::ErrorContent &Content, llvm::raw_ostream &OS)
static void maybeAddLineAndColumn(SourceRange Range, llvm::raw_ostream &OS)
static StringRef contextTypeToFormatString(Diagnostics::ContextType Type)
std::vector< std::string > Args
MatcherArgEnum
About to recurse into parsing one argument for a matcher.
Context(ConstructMatcherEnum, Diagnostics *Error, StringRef MatcherName, SourceRange MatcherRange)
ContextType
Parser context types.
ConstructMatcherEnum
About to call the constructor for a matcher.
std::vector< Message > Messages
OverloadContext(Diagnostics *Error)
void revertErrors()
Revert all errors that happened within this context.
void printToStream(llvm::raw_ostream &OS) const
Returns a simple string representation of each error.
void printToStreamFull(llvm::raw_ostream &OS) const
Returns the full string representation of each error.
Diagnostics class to manage error messages.
Helper class to manage error messages.
static void printContextFrameToStream(const Diagnostics::ContextFrame &Frame, llvm::raw_ostream &OS)
ArgStream addError(SourceRange Range, ErrorType Error)
Add an error to the diagnostics.
static void formatErrorString(StringRef FormatString, ArrayRef< std::string > Args, llvm::raw_ostream &OS)
std::string toStringFull() const
Dataflow Directional Tag Classes.
ErrorType
All errors from the system.
ArgStream & operator<<(const T &Arg)
std::vector< ContextFrame > ContextStack
Information stored for each error found.
std::vector< std::string > Args
std::string toString() const
static void printMessageToStream(const Diagnostics::ErrorContent::Message &Message, const Twine Prefix, llvm::raw_ostream &OS)
static StringRef errorTypeToFormatString(Diagnostics::ErrorType Type)
Information stored for one frame of the context.