[Python-checkins] gh-90110: Update the c-analyzer Tool (gh-96058)
ericsnowcurrently
webhook-mailer at python.org
Wed Aug 17 18:55:18 EDT 2022
https://github.com/python/cpython/commit/586fc02be5b3e103bfddd49654034a898a8d6dfc
commit: 586fc02be5b3e103bfddd49654034a898a8d6dfc
branch: main
author: Eric Snow <ericsnowcurrently at gmail.com>
committer: ericsnowcurrently <ericsnowcurrently at gmail.com>
date: 2022-08-17T16:54:59-06:00
summary:
gh-90110: Update the c-analyzer Tool (gh-96058)
files:
M Tools/c-analyzer/c_parser/info.py
M Tools/c-analyzer/c_parser/parser/_common.py
M Tools/c-analyzer/cpython/_parser.py
M Tools/c-analyzer/cpython/ignored.tsv
diff --git a/Tools/c-analyzer/c_parser/info.py b/Tools/c-analyzer/c_parser/info.py
index a1d349dc0b0d..e9783ccc9535 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 @@ 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
@@ -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 40c36039f3f4..d468d5442a93 100644
--- a/Tools/c-analyzer/c_parser/parser/_common.py
+++ b/Tools/c-analyzer/c_parser/parser/_common.py
@@ -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})')
#############################
diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py
index 14ab6198ff25..992d2e5a7c3d 100644
--- a/Tools/c-analyzer/cpython/_parser.py
+++ b/Tools/c-analyzer/cpython/_parser.py
@@ -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@
''')
@@ -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('''
@@ -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),
}
diff --git a/Tools/c-analyzer/cpython/ignored.tsv b/Tools/c-analyzer/cpython/ignored.tsv
index bc3b37dd7da0..04c540f8864d 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 -
More information about the Python-checkins
mailing list