MCPcopy Index your code
hub / github.com/python/mypy / analyze_always_defined_attrs

Function analyze_always_defined_attrs

mypyc/analysis/attrdefined.py:100–125  ·  view source on GitHub ↗

Find always defined attributes all classes of a compilation unit. Also tag attribute initialization ops to not decref the previous value (as this would read a NULL pointer and segfault). Update the _always_initialized_attrs, _sometimes_initialized_attrs and init_self_leak attribute

(class_irs: list[ClassIR])

Source from the content-addressed store, hash-verified

98
99
100def analyze_always_defined_attrs(class_irs: list[ClassIR]) -> None:
101 """Find always defined attributes all classes of a compilation unit.
102
103 Also tag attribute initialization ops to not decref the previous
104 value (as this would read a NULL pointer and segfault).
105
106 Update the _always_initialized_attrs, _sometimes_initialized_attrs
107 and init_self_leak attributes in ClassIR instances.
108
109 This is the main entry point.
110 """
111 seen: set[ClassIR] = set()
112
113 # First pass: only look at target class and classes in MRO
114 for cl in class_irs:
115 analyze_always_defined_attrs_in_class(cl, seen)
116
117 # Second pass: look at all derived class
118 seen = set()
119 for cl in class_irs:
120 update_always_defined_attrs_using_subclasses(cl, seen)
121
122 # Final pass: detect attributes that need to use a bitmap to track definedness
123 seen = set()
124 for cl in class_irs:
125 detect_undefined_bitmap(cl, seen)
126
127
128def analyze_always_defined_attrs_in_class(cl: ClassIR, seen: set[ClassIR]) -> None:

Callers 1

build_irFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…