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.
diff --git a/parser.cc b/parser.cc
index 61d1ac5..3822dd8 100644
--- a/parser.cc
+++ b/parser.cc
@@ -92,10 +92,10 @@
}
if (!if_stack_.empty())
- ERROR("%s:%d: *** missing `endif'.", loc_.filename, loc_.lineno + 1);
+ ERROR_LOC(Loc(loc_.filename, loc_.lineno + 1), "*** missing `endif'.");
if (!define_name_.empty())
- ERROR("%s:%d: *** missing `endef', unterminated `define'.",
- loc_.filename, define_start_line_);
+ ERROR_LOC(Loc(loc_.filename, define_start_line_),
+ "*** missing `endef', unterminated `define'.");
}
static void Init() {
@@ -304,7 +304,7 @@
StringPiece rest = TrimRightSpace(RemoveComment(TrimLeftSpace(
line.substr(sizeof("endef")))));
if (!rest.empty()) {
- WARN("%s:%d: extraneous text after `endef' directive", LOCF(loc_));
+ WARN_LOC(loc_, "extraneous text after `endef' directive");
}
AssignStmt* stmt = new AssignStmt();
@@ -374,7 +374,7 @@
}
}
if (!s.empty()) {
- WARN("%s:%d: extraneous text after `ifeq' directive", LOCF(loc_));
+ WARN_LOC(loc_, "extraneous text after `ifeq' directive");
return true;
}
return true;
@@ -411,7 +411,7 @@
num_if_nest_ = st->num_nest + 1;
if (!HandleDirective(next_if, else_if_directives_)) {
- WARN("%s:%d: extraneous text after `else' directive", LOCF(loc_));
+ WARN_LOC(loc_, "extraneous text after `else' directive");
}
num_if_nest_ = 0;
}