16 out->push_back(arg.str());
22 errorValues.emplace_back();
23 ErrorContent &last = errorValues.back();
24 last.contextStack = contextStack;
25 last.messages.emplace_back();
26 last.messages.back().range = range;
27 last.messages.back().type = error;
28 return ArgStream(&last.messages.back().args);
34 return "Matcher not found: $0";
36 return "Incorrect argument count. (Expected = $0) != (Actual = $1)";
38 return "Incorrect type for arg $0. (Expected = $1) != (Actual = $2)";
40 return "Value not found: $0";
42 return "Matcher does not support binding.";
45 return "Error parsing string token: <$0>";
47 return "Error parsing matcher. Found token <$0> while looking for '('.";
49 return "Error parsing matcher. Found end-of-code while looking for ')'.";
51 return "Error parsing matcher. Found token <$0> while looking for ','.";
53 return "End of code found while looking for token.";
55 return "Input value is not a matcher expression.";
57 return "Invalid token <$0> found when looking for a value.";
59 return "Unexpected end of code.";
61 return "Input value has unresolved overloaded type: $0";
63 return "Period not followed by valid chained call.";
65 return "Missing/Invalid argument for the chained call.";
67 return "Missing ')' for the chained call.";
69 return "Missing '(' for the chained call.";
71 return "Failed to build matcher: $0.";
76 llvm_unreachable(
"Unknown ErrorType value.");
81 llvm::raw_ostream &os) {
82 while (!formatString.empty()) {
83 std::pair<llvm::StringRef, llvm::StringRef> pieces =
84 formatString.split(
"$");
85 os << pieces.first.str();
86 if (pieces.second.empty())
89 const char next = pieces.second.front();
90 formatString = pieces.second.drop_front();
91 if (next >=
'0' && next <=
'9') {
92 const unsigned index = next -
'0';
93 if (index < args.size()) {
96 os <<
"<Argument_Not_Provided>";
108 void Diagnostics::printMessage(
109 const Diagnostics::ErrorContent::Message &message,
const llvm::Twine prefix,
110 llvm::raw_ostream &os)
const {
116 void Diagnostics::printErrorContent(
const Diagnostics::ErrorContent &content,
117 llvm::raw_ostream &os)
const {
118 if (content.messages.size() == 1) {
119 printMessage(content.messages[0],
"", os);
121 for (
size_t i = 0, e = content.messages.size(); i != e; ++i) {
124 printMessage(content.messages[i],
125 "Candidate " + llvm::Twine(i + 1) +
": ", os);
131 for (
const ErrorContent &error : errorValues) {
132 if (&error != &errorValues.front())
134 printErrorContent(error, os);
ArgStream & operator<<(const T &arg)
ArgStream addError(SourceRange range, ErrorType error)
void print(llvm::raw_ostream &os) const
static void formatErrorString(llvm::StringRef formatString, llvm::ArrayRef< std::string > args, llvm::raw_ostream &os)
static void maybeAddLineAndColumn(SourceRange range, llvm::raw_ostream &os)
@ ParserChainedExprNoOpenParen
@ ParserFailedToBuildMatcher
@ RegistryMatcherNotFound
@ ParserChainedExprInvalidArg
@ ParserMalformedChainedExpr
@ ParserChainedExprNoCloseParen
static llvm::StringRef errorTypeToFormatString(ErrorType type)