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])
| 98 | |
| 99 | |
| 100 | def 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 | |
| 128 | def analyze_always_defined_attrs_in_class(cl: ClassIR, seen: set[ClassIR]) -> None: |
no test coverage detected
searching dependent graphs…