diff --git a/clang/utils/analyzer/exploded-graph-rewriter.py b/clang/utils/analyzer/exploded-graph-rewriter.py --- a/clang/utils/analyzer/exploded-graph-rewriter.py +++ b/clang/utils/analyzer/exploded-graph-rewriter.py @@ -267,6 +267,8 @@ 'store': None, 'environment': None, 'constraints': None, + 'equivalence_classes': None, + 'disequality_info': None, 'dynamic_types': None, 'constructing_objects': None, 'checker_messages': None @@ -285,6 +287,39 @@ (c['symbol'], c['range']) for c in json_ps['constraints'] ]) if json_ps['constraints'] is not None else None + # Each equivalence_class is represented as List[Str]. + # json_ps['equivalence_classes']: List[List[Str]] + # Sort by the first element of each equivalence_class. + eq_classes = ( + sorted(json_ps['equivalence_classes'], key=lambda eqc: eqc[0]) + if json_ps['equivalence_classes'] + else None + ) + self.equivalence_classes = ( + GenericMap({i: ", ".join(eq_classes[i]) for i in range(0, len(eq_classes))}) + if eq_classes + else None + ) + + # Each equivalence_class is represented as List[Str]. + # Disequality info is a mapping from an equivalence class to many + # equivalence classes: + # json_ps['disequality_info']: Dict[List[Str], List[List[Str]]] + def get_diseq_classes(classes): + """ Flatten List[List[Str]] to Str """ + return "
".join([", ".join(cl) for cl in classes]) + + self.disequality_info = ( + GenericMap( + { + ", ".join(c["class"]): get_diseq_classes(c["disequal_to"]) + for c in json_ps["disequality_info"] + } + ) + if json_ps["disequality_info"] + else None + ) + self.dynamic_types = GenericMap([ (t['region'], '%s%s' % (t['dyn_type'], ' (or a sub-class)' @@ -791,6 +826,12 @@ s, prev_s) self.visit_generic_map_in_state('constraints', 'Ranges', s, prev_s) + self.visit_generic_map_in_state('equivalence_classes', + 'Equivalence Classes', + s, prev_s) + self.visit_generic_map_in_state('disequality_info', + 'Disequality Info', + s, prev_s) self.visit_generic_map_in_state('dynamic_types', 'Dynamic Types', s, prev_s) self.visit_environment_in_state('constructing_objects',