mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00

The original tool wasn't working right and it was simpler to create a new one, partially re-using some of the old code. At this point the tool runs properly on the master. (Try: ./python Tools/c-analyzer/c-analyzer.py analyze.) It take ~40 seconds on my machine to analyze the full CPython code base. Note that we'll need to iron out some OS-specific stuff (e.g. preprocessor). We're okay though since this tool isn't used yet in our workflow. We will also need to verify the analysis results in detail before activating the check in CI, though I'm pretty sure it's close. https://bugs.python.org/issue36876
23 lines
582 B
Python
23 lines
582 B
Python
from ..source import (
|
|
opened as _open_source,
|
|
)
|
|
from . import common as _common
|
|
|
|
|
|
def preprocess(lines, filename=None):
|
|
if isinstance(lines, str):
|
|
with _open_source(lines, filename) as (lines, filename):
|
|
yield from preprocess(lines, filename)
|
|
return
|
|
|
|
# XXX actually preprocess...
|
|
for lno, line in enumerate(lines, 1):
|
|
kind = 'source'
|
|
data = line
|
|
conditions = None
|
|
yield _common.SourceLine(
|
|
_common.FileInfo(filename, lno),
|
|
kind,
|
|
data,
|
|
conditions,
|
|
)
|