Skip to content

gh-90110: Update the c-analyzer Tool #96058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions Tools/c-analyzer/c_parser/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ def get_parsed_vartype(decl):
elif isinstance(decl, Variable):
storage = decl.storage
typequal, typespec, abstract = decl.vartype
elif isinstance(decl, Signature):
storage = None
typequal, typespec, abstract = decl.returntype
elif isinstance(decl, Function):
storage = decl.storage
typequal, typespec, abstract = decl.signature.returntype
Expand Down Expand Up @@ -1012,6 +1015,18 @@ def __str__(self):
def returns(self):
return self.returntype

@property
def typequal(self):
return self.returntype.typequal

@property
def typespec(self):
return self.returntype.typespec

@property
def abstract(self):
return self.returntype.abstract


class Function(Declaration):
kind = KIND.FUNCTION
Expand Down Expand Up @@ -1106,9 +1121,16 @@ class TypeDef(TypeDeclaration):
def _resolve_data(cls, data):
if not data:
raise NotImplementedError(data)
vartype = dict(data)
del vartype['storage']
return VarType(**vartype), None
kwargs = dict(data)
del kwargs['storage']
if 'returntype' in kwargs:
vartype = kwargs['returntype']
del vartype['storage']
kwargs['returntype'] = VarType(**vartype)
datacls = Signature
else:
datacls = VarType
return datacls(**kwargs), None

@classmethod
def _raw_data(self, data):
Expand Down
6 changes: 5 additions & 1 deletion Tools/c-analyzer/c_parser/parser/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

def log_match(group, m):
from . import _logger
_logger.debug(f'matched <{group}> ({m.group(0)})')
text = m.group(0)
if text.startswith(('(', ')')) or text.endswith(('(', ')')):
_logger.debug(f'matched <{group}> ({text!r})')
else:
_logger.debug(f'matched <{group}> ({text})')


#############################
Expand Down
8 changes: 4 additions & 4 deletions Tools/c-analyzer/cpython/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ def clean_lines(text):
# generated
Python/deepfreeze/*.c
Python/frozen_modules/*.h
Python/opcode_targets.h
Python/stdlib_module_names.h

# @end=conf@
''')
Expand All @@ -109,9 +107,7 @@ def clean_lines(text):

Modules/_dbmmodule.c
Modules/cjkcodecs/_codecs_*.c
Modules/expat/xmlrole.c
Modules/expat/xmlparse.c
Python/initconfig.c
''')

INCL_DIRS = clean_lines('''
Expand Down Expand Up @@ -308,8 +304,12 @@ def clean_lines(text):
_abs('Objects/stringlib/unicode_format.h'): (10_000, 400),
_abs('Objects/typeobject.c'): (20_000, 200),
_abs('Python/compile.c'): (20_000, 500),
_abs('Python/deepfreeze/*.c'): (20_000, 500),
_abs('Python/frozen_modules/*.h'): (20_000, 500),
_abs('Python/pylifecycle.c'): (500_000, 5000),
_abs('Python/pystate.c'): (500_000, 5000),
_abs('Python/opcode_targets.h'): (10_000, 500),
_abs('Python/stdlib_module_names.h'): (5_000, 500),
}


Expand Down
53 changes: 53 additions & 0 deletions Tools/c-analyzer/cpython/ignored.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,58 @@ Objects/object.c - _PyLineIterator -
Objects/object.c - _PyPositionsIterator -
Python/importdl.h - _PyImport_DynLoadFiletab -

Modules/expat/xmlrole.c - prolog0 -
Modules/expat/xmlrole.c - prolog1 -
Modules/expat/xmlrole.c - prolog2 -
Modules/expat/xmlrole.c - doctype0 -
Modules/expat/xmlrole.c - doctype1 -
Modules/expat/xmlrole.c - doctype2 -
Modules/expat/xmlrole.c - doctype3 -
Modules/expat/xmlrole.c - doctype4 -
Modules/expat/xmlrole.c - doctype5 -
Modules/expat/xmlrole.c - internalSubset -
Modules/expat/xmlrole.c - entity0 -
Modules/expat/xmlrole.c - entity1 -
Modules/expat/xmlrole.c - entity2 -
Modules/expat/xmlrole.c - entity3 -
Modules/expat/xmlrole.c - entity4 -
Modules/expat/xmlrole.c - entity5 -
Modules/expat/xmlrole.c - entity6 -
Modules/expat/xmlrole.c - entity7 -
Modules/expat/xmlrole.c - entity8 -
Modules/expat/xmlrole.c - entity9 -
Modules/expat/xmlrole.c - entity10 -
Modules/expat/xmlrole.c - notation0 -
Modules/expat/xmlrole.c - notation1 -
Modules/expat/xmlrole.c - notation2 -
Modules/expat/xmlrole.c - notation3 -
Modules/expat/xmlrole.c - notation4 -
Modules/expat/xmlrole.c - attlist0 -
Modules/expat/xmlrole.c - attlist1 -
Modules/expat/xmlrole.c - attlist2 -
Modules/expat/xmlrole.c - attlist3 -
Modules/expat/xmlrole.c - attlist4 -
Modules/expat/xmlrole.c - attlist5 -
Modules/expat/xmlrole.c - attlist6 -
Modules/expat/xmlrole.c - attlist7 -
Modules/expat/xmlrole.c - attlist8 -
Modules/expat/xmlrole.c - attlist9 -
Modules/expat/xmlrole.c - element0 -
Modules/expat/xmlrole.c - element1 -
Modules/expat/xmlrole.c - element2 -
Modules/expat/xmlrole.c - element3 -
Modules/expat/xmlrole.c - element4 -
Modules/expat/xmlrole.c - element5 -
Modules/expat/xmlrole.c - element6 -
Modules/expat/xmlrole.c - element7 -
Modules/expat/xmlrole.c - externalSubset0 -
Modules/expat/xmlrole.c - externalSubset1 -
Modules/expat/xmlrole.c - condSect0 -
Modules/expat/xmlrole.c - condSect1 -
Modules/expat/xmlrole.c - condSect2 -
Modules/expat/xmlrole.c - declClose -
Modules/expat/xmlrole.c - error -


##################################
# test code
Expand Down Expand Up @@ -1933,4 +1985,5 @@ Python/specialize.c - adaptive_opcodes -
Python/specialize.c - cache_requirements -
Python/specialize.c - compare_masks -
Python/specialize.c - _PyOpcode_Adaptive -
Python/stdlib_module_names.h - _Py_stdlib_module_names -
Python/sysmodule.c - whatstrings -