summaryrefslogtreecommitdiffstats
path: root/Tools/c-analyzer/cpython/_parser.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2021-12-01 18:20:20 (GMT)
committerGitHub <noreply@github.com>2021-12-01 18:20:20 (GMT)
commitee94aa0850191712e6adfc1f4a9df08ec3240195 (patch)
tree7b739a21cf64a77be3431224d32d90084027d446 /Tools/c-analyzer/cpython/_parser.py
parentf27bef30438d2f07f19de91e021f34b77ccc4b20 (diff)
downloadcpython-ee94aa0850191712e6adfc1f4a9df08ec3240195.zip
cpython-ee94aa0850191712e6adfc1f4a9df08ec3240195.tar.gz
cpython-ee94aa0850191712e6adfc1f4a9df08ec3240195.tar.bz2
bpo-45952: Get the C analyzer tool working again. (gh-29882)
There wasn't much that needed to be done. Mostly it was just a few new files that got added. https://bugs.python.org/issue45952
Diffstat (limited to 'Tools/c-analyzer/cpython/_parser.py')
-rw-r--r--Tools/c-analyzer/cpython/_parser.py81
1 files changed, 55 insertions, 26 deletions
diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py
index 8526b2a..90b470c 100644
--- a/Tools/c-analyzer/cpython/_parser.py
+++ b/Tools/c-analyzer/cpython/_parser.py
@@ -14,6 +14,10 @@ from . import REPO_ROOT
GLOB_ALL = '**/*'
+def _abs(relfile):
+ return os.path.join(REPO_ROOT, relfile)
+
+
def clean_lines(text):
"""Clear out comments, blank lines, and leading/trailing whitespace."""
lines = (line.strip() for line in text.splitlines())
@@ -22,7 +26,7 @@ def clean_lines(text):
if line and not line.startswith('#'))
glob_all = f'{GLOB_ALL} '
lines = (re.sub(r'^[*] ', glob_all, line) for line in lines)
- lines = (os.path.join(REPO_ROOT, line) for line in lines)
+ lines = (_abs(line) for line in lines)
return list(lines)
@@ -55,26 +59,31 @@ Modules/_scproxy.c # SystemConfiguration/SystemConfiguration.h
# Windows
Modules/_winapi.c # windows.h
+Modules/expat/winconfig.h
Modules/overlapped.c # winsock.h
Python/dynload_win.c # windows.h
-Modules/expat/winconfig.h
Python/thread_nt.h
# other OS-dependent
+Python/dynload_aix.c # sys/ldr.h
Python/dynload_dl.c # dl.h
Python/dynload_hpux.c # dl.h
-Python/dynload_aix.c # sys/ldr.h
Python/thread_pthread.h
# only huge constants (safe but parsing is slow)
+Modules/_blake2/impl/blake2-kat.h
Modules/_ssl_data.h
+Modules/_ssl_data_300.h
+Modules/_ssl_data_111.h
+Modules/cjkcodecs/mappings_*.h
Modules/unicodedata_db.h
Modules/unicodename_db.h
-Modules/cjkcodecs/mappings_*.h
Objects/unicodetype_db.h
-Python/importlib.h
-Python/importlib_external.h
-Python/importlib_zipimport.h
+
+# generated
+Python/frozen_modules/*.h
+Python/opcode_targets.h
+Python/stdlib_module_names.h
# @end=conf@
''')
@@ -126,35 +135,40 @@ Python/**/*.c Py_BUILD_CORE 1
Parser/**/*.c Py_BUILD_CORE 1
Objects/**/*.c Py_BUILD_CORE 1
-Modules/faulthandler.c Py_BUILD_CORE 1
+Modules/_asynciomodule.c Py_BUILD_CORE 1
+Modules/_collectionsmodule.c Py_BUILD_CORE 1
+Modules/_ctypes/_ctypes.c Py_BUILD_CORE 1
+Modules/_ctypes/cfield.c Py_BUILD_CORE 1
+Modules/_cursesmodule.c Py_BUILD_CORE 1
+Modules/_datetimemodule.c Py_BUILD_CORE 1
Modules/_functoolsmodule.c Py_BUILD_CORE 1
-Modules/gcmodule.c Py_BUILD_CORE 1
-Modules/getpath.c Py_BUILD_CORE 1
+Modules/_heapqmodule.c Py_BUILD_CORE 1
Modules/_io/*.c Py_BUILD_CORE 1
-Modules/itertoolsmodule.c Py_BUILD_CORE 1
Modules/_localemodule.c Py_BUILD_CORE 1
-Modules/main.c Py_BUILD_CORE 1
-Modules/posixmodule.c Py_BUILD_CORE 1
-Modules/signalmodule.c Py_BUILD_CORE 1
+Modules/_operator.c Py_BUILD_CORE 1
+Modules/_posixsubprocess.c Py_BUILD_CORE 1
+Modules/_sre.c Py_BUILD_CORE 1
Modules/_threadmodule.c Py_BUILD_CORE 1
Modules/_tracemalloc.c Py_BUILD_CORE 1
-Modules/_asynciomodule.c Py_BUILD_CORE 1
-Modules/mathmodule.c Py_BUILD_CORE 1
-Modules/cmathmodule.c Py_BUILD_CORE 1
Modules/_weakref.c Py_BUILD_CORE 1
+Modules/_zoneinfo.c Py_BUILD_CORE 1
+Modules/atexitmodule.c Py_BUILD_CORE 1
+Modules/cmathmodule.c Py_BUILD_CORE 1
+Modules/faulthandler.c Py_BUILD_CORE 1
+Modules/gcmodule.c Py_BUILD_CORE 1
+Modules/getpath.c Py_BUILD_CORE 1
+Modules/itertoolsmodule.c Py_BUILD_CORE 1
+Modules/main.c Py_BUILD_CORE 1
+Modules/mathmodule.c Py_BUILD_CORE 1
+Modules/posixmodule.c Py_BUILD_CORE 1
Modules/sha256module.c Py_BUILD_CORE 1
Modules/sha512module.c Py_BUILD_CORE 1
-Modules/_datetimemodule.c Py_BUILD_CORE 1
-Modules/_ctypes/cfield.c Py_BUILD_CORE 1
-Modules/_heapqmodule.c Py_BUILD_CORE 1
-Modules/_posixsubprocess.c Py_BUILD_CORE 1
-Modules/_sre.c Py_BUILD_CORE 1
-Modules/_collectionsmodule.c Py_BUILD_CORE 1
-Modules/_zoneinfo.c Py_BUILD_CORE 1
+Modules/signalmodule.c Py_BUILD_CORE 1
+Modules/symtablemodule.c Py_BUILD_CORE 1
+Modules/timemodule.c Py_BUILD_CORE 1
Modules/unicodedata.c Py_BUILD_CORE 1
-Modules/_cursesmodule.c Py_BUILD_CORE 1
-Modules/_ctypes/_ctypes.c Py_BUILD_CORE 1
Objects/stringlib/codecs.h Py_BUILD_CORE 1
+Objects/stringlib/unicode_format.h Py_BUILD_CORE 1
Python/ceval_gil.h Py_BUILD_CORE 1
Python/condvar.h Py_BUILD_CORE 1
@@ -244,6 +258,7 @@ Modules/_dbmmodule.c HAVE_GDBM_DASH_NDBM_H 1
Modules/sre_lib.h LOCAL(type) static inline type
Modules/sre_lib.h SRE(F) sre_ucs2_##F
Objects/stringlib/codecs.h STRINGLIB_IS_UNICODE 1
+Include/internal/pycore_bitutils.h _Py__has_builtin(B) 0
# @end=tsv@
''')[1:]
@@ -264,6 +279,18 @@ SAME = [
'./Include/cpython/',
]
+MAX_SIZES = {
+ _abs('Include/**/*.h'): (5_000, 500),
+ _abs('Modules/_ctypes/ctypes.h'): (5_000, 500),
+ _abs('Modules/_datetimemodule.c'): (20_000, 300),
+ _abs('Modules/posixmodule.c'): (20_000, 500),
+ _abs('Modules/termios.c'): (10_000, 800),
+ _abs('Modules/_testcapimodule.c'): (20_000, 400),
+ _abs('Modules/expat/expat.h'): (10_000, 400),
+ _abs('Objects/stringlib/unicode_format.h'): (10_000, 400),
+ _abs('Objects/typeobject.c'): (20_000, 200),
+}
+
def get_preprocessor(*,
file_macros=None,
@@ -298,6 +325,7 @@ def parse_file(filename, *,
filename,
match_kind=match_kind,
get_file_preprocessor=get_file_preprocessor,
+ file_maxsizes=MAX_SIZES,
)
@@ -317,5 +345,6 @@ def parse_files(filenames=None, *,
filenames,
match_kind=match_kind,
get_file_preprocessor=get_file_preprocessor,
+ file_maxsizes=MAX_SIZES,
**file_kwargs
)