Skip to content

Commit e2afe93

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#869 from reuk/doxy-squashed
Convert documentation style for doxygen compatibility
2 parents 7ee0510 + e9349f8 commit e2afe93

File tree

1,212 files changed

+6807
-59736
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,212 files changed

+6807
-59736
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ src/xmllang/xml_lex.yy.cpp
7575
src/xmllang/xml_y.output
7676
src/xmllang/xml_y.tab.cpp
7777
src/xmllang/xml_y.tab.h
78+
src/memory-models/mm_lex.yy.cpp
79+
src/memory-models/mm_y.output
80+
src/memory-models/mm_y.tab.cpp
81+
src/memory-models/mm_y.tab.h
7882

7983
# binaries
8084
src/cbmc/cbmc
@@ -106,3 +110,5 @@ src/ansi-c/library/converter
106110
src/ansi-c/library/converter.exe
107111
src/util/irep_ids_convert
108112
src/util/irep_ids_convert.exe
113+
114+
*.pyc
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import difflib, argparse, subprocess, sys, os, multiprocessing, itertools
2+
3+
4+
def preprocess(compiler, file_contents):
5+
""" Get output from the preprocessing pass on a file. """
6+
output = subprocess.Popen(
7+
[compiler, '-E', '-'],
8+
stdout=subprocess.PIPE,
9+
stderr=subprocess.PIPE,
10+
stdin=subprocess.PIPE).communicate(input=file_contents)[0]
11+
12+
def should_keep(line):
13+
return str.strip(line) and line[0] != '#'
14+
15+
return filter(should_keep, output.splitlines())
16+
17+
18+
def preprocess_file(compiler, filename):
19+
""" Open a file and get the preprocessor output. """
20+
with open(filename, 'rb') as f:
21+
return preprocess(compiler, f.read())
22+
23+
24+
def file_contents_from_branch(filename, branch):
25+
""" Get a copy of a file from another branch and return its contents. """
26+
return subprocess.check_output(
27+
['git', 'show', '%s:%s' % (branch, filename)])
28+
29+
30+
def equal_to_file_on_branch(filename, branch, compiler):
31+
"""
32+
Open a file on this branch and preprocess it. Preprocess the same file
33+
from another branch, and return a diff.
34+
"""
35+
with open(filename, 'rb') as f:
36+
def p(text):
37+
return preprocess(compiler, text)
38+
return difflib.unified_diff(p(f.read()),
39+
p(file_contents_from_branch(filename, branch)),
40+
fromfile=filename,
41+
tofile=filename,
42+
lineterm='')
43+
44+
45+
def is_source(filename):
46+
""" Return whether the file appears to be a C++ source file. """
47+
_, ext = os.path.splitext(filename)
48+
return ext == '.h' or ext == '.cpp'
49+
50+
51+
def process(tup):
52+
"""
53+
Check a single file, and return its name if the check fails, otherwise
54+
return None.
55+
"""
56+
filename, branch, compiler = tup
57+
failed = '\n'.join(equal_to_file_on_branch(filename, branch, compiler))
58+
return failed if failed else None
59+
60+
61+
def main():
62+
"""
63+
Open a file and compare its preprocessor output to the output from the same
64+
file on a different branch. Return 0 if the outputs match, or 1 otherwise.
65+
"""
66+
parser = argparse.ArgumentParser()
67+
parser.add_argument(
68+
'--branch', type=str, default='upstream/master',
69+
help='The branch to compare')
70+
parser.add_argument(
71+
'--compiler', type=str, default='g++',
72+
help='The compiler to use')
73+
args = parser.parse_args()
74+
75+
all_files = [os.path.join(root, file)
76+
for root, _, files in os.walk('.') for file in files]
77+
source_files = filter(is_source, all_files)
78+
79+
zipped = zip(
80+
source_files,
81+
itertools.cycle([args.branch]),
82+
itertools.cycle([args.compiler]))
83+
84+
pool = multiprocessing.Pool(10)
85+
86+
results = filter(None, pool.map(process, zipped))
87+
88+
pool.close()
89+
pool.join()
90+
91+
if results:
92+
print('\n\n'.join(results))
93+
return 1
94+
95+
return 0
96+
97+
98+
if __name__ == "__main__":
99+
sys.exit(main())

scripts/do_doc_convert.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from reformat_docs import convert_file
2+
from os import walk
3+
from os.path import join
4+
from sys import exit
5+
from re import match
6+
7+
"""
8+
Run this from CBMC's top-level directory.
9+
"""
10+
11+
def main():
12+
IGNORE_LIST = [
13+
r'src/big-int/.*',
14+
r'src/miniz/.*',
15+
r'src/ansi-c/arm_builtin_headers.h',
16+
r'src/ansi-c/clang_builtin_headers.h',
17+
r'src/ansi-c/cw_builtin_headers.h',
18+
r'src/ansi-c/gcc_builtin_headers_alpha.h',
19+
r'src/ansi-c/gcc_builtin_headers_arm.h',
20+
r'src/ansi-c/gcc_builtin_headers_generic.h',
21+
r'src/ansi-c/gcc_builtin_headers_ia32-2.h',
22+
r'src/ansi-c/gcc_builtin_headers_ia32.h',
23+
r'src/ansi-c/gcc_builtin_headers_mips.h',
24+
r'src/ansi-c/gcc_builtin_headers_power.h',
25+
r'src/ansi-c/library/cprover.h']
26+
27+
MATCH_EXPR = r'.*\.(h|cpp)'
28+
29+
for root, dirs, files in walk('src'):
30+
for file in files:
31+
path = join(root, file)
32+
if any(map(lambda x: match(x, path), IGNORE_LIST)):
33+
print 'ignoring', path
34+
continue
35+
if not match(MATCH_EXPR, path):
36+
continue
37+
convert_file(path, True)
38+
39+
if __name__ == '__main__':
40+
exit(main())

0 commit comments

Comments
 (0)