summaryrefslogtreecommitdiff
path: root/massage_messages.py
diff options
context:
space:
mode:
authorThomas Tanner <trtanner@btinternet.com>2015-11-09 18:16:58 +0000
committerThomas Tanner <trtanner@btinternet.com>2015-11-09 18:16:58 +0000
commita284cbf232f34cc1a83b85ec45baafc1ce6518ec (patch)
treefb6a30cad10a307c818afcb638b0da0a3b7b675d /massage_messages.py
parentfe54b6c46ada0807a7e6cb6135253fe22af68924 (diff)
Yet more changes for include what you use, including a moderate hack for compiling stackdata with clang
Diffstat (limited to 'massage_messages.py')
-rw-r--r--massage_messages.py41
1 files changed, 29 insertions, 12 deletions
diff --git a/massage_messages.py b/massage_messages.py
index 708c09cc..249068ba 100644
--- a/massage_messages.py
+++ b/massage_messages.py
@@ -34,7 +34,9 @@ includes = dict
foundline = 0
-def process_next_line(line):
+errors = False
+
+def process_next_line(line, outfile):
""" Read a line of output/error from include-what-you use
Turn clang errors into a form QT creator recognises
Raise warnings for unneeded includes
@@ -42,37 +44,48 @@ def process_next_line(line):
global removing
global includes
global foundline
+ global errors
line = line.rstrip()
+ print >> outfile, line
if removing:
if line == '':
removing = None
print
return
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.
+ # 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))
+ 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))
+ 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 **********'
if line.startswith('In file included from'):
- line = re.sub(r'^(In file included from)(.*):(\d+):', r' \2(\3) : \1 here', line)
- # Note This doesnt appear to work if you get a string of them, not sure why.
+ line = re.sub(r'^(In file included from)(.*):(\d+):',
+ r' \2(\3) : \1 here',
+ line)
+ # Note; QT Creator seems to be unwilling to let you double click the
+ # line to select the code in question if you get a string of these, not
+ # sure why.
elif ': note:' in line:
line = ' ' + re.sub(r':(\d+):\d+: note:', r'(\1) : note:', line)
else:
# Replace clang :line:column: type: with ms (line) : type nnnn:
line = re.sub(r':(\d+):\d+: ([^:]*):', r'(\1) : \2 I1234:', line)
-
+ if ' : error I1234:' in line:
+ errors = True
print line
if line.endswith(' should remove these lines:'):
@@ -84,16 +97,20 @@ def process_next_line(line):
# added lines should come after the first entry with a line number.
-process = subprocess.Popen(sys.argv[1:],
+outfile = open(sys.argv[1], 'w')
+process = subprocess.Popen(sys.argv[2:],
stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
while True:
output = process.stdout.readline()
if output == '' and process.poll() is not None:
break
if output:
- process_next_line(output)
+ process_next_line(output, outfile)
+
rc = process.poll()
# The return code you get appears to be more to do with the amount of output
-# generated than any real error. We should error if any ': error:' lines are
-# detected
+# generated than any real error, so instead we should error if any ': error:'
+# lines are detected
+if errors:
+ sys.exit(1)