aboutsummaryrefslogtreecommitdiff
path: root/rule.cc
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2017-02-22 14:31:16 -0800
committerDan Willemsen <dwillemsen@google.com>2017-02-22 22:41:57 -0800
commite41c7556c22bda359c2b97cd98d59082110add95 (patch)
treef839deb8477c133f430ad142bbbdb4cabec661df /rule.cc
parentf8e155865652181a504d7400afd25f35cf158472 (diff)
Add --color_warnings to make warnings/errors like clang
This adds new (WARN|KATI_WARN|ERROR)_LOC log macro variants that take a location as the first argument, and will prefix that location information to the warning/error lines. When --color_warnings is enabled, it reformats them to have a standard warning:/error: infix, and adds colors in order to match the warnings/errors produced by clang.
Diffstat (limited to 'rule.cc')
-rw-r--r--rule.cc22
1 files changed, 10 insertions, 12 deletions
diff --git a/rule.cc b/rule.cc
index 6942fb5..717d0f0 100644
--- a/rule.cc
+++ b/rule.cc
@@ -58,7 +58,7 @@ void ParseRule(Loc& loc, StringPiece line, char term,
Rule** out_rule, RuleVarAssignment* rule_var) {
size_t index = line.find(':');
if (index == string::npos) {
- ERROR("%s:%d: *** missing separator.", LOCF(loc));
+ ERROR_LOC(loc, "*** missing separator.");
}
StringPiece first = line.substr(0, index);
@@ -71,8 +71,7 @@ void ParseRule(Loc& loc, StringPiece line, char term,
!outputs.empty() && IsPatternRule(outputs[0].str()));
for (size_t i = 1; i < outputs.size(); i++) {
if (IsPatternRule(outputs[i].str()) != is_first_pattern) {
- ERROR("%s:%d: *** mixed implicit and normal rules: deprecated syntax",
- LOCF(loc));
+ ERROR_LOC(loc, "*** mixed implicit and normal rules: deprecated syntax");
}
}
@@ -94,8 +93,8 @@ void ParseRule(Loc& loc, StringPiece line, char term,
// target specific variable).
// See https://github.com/google/kati/issues/83
if (term_index == 0) {
- KATI_WARN("%s:%d: defining a target which starts with `=', "
- "which is not probably what you meant", LOCF(loc));
+ KATI_WARN_LOC(loc, "defining a target which starts with `=', "
+ "which is not probably what you meant");
buf = line.as_string();
if (term)
buf += term;
@@ -136,8 +135,7 @@ void ParseRule(Loc& loc, StringPiece line, char term,
}
if (is_first_pattern) {
- ERROR("%s:%d: *** mixed implicit and normal rules: deprecated syntax",
- LOCF(loc));
+ ERROR_LOC(loc, "*** mixed implicit and normal rules: deprecated syntax");
}
StringPiece second = rest.substr(0, index);
@@ -147,8 +145,8 @@ void ParseRule(Loc& loc, StringPiece line, char term,
tok = TrimLeadingCurdir(tok);
for (Symbol output : rule->outputs) {
if (!Pattern(tok).Match(output.str())) {
- WARN("%s:%d: target `%s' doesn't match the target pattern",
- LOCF(loc), output.c_str());
+ WARN_LOC(loc, "target `%s' doesn't match the target pattern",
+ output.c_str());
}
}
@@ -156,13 +154,13 @@ void ParseRule(Loc& loc, StringPiece line, char term,
}
if (rule->output_patterns.empty()) {
- ERROR("%s:%d: *** missing target pattern.", LOCF(loc));
+ ERROR_LOC(loc, "*** missing target pattern.");
}
if (rule->output_patterns.size() > 1) {
- ERROR("%s:%d: *** multiple target patterns.", LOCF(loc));
+ ERROR_LOC(loc, "*** multiple target patterns.");
}
if (!IsPatternRule(rule->output_patterns[0].str())) {
- ERROR("%s:%d: *** target pattern contains no '%%'.", LOCF(loc));
+ ERROR_LOC(loc, "*** target pattern contains no '%%'.");
}
ParseInputs(rule, third);
}