@@ -40,6 +40,8 @@ class InterProceduralUnitGraph(graph: ExceptionalUnitGraph) {
40
40
41
41
val stmts: MutableSet <Stmt > = graph.stmts.toMutableSet()
42
42
val registeredEdges: MutableSet <Edge > = graph.edges.toMutableSet()
43
+ // this field is required for visualization
44
+ val allEdges: MutableSet <Edge > = graph.edges.toMutableSet()
43
45
/* *
44
46
* Used in [org.utbot.engine.selectors.nurs.InheritorsSelector] for a fast search of Virtual invoke successors.
45
47
*/
@@ -54,6 +56,7 @@ class InterProceduralUnitGraph(graph: ExceptionalUnitGraph) {
54
56
private val edgeToGraph: MutableMap <Edge , ExceptionalUnitGraph > = graph.edges.associateWithTo(mutableMapOf ()) { graph }
55
57
56
58
private val registeredEdgesCount: MutableMap <Stmt , Int > = graph.outgoingEdgesCount
59
+ private val allEdgesCount: MutableMap <Stmt , Int > = graph.outgoingEdgesCount
57
60
private val outgoingEdgesCount: MutableMap <Stmt , Int > = graph.outgoingEdgesCount
58
61
59
62
fun method (stmt : Stmt ): SootMethod = stmtToGraph[stmt]?.body?.method ? : error(" $stmt not in graph." )
@@ -125,6 +128,12 @@ class InterProceduralUnitGraph(graph: ExceptionalUnitGraph) {
125
128
outgoingEdgesCount + = graph.outgoingEdgesCount
126
129
stmts + = joinedStmts
127
130
131
+ allEdges + = graph.edges
132
+ allEdgesCount + = graph.outgoingEdgesCount
133
+ allEdgesCount.computeIfPresent(stmt) { _, value ->
134
+ value + 1
135
+ }
136
+
128
137
if (registerEdges) {
129
138
registeredMethods + = method
130
139
registeredEdgesCount + = graph.outgoingEdgesCount
@@ -144,6 +153,7 @@ class InterProceduralUnitGraph(graph: ExceptionalUnitGraph) {
144
153
}
145
154
146
155
registeredEdges + = invokeEdge
156
+ allEdges + = invokeEdge
147
157
148
158
outgoingEdgesCount.computeIfPresent(stmt) { _, value ->
149
159
value + 1
@@ -168,11 +178,8 @@ class InterProceduralUnitGraph(graph: ExceptionalUnitGraph) {
168
178
169
179
when (edge) {
170
180
in implicitEdges -> coveredImplicitEdges + = edge
171
- !in registeredEdges -> {
181
+ !in registeredEdges, !in coveredEdges -> {
172
182
coveredOutgoingEdges.putIfAbsent(edge.src, 0 )
173
- coveredEdges + = edge
174
- }
175
- !in coveredEdges -> {
176
183
coveredOutgoingEdges.compute(edge.src) { _, value -> (value ? : 0 ) + 1 }
177
184
coveredEdges + = edge
178
185
}
@@ -280,7 +287,10 @@ class InterProceduralUnitGraph(graph: ExceptionalUnitGraph) {
280
287
* Statement is covered if all the outgoing edges are covered.
281
288
*/
282
289
fun isCovered (stmt : Stmt ) =
283
- stmt !in registeredEdgesCount || stmt in coveredOutgoingEdges && coveredOutgoingEdges[stmt]!! >= registeredEdgesCount[stmt]!!
290
+ stmt !in registeredEdgesCount || isCoveredIgnoringRegistration(stmt)
291
+
292
+ fun isCoveredIgnoringRegistration (stmt : Stmt ) =
293
+ stmt in coveredOutgoingEdges && coveredOutgoingEdges[stmt]!! >= allEdgesCount[stmt]!!
284
294
285
295
/* *
286
296
* Edge is covered if we visited it in successfully completed execution at least once
0 commit comments