aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2020-10-22 18:42:51 -0600
committerGitHub <noreply@github.com>2020-10-22 18:42:51 -0600
commit345cd37abe324ad4f60f80e2c3133b8849e54e9b (patch)
tree5d965e662dca9dcac19e7eddd63a3d9d0b816fed /Tools/c-analyzer/c_analyzer/symbols/info.py
parentbpo-38486: Fix dead qmail links in the mailbox docs (GH-22239) (diff)
downloadcpython-345cd37abe324ad4f60f80e2c3133b8849e54e9b.tar.gz
cpython-345cd37abe324ad4f60f80e2c3133b8849e54e9b.tar.bz2
cpython-345cd37abe324ad4f60f80e2c3133b8849e54e9b.zip
bpo-36876: Fix the C analyzer tool. (GH-22841)
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
Diffstat (limited to 'Tools/c-analyzer/c_analyzer/symbols/info.py')
-rw-r--r--Tools/c-analyzer/c_analyzer/symbols/info.py51
1 files changed, 0 insertions, 51 deletions
diff --git a/Tools/c-analyzer/c_analyzer/symbols/info.py b/Tools/c-analyzer/c_analyzer/symbols/info.py
deleted file mode 100644
index 96a251abb7c..00000000000
--- a/Tools/c-analyzer/c_analyzer/symbols/info.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from collections import namedtuple
-
-from c_analyzer.common.info import ID
-from c_analyzer.common.util import classonly, _NTBase
-
-
-class Symbol(_NTBase, namedtuple('Symbol', 'id kind external')):
- """Info for a single compilation symbol."""
-
- __slots__ = ()
-
- class KIND:
- VARIABLE = 'variable'
- FUNCTION = 'function'
- OTHER = 'other'
-
- @classonly
- def from_name(cls, name, filename=None, kind=KIND.VARIABLE, external=None):
- """Return a new symbol based on the given name."""
- id = ID(filename, None, name)
- return cls(id, kind, external)
-
- def __new__(cls, id, kind=KIND.VARIABLE, external=None):
- self = super().__new__(
- cls,
- id=ID.from_raw(id),
- kind=str(kind) if kind else None,
- external=bool(external) if external is not None else None,
- )
- return self
-
- def __hash__(self):
- return hash(self.id)
-
- def __getattr__(self, name):
- return getattr(self.id, name)
-
- def validate(self):
- """Fail if the object is invalid (i.e. init with bad data)."""
- if not self.id:
- raise TypeError('missing id')
- else:
- self.id.validate()
-
- if not self.kind:
- raise TypeError('missing kind')
- elif self.kind not in vars(self.KIND).values():
- raise ValueError(f'unsupported kind {self.kind}')
-
- if self.external is None:
- raise TypeError('missing external')