3 # Copyright (C) 2018-2023 Free Software Foundation, Inc.
5 # Find missing and extra parameters in documentation compared to
6 # output of: gcc --help=params.
8 # This file is part of GCC.
10 # GCC is free software; you can redistribute it and/or modify it under
11 # the terms of the GNU General Public License as published by the Free
12 # Software Foundation; either version 3, or (at your option) any later
15 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # You should have received a copy of the GNU General Public License
21 # along with GCC; see the file COPYING3. If not see
22 # <http://www.gnu.org/licenses/>. */
29 from itertools
import dropwhile
, takewhile
32 def get_param_tuple(line
):
33 line
= line
.strip().replace('--param=', '')
37 name
= name
[:name
.find('=')]
38 description
= line
[i
:].strip()
39 return (name
, description
)
42 parser
= argparse
.ArgumentParser()
43 parser
.add_argument('texi_file')
44 parser
.add_argument('params_output')
46 args
= parser
.parse_args()
48 ignored
= {'logical-op-non-short-circuit'}
51 for line
in open(args
.params_output
).readlines():
52 if line
.startswith(' ' * 2) and not line
.startswith(' ' * 8):
53 r
= get_param_tuple(line
)
56 # Find section in .texi manual with parameters
57 texi
= ([x
.strip() for x
in open(args
.texi_file
).readlines()])
58 texi
= dropwhile(lambda x
: 'item --param' not in x
, texi
)
59 texi
= takewhile(lambda x
: '@node Instrumentation Options' not in x
, texi
)
64 for token
in ('@item ', '@itemx '):
65 if line
.startswith(token
):
66 texi_params
.append(line
[len(token
):])
70 texi_params
= [x
for x
in texi_params
if not x
[0].isdigit()]
72 texi_params
= [x
for x
in texi_params
if not x
.startswith('aarch64')]
73 sorted_params
= sorted(texi_params
)
75 texi_set
= set(texi_params
) - ignored
76 params_set
= set(params
.keys()) - ignored
79 extra
= texi_set
- params_set
85 missing
= params_set
- texi_set
94 sys
.exit(0 if success
else 1)