From f1aaf92afb58e9fee330ede36b9775fe2a6e5a27 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 31 Oct 2015 19:40:33 +0000 Subject: Improve diagnostics if IWYU is enabled Few small cleanups from clang --- massage_messages.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) (limited to 'massage_messages.py') diff --git a/massage_messages.py b/massage_messages.py index 656c48bd..c1b31c96 100644 --- a/massage_messages.py +++ b/massage_messages.py @@ -5,8 +5,70 @@ import fileinput import re +removing = None + +includes = dict + +foundline = 0 + for line in fileinput.input(): # Look for '\) : ([^:])?:' # Replace with ') : \1 I0000: - line.rstrip() - print re.sub(r'\)\s*:\s*([^:]*):', r') : \1 I0000:', line) \ No newline at end of file + line = line.rstrip() + if removing: + if line == '': + removing = None + print + continue + else: + # Really we should stash these so that if we get a 'class xxx' in the + # add lines we can print it here. also we could do the case fixing. + m = re.match(r'- #include [<"](.*)[">] +// lines (.*)-', line) + if m: + # If there is an added line with the same class, print it here + print '%s(%s) : warning I0001: Unnecessary include of %s' % (removing, m.group(2), m.group(1)) + foundline = m.group(1) + else: + m = re.match(r'- (.*); +// lines (.*)-', line) + if m: + print '%s(%s) : warning I0002: Unnecessary forward ref of %s' % (removing, m.group(2), m.group(1)) + foundline = m.group(1) + else: + print '********* I got confused **********' + + line = re.sub(r'\)\s*:\s*([^:]*):', r') : \1 I1234:', line) + # Sadly qt doesn't seem to support 'info' in the issues tab. + line = re.sub(r': note I1234:', r': warning I1234:', line) + print line + if line.endswith(' should remove these lines:'): + removing = (line.split(' '))[0] + elif line.endswith(' should add these lines:'): + adding = (line.split(' '))[0] + +# also process the other lines +""" + +source/organizer/aboutdialog.h should add these lines: +#include // for Q_OBJECT, slots +#include // for QString +class QListWidgetItem; +class QWidget; + +source/organizer/aboutdialog.h should remove these lines: +- #include // lines 25-25 +- #include // lines 28-28 +- #include // lines 27-27 +- class DownloadManager; // lines 47-47 + +The full include-list for source/organizer/aboutdialog.h: +#include // for QDialog +#include // for Q_OBJECT, slots +#include // for QString +#include // for map +class QListWidgetItem; +class QWidget; +namespace Ui { class AboutDialog; } // lines 31-31 +--- +""" + +# added lines should come after the first entry with a line number. -- cgit v1.3.1