]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/header-tools/count-headers
Fix boostrap failure in tree-ssa-loop-ch.cc
[thirdparty/gcc.git] / contrib / header-tools / count-headers
CommitLineData
bd94906f
AM
1#! /usr/bin/python2
2import os.path
3import sys
4import shlex
5import re
6
7from headerutils import *
8
9usage = False
10src = list ()
11flist = { }
12process_h = True
13process_c = True
14verbose = False
15all_inc = True
16level = 0
17
18only_use_list = list ()
19
20for x in sys.argv[1:]:
21 if x[0:2] == "-h":
22 usage = True
23 else:
24 src.append (x)
25
26
27if not usage and len (src) > 0:
28 incl = { }
29 for fn in src:
30 src = readwholefile (fn)
31 dup = { }
32 for line in src:
33 d = find_pound_include (line, True, True)
34 if d != "" and d[-2:] ==".h":
35 if dup.get (d) == None:
36 if incl.get (d) == None:
37 incl[d] = 1
38 else:
39 incl[d] = incl[d]+ 1
40 dup[d] = 1
41
42 l = list ()
43 for i in incl:
44 l.append ((incl[i], i))
45 l.sort (key=lambda tup:tup[0], reverse=True)
46
47 for f in l:
48 print str (f[0]) + " : " + f[1]
49
50else:
51 print "count-headers file1 [filen]"
52 print "Count the number of occurrences of all includes across all listed files"
53
54
55
56
57
58