Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-36876: Fix the C analyzer tool.#22841

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
Fix the "full" and "summary" check formats.
  • Loading branch information
@ericsnowcurrently
ericsnowcurrently committedOct 23, 2020
commit6333a55fbaf85d9c834e4c36cfd2ad6dff3771d8
17 changes: 11 additions & 6 deletionsTools/c-analyzer/c_analyzer/__main__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -160,14 +160,16 @@ def handle_failure(failure, data):
print(f'{failure!r} {data!r}')
elif fmt == 'brief':
def handle_failure(failure, data):
print(f'{data.filename}\t{data.parent or "-"}\t{data.name}\t{failure!r}')
parent = data.parent or ''
funcname = parent if isinstance(parent, str) else parent.name
name = f'({funcname}).{data.name}' if funcname else data.name
failure = failure.split('\t')[0]
print(f'{data.filename}:{name} - {failure}')
elif fmt == 'summary':
failures = []
def handle_failure(failure, data):
failures.append((failure, data))
def handle_after():
# XXX
raise NotImplementedError
parent = data.parent or ''
funcname = parent if isinstance(parent, str) else parent.name
print(f'{data.filename:35}\t{funcname or "-":35}\t{data.name:40}\t{failure}')
elif fmt == 'full':
div = ''
def handle_failure(failure, data):
Expand DownExpand Up@@ -283,6 +285,7 @@ def cmd_check(filenames, *,
checks=None,
ignored=None,
fmt=None,
relroot=None,
failfast=False,
iter_filenames=None,
verbosity=VERBOSITY,
Expand All@@ -304,6 +307,8 @@ def cmd_check(filenames, *,

logger.info('analyzing...')
analyzed = _analyze(filenames, **kwargs)
if relroot:
analyzed.fix_filenames(relroot)

logger.info('checking...')
numfailed = 0
Expand Down
7 changes: 7 additions & 0 deletionsTools/c-analyzer/c_analyzer/info.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -257,6 +257,9 @@ def is_known(self):
else:
return UNKNOWN not in self.typedecl

def fix_filename(self, relroot):
self.item.fix_filename(relroot)

def as_rowdata(self, columns=None):
# XXX finsih!
return self.item.as_rowdata(columns)
Expand DownExpand Up@@ -340,6 +343,10 @@ def __getitem__(self, key):
else:
return self._analyzed[key]

def fix_filenames(self, relroot):
for item in self._analyzed:
item.fix_filename(relroot)

def _add_result(self, info, resolved):
analyzed = type(self).build_item(info, resolved)
self._analyzed[analyzed] = None
Expand Down
9 changes: 9 additions & 0 deletionsTools/c-analyzer/c_parser/info.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
from collections import namedtuple
import enum
import os.path
import re

from c_common.clsutil import classonly
Expand DownExpand Up@@ -287,6 +288,10 @@ def from_raw(cls, raw):
def __str__(self):
return self.filename

def fix_filename(self, relroot):
filename = os.path.relpath(self.filename, relroot)
return self._replace(filename=filename)


class SourceLine(namedtuple('Line', 'file kind data conditions')):
KINDS = (
Expand DownExpand Up@@ -688,6 +693,10 @@ def parsed(self):
)
return self._parsed

def fix_filename(self, relroot):
if self.file:
self.file = self.file.fix_filename(relroot)

def as_rowdata(self, columns=None):
columns, datacolumns, colnames = self._parse_columns(columns)
return self._as_row(colnames, datacolumns, self._data_as_row)
Expand Down
1 change: 1 addition & 0 deletionsTools/c-analyzer/cpython/__main__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -114,6 +114,7 @@ def cmd_check(filenames=None, **kwargs):
kwargs['get_file_preprocessor'] = _parser.get_preprocessor(log_err=print)
c_analyzer.cmd_check(
filenames,
relroot=REPO_ROOT,
_analyze=_analyzer.analyze,
_CHECKS=CHECKS,
**kwargs
Expand Down
9 changes: 8 additions & 1 deletionTools/c-analyzer/cpython/_analyzer.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -338,4 +338,11 @@ def check_globals(analysis):
continue
if item.id in ignored:
continue
yield item, 'not supported'
reason = item.unsupported
if not reason:
reason = '???'
elif not isinstance(reason, str):
if len(reason) == 1:
reason, = reason
reason = f'({reason})'
yield item, f'not supported {reason:20}\t{item.storage or ""} {item.vartype}'
Loading

[8]ページ先頭

©2009-2025 Movatter.jp