r364865 - [analyzer] exploded-graph-rewriter: Add support for dynamic types.
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 1 16:01:59 PDT 2019
Author: dergachev
Date: Mon Jul 1 16:01:59 2019
New Revision: 364865
URL: http://llvm.org/viewvc/llvm-project?rev=364865&view=rev
Log:
[analyzer] exploded-graph-rewriter: Add support for dynamic types.
Slightly cleanup emission of horizontal lines and unhardcode the title
for generic maps.
Differential Revision: https://reviews.llvm.org/D64041
Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints_diff.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/environment_diff.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/store_diff.dot
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints.dot?rev=364865&r1=364864&r2=364865&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints.dot Mon Jul 1 16:01:59 2019
@@ -19,6 +19,7 @@ Node0x1 [shape=record,label=
"program_state": {
"store": null,
"environment": null,
+ "dynamic_types": null,
"constraints": [
{ "symbol": "reg_$0<x>", "range": "{ [0, 0] }" }
]
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints_diff.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints_diff.dot?rev=364865&r1=364864&r2=364865&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints_diff.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/constraints_diff.dot Mon Jul 1 16:01:59 2019
@@ -12,6 +12,7 @@ Node0x1 [shape=record,label=
"program_state": {
"store": null,
"environment": null,
+ "dynamic_types": null,
"constraints": [
{ "symbol": "reg_$0<x>", "range": "{ [0, 10] }" }
]
@@ -41,6 +42,7 @@ Node0x3 [shape=record,label=
"program_state": {
"store": null,
"environment": null,
+ "dynamic_types": null,
"constraints": [
{ "symbol": "reg_$0<x>", "range": "{ [0, 5] }" }
]
@@ -59,7 +61,8 @@ Node0x5 [shape=record,label=
"program_state": {
"store": null,
"environment": null,
- "constraints": null
+ "constraints": null,
+ "dynamic_types": null
}
}
\l}"];
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot?rev=364865&r1=364864&r2=364865&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot Mon Jul 1 16:01:59 2019
@@ -34,6 +34,7 @@ Node0x1 [shape=record,label=
"program_state": {
"store": null,
"constraints": null,
+ "dynamic_types": null,
"environment": {
"pointer": "0x2",
"items": [
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/environment_diff.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/environment_diff.dot?rev=364865&r1=364864&r2=364865&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/environment_diff.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/environment_diff.dot Mon Jul 1 16:01:59 2019
@@ -13,6 +13,7 @@ Node0x1 [shape=record,label=
"program_state": {
"store": null,
"constraints": null,
+ "dynamic_types": null,
"environment": {
"pointer": "0x2",
"items": [
@@ -59,6 +60,7 @@ Node0x6 [shape=record,label=
"program_state": {
"store": null,
"constraints": null,
+ "dynamic_types": null,
"environment": {
"pointer": "0x2",
"items": [
@@ -99,6 +101,7 @@ Node0x9 [shape=record,label=
"program_state": {
"store": null,
"constraints": null,
+ "dynamic_types": null,
"environment": {
"pointer": "0x2",
"items": [
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot?rev=364865&r1=364864&r2=364865&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/store.dot Mon Jul 1 16:01:59 2019
@@ -29,6 +29,7 @@ Node0x1 [shape=record,label=
"program_state": {
"environment": null,
"constraints": null,
+ "dynamic_types": null,
"store": {
"pointer": "0x2",
"items": [
Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/store_diff.dot
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/store_diff.dot?rev=364865&r1=364864&r2=364865&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/store_diff.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/store_diff.dot Mon Jul 1 16:01:59 2019
@@ -12,6 +12,7 @@ Node0x1 [shape=record,label=
"program_state": {
"environment": null,
"constraints": null,
+ "dynamic_types": null,
"store": {
"pointer": "0x2",
"items": [
@@ -57,6 +58,7 @@ Node0x4 [shape=record,label=
"program_state": {
"environment": null,
"constraints": null,
+ "dynamic_types": null,
"store": {
"pointer": "0x5",
"items": [
Modified: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/exploded-graph-rewriter.py?rev=364865&r1=364864&r2=364865&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py (original)
+++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py Mon Jul 1 16:01:59 2019
@@ -27,8 +27,8 @@ def diff_dicts(curr, prev):
# Represents any program state trait that is a dictionary of key-value pairs.
class GenericMap(object):
- def __init__(self, generic_map):
- self.generic_map = generic_map
+ def __init__(self, items):
+ self.generic_map = collections.OrderedDict(items)
def diff(self, prev):
return diff_dicts(self.generic_map, prev.generic_map)
@@ -218,11 +218,17 @@ class ProgramState(object):
if json_ps['store'] is not None else None
self.environment = Environment(json_ps['environment']) \
if json_ps['environment'] is not None else None
- self.constraints = GenericMap(collections.OrderedDict([
+ self.constraints = GenericMap([
(c['symbol'], c['range']) for c in json_ps['constraints']
- ])) if json_ps['constraints'] is not None else None
+ ]) if json_ps['constraints'] is not None else None
+ self.dynamic_types = GenericMap([
+ (t['region'], '%s%s' % (t['dyn_type'],
+ ' (or a sub-class)'
+ if t['sub_classable'] else ''))
+ for t in json_ps['dynamic_types']]) \
+ if json_ps['dynamic_types'] is not None else None
+
# TODO: Objects under construction.
- # TODO: Dynamic types of objects.
# TODO: Checker messages.
@@ -435,8 +441,7 @@ class DotDumpVisitor(object):
self._dump('</table>')
def visit_environment_in_state(self, s, prev_s=None):
- self._dump('<tr><td align="left">'
- '<b>Environment: </b>')
+ self._dump('<hr /><tr><td align="left"><b>Environment: </b>')
if s.environment is None:
self._dump('<i> Nothing!</i>')
else:
@@ -491,7 +496,7 @@ class DotDumpVisitor(object):
self._dump('</table>')
def visit_store_in_state(self, s, prev_s=None):
- self._dump('<tr><td align="left"><b>Store: </b>')
+ self._dump('<hr /><tr><td align="left"><b>Store: </b>')
if s.store is None:
self._dump('<i> Nothing!</i>')
else:
@@ -528,16 +533,19 @@ class DotDumpVisitor(object):
self._dump('</table>')
- def visit_generic_map_in_state(self, selector, s, prev_s=None):
- self._dump('<tr><td align="left">'
- '<b>Ranges: </b>')
+ def visit_generic_map_in_state(self, selector, title, s, prev_s=None):
m = getattr(s, selector)
+ prev_m = getattr(prev_s, selector) if prev_s is not None else None
+ if m is None and prev_m is None:
+ return
+
+ self._dump('<hr />')
+ self._dump('<tr><td align="left">'
+ '<b>%s: </b>' % title)
if m is None:
self._dump('<i> Nothing!</i>')
else:
- prev_m = None
if prev_s is not None:
- prev_m = getattr(prev_s, selector)
if prev_m is not None:
if m.is_different(prev_m):
self._dump('</td></tr><tr><td align="left">')
@@ -551,10 +559,11 @@ class DotDumpVisitor(object):
def visit_state(self, s, prev_s):
self.visit_store_in_state(s, prev_s)
- self._dump('<hr />')
self.visit_environment_in_state(s, prev_s)
- self._dump('<hr />')
- self.visit_generic_map_in_state('constraints', s, prev_s)
+ self.visit_generic_map_in_state('constraints', 'Ranges',
+ s, prev_s)
+ self.visit_generic_map_in_state('dynamic_types', 'Dynamic Types',
+ s, prev_s)
def visit_node(self, node):
self._dump('%s [shape=record,label=<<table border="0">'
@@ -576,7 +585,6 @@ class DotDumpVisitor(object):
self._dump('</table></td></tr>')
if node.state is not None:
- self._dump('<hr />')
prev_s = None
# Do diffs only when we have a unique predecessor.
# Don't do diffs on the leaf nodes because they're
More information about the cfe-commits
mailing list