summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Panne <svenpanne@gmail.com>2021-08-16 10:23:22 +0200
committerKim Gräsman <kim.grasman@gmail.com>2021-09-26 16:40:14 +0200
commit0997656913fc15d52b15715e275897b4f8de6d5c (patch)
treea20ff6adf4ce0788a5400a77e11c7c5a335fae98
parentd90dcaa1b7a97ab7e88130e980c68aa9ca18dfcd (diff)
Always use one-line messages with --output-format=clang
Apart from being easier to read by humans, this improves the cooperation with other tools (e.g. Jenkins' warnings-ng plugin, various Emacs modes) quite a bit. As an example, here the previous output: Foo.h:1:1: error: add the following line class Bar; Foo.h:18:1: error: remove the following line #include "Bar.h" Foo.cc:1:1: error: add the following line #include "Baz.h" // for Huey, Dewey, Louie (ptr only) Foo.cc:19:1: error: remove the following line #include "Blah.h" With this patch: Foo.h:1:1: error: add 'class Bar;' Foo.h:18:1: error: superfluous '#include "Bar.h"' Foo.cc:1:1: error: add '#include "Baz.h"' (for Huey, Dewey, Louie (ptr only)) Foo.cc:19:1: error: superfluous '#include "Blah.h"'
-rwxr-xr-xiwyu_tool.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/iwyu_tool.py b/iwyu_tool.py
index eaf0abc..45b2a4a 100755
--- a/iwyu_tool.py
+++ b/iwyu_tool.py
@@ -42,6 +42,7 @@ import subprocess
CORRECT_RE = re.compile(r'^\((.*?) has correct #includes/fwd-decls\)$')
SHOULD_ADD_RE = re.compile(r'^(.*?) should add these lines:$')
+ADD_RE = re.compile('^(.*?) +// (.*)$')
SHOULD_REMOVE_RE = re.compile(r'^(.*?) should remove these lines:$')
FULL_LIST_RE = re.compile(r'The full include-list for (.*?):$')
END_RE = re.compile(r'^---$')
@@ -80,14 +81,17 @@ def clang_formatter(output):
elif state[0] == GENERAL:
formatted.append(line)
elif state[0] == ADD:
- formatted.append('%s:1:1: error: add the following line' % state[1])
- formatted.append(line)
+ match = ADD_RE.match(line)
+ if match:
+ formatted.append("%s:1:1: error: add '%s' (%s)" %
+ (state[1], match.group(1), match.group(2)))
+ else:
+ formatted.append("%s:1:1: error: add '%s'" % (state[1], line))
elif state[0] == REMOVE:
match = LINES_RE.match(line)
line_no = match.group(2) if match else '1'
- formatted.append('%s:%s:1: error: remove the following line' %
- (state[1], line_no))
- formatted.append(match.group(1))
+ formatted.append("%s:%s:1: error: superfluous '%s'" %
+ (state[1], line_no, match.group(1)))
return os.linesep.join(formatted)