[PATCH] D104917: [Analyzer] Extend exploded-graph-rewriter to support eq and diseq classes
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 25 07:26:07 PDT 2021
martong created this revision.
martong added reviewers: steakhal, vsavchenko, NoQ.
Herald added subscribers: manas, ASDenysPetrov, gamesh411, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, whisperity.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104917
Files:
clang/utils/analyzer/exploded-graph-rewriter.py
Index: clang/utils/analyzer/exploded-graph-rewriter.py
===================================================================
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ 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 "<br />".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',
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104917.354493.patch
Type: text/x-patch
Size: 2920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210625/5debf672/attachment.bin>
More information about the cfe-commits
mailing list