diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2022-08-17 22:54:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-17 22:54:59 (GMT) |
commit | 586fc02be5b3e103bfddd49654034a898a8d6dfc (patch) | |
tree | 6602f98e30e0964c5e1dea463dd288078e507202 | |
parent | 5aac85101b3b0285770bf5739a94cb26245b9eaf (diff) | |
download | cpython-586fc02be5b3e103bfddd49654034a898a8d6dfc.zip cpython-586fc02be5b3e103bfddd49654034a898a8d6dfc.tar.gz cpython-586fc02be5b3e103bfddd49654034a898a8d6dfc.tar.bz2 |
gh-90110: Update the c-analyzer Tool (gh-96058)
-rw-r--r-- | Tools/c-analyzer/c_parser/info.py | 28 | ||||
-rw-r--r-- | Tools/c-analyzer/c_parser/parser/_common.py | 6 | ||||
-rw-r--r-- | Tools/c-analyzer/cpython/_parser.py | 8 | ||||
-rw-r--r-- | Tools/c-analyzer/cpython/ignored.tsv | 53 |
4 files changed, 87 insertions, 8 deletions
diff --git a/Tools/c-analyzer/c_parser/info.py b/Tools/c-analyzer/c_parser/info.py index a1d349d..e9783cc 100644 --- a/Tools/c-analyzer/c_parser/info.py +++ b/Tools/c-analyzer/c_parser/info.py @@ -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 @@ -1012,6 +1015,18 @@ class Signature(namedtuple('Signature', 'params returntype inline isforward')): 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 @@ -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): diff --git a/Tools/c-analyzer/c_parser/parser/_common.py b/Tools/c-analyzer/c_parser/parser/_common.py index 40c3603..d468d54 100644 --- a/Tools/c-analyzer/c_parser/parser/_common.py +++ b/Tools/c-analyzer/c_parser/parser/_common.py @@ -9,7 +9,11 @@ from ._regexes import ( 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})') ############################# diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py index 14ab619..992d2e5 100644 --- a/Tools/c-analyzer/cpython/_parser.py +++ b/Tools/c-analyzer/cpython/_parser.py @@ -86,8 +86,6 @@ Objects/unicodetype_db.h # generated Python/deepfreeze/*.c Python/frozen_modules/*.h -Python/opcode_targets.h -Python/stdlib_module_names.h # @end=conf@ ''') @@ -109,9 +107,7 @@ Objects/stringlib/split.h Modules/_dbmmodule.c Modules/cjkcodecs/_codecs_*.c -Modules/expat/xmlrole.c Modules/expat/xmlparse.c -Python/initconfig.c ''') INCL_DIRS = clean_lines(''' @@ -308,8 +304,12 @@ MAX_SIZES = { _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), } diff --git a/Tools/c-analyzer/cpython/ignored.tsv b/Tools/c-analyzer/cpython/ignored.tsv index bc3b37d..04c540f 100644 --- a/Tools/c-analyzer/cpython/ignored.tsv +++ b/Tools/c-analyzer/cpython/ignored.tsv @@ -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 @@ -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 - |