gh-81057: Get the c-analyzer tool working again. (gh-92246)

This commit is contained in:
Eric Snow 2022-05-03 13:18:27 -06:00 committed by GitHub
parent f03d3dd9af
commit 456cd513e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 4 deletions

View file

@ -1161,7 +1161,9 @@ class Member(namedtuple('Member', 'name vartype size')):
vartype = dict(raw.data) vartype = dict(raw.data)
del vartype['storage'] del vartype['storage']
if 'size' in vartype: if 'size' in vartype:
size = int(vartype.pop('size')) size = vartype.pop('size')
if isinstance(size, str) and size.isdigit():
size = int(size)
vartype = VarType(**vartype) vartype = VarType(**vartype)
return cls(name, vartype, size) return cls(name, vartype, size)

View file

@ -99,7 +99,7 @@ def _parse_struct_next(m, srcinfo, anon_name, parent):
name = anon_name('struct-field-') name = anon_name('struct-field-')
if size: if size:
# data = (data, size) # data = (data, size)
data['size'] = int(size) data['size'] = int(size) if size.isdigit() else size
else: else:
# This shouldn't happen (we expect each field to have a name). # This shouldn't happen (we expect each field to have a name).
raise NotImplementedError raise NotImplementedError

View file

@ -176,6 +176,7 @@ DECLARATOR = textwrap.dedent(rf'''
(?: # <IDENTIFIER> (?: # <IDENTIFIER>
{STRICT_IDENTIFIER} {STRICT_IDENTIFIER}
) )
# Inside the brackets is actually a "constant expression".
(?: \s* \[ (?: \s* [^\]]+ \s* )? [\]] )* # arrays (?: \s* \[ (?: \s* [^\]]+ \s* )? [\]] )* # arrays
) )
| |
@ -184,6 +185,7 @@ DECLARATOR = textwrap.dedent(rf'''
(?: # <WRAPPED_IDENTIFIER> (?: # <WRAPPED_IDENTIFIER>
{STRICT_IDENTIFIER} {STRICT_IDENTIFIER}
) )
# Inside the brackets is actually a "constant expression".
(?: \s* \[ (?: \s* [^\]]+ \s* )? [\]] )* # arrays (?: \s* \[ (?: \s* [^\]]+ \s* )? [\]] )* # arrays
\s* [)] \s* [)]
) )
@ -194,6 +196,7 @@ DECLARATOR = textwrap.dedent(rf'''
(?: # <FUNC_IDENTIFIER> (?: # <FUNC_IDENTIFIER>
{STRICT_IDENTIFIER} {STRICT_IDENTIFIER}
) )
# Inside the brackets is actually a "constant expression".
(?: \s* \[ (?: \s* [^\]]+ \s* )? [\]] )* # arrays (?: \s* \[ (?: \s* [^\]]+ \s* )? [\]] )* # arrays
\s* [)] \s* [)]
# We allow for a single level of paren nesting in parameters. # We allow for a single level of paren nesting in parameters.
@ -322,7 +325,10 @@ STRUCT_MEMBER_DECL = textwrap.dedent(rf'''
(?: (?:
\s* [:] \s* \s* [:] \s*
(?: # <SIZE> (?: # <SIZE>
# This is actually a "constant expression".
\d+ \d+
|
[^'",}}]+
) )
)? )?
\s* \s*
@ -357,6 +363,7 @@ ENUM_MEMBER_DECL = textwrap.dedent(rf'''
(?: (?:
\s* = \s* \s* = \s*
(?: # <INIT> (?: # <INIT>
# This is actually a "constant expression".
{_ind(STRING_LITERAL, 4)} {_ind(STRING_LITERAL, 4)}
| |
[^'",}}]+ [^'",}}]+

View file

@ -46,6 +46,7 @@ def clean_lines(text):
@end=sh@ @end=sh@
''' '''
# XXX Handle these.
EXCLUDED = clean_lines(''' EXCLUDED = clean_lines('''
# @begin=conf@ # @begin=conf@
@ -69,6 +70,7 @@ Python/dynload_aix.c # sys/ldr.h
Python/dynload_dl.c # dl.h Python/dynload_dl.c # dl.h
Python/dynload_hpux.c # dl.h Python/dynload_hpux.c # dl.h
Python/thread_pthread.h Python/thread_pthread.h
Python/emscripten_signal.c
# only huge constants (safe but parsing is slow) # only huge constants (safe but parsing is slow)
Modules/_blake2/impl/blake2-kat.h Modules/_blake2/impl/blake2-kat.h
@ -202,6 +204,7 @@ Include/cpython/sysmodule.h Py_CPYTHON_SYSMODULE_H 1
Include/cpython/traceback.h Py_CPYTHON_TRACEBACK_H 1 Include/cpython/traceback.h Py_CPYTHON_TRACEBACK_H 1
Include/cpython/tupleobject.h Py_CPYTHON_TUPLEOBJECT_H 1 Include/cpython/tupleobject.h Py_CPYTHON_TUPLEOBJECT_H 1
Include/cpython/unicodeobject.h Py_CPYTHON_UNICODEOBJECT_H 1 Include/cpython/unicodeobject.h Py_CPYTHON_UNICODEOBJECT_H 1
Include/internal/pycore_code.h SIZEOF_VOID_P 8
# implied include of pyport.h # implied include of pyport.h
Include/**/*.h PyAPI_DATA(RTYPE) extern RTYPE Include/**/*.h PyAPI_DATA(RTYPE) extern RTYPE
@ -297,8 +300,8 @@ MAX_SIZES = {
_abs('Objects/stringlib/unicode_format.h'): (10_000, 400), _abs('Objects/stringlib/unicode_format.h'): (10_000, 400),
_abs('Objects/typeobject.c'): (20_000, 200), _abs('Objects/typeobject.c'): (20_000, 200),
_abs('Python/compile.c'): (20_000, 500), _abs('Python/compile.c'): (20_000, 500),
_abs('Python/pylifecycle.c'): (200_000, 5000), _abs('Python/pylifecycle.c'): (500_000, 5000),
_abs('Python/pystate.c'): (200_000, 5000), _abs('Python/pystate.c'): (500_000, 5000),
} }