Skip to content

Commit c5b7794

Browse files
authored
Use stmt.location.method instead of stmt.method (#312)
1 parent e4ac429 commit c5b7794

12 files changed

Lines changed: 40 additions & 28 deletions

File tree

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Versions {
66
const val clikt = "5.0.0"
77
const val detekt = "1.23.7"
88
const val ini4j = "0.5.4"
9-
const val jacodb = "d7dd9d343b"
9+
const val jacodb = "081adc271e"
1010
const val juliet = "1.3.2"
1111
const val junit = "5.9.3"
1212
const val kotlin = "2.1.0"

usvm-dataflow/src/main/kotlin/org/usvm/dataflow/ifds/Vertex.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ data class Vertex<out Fact, out Statement : CommonInst>(
2424
val fact: Fact,
2525
) {
2626
val method: CommonMethod
27-
get() = statement.method
27+
get() = statement.location.method
2828

2929
override fun toString(): String {
3030
return "$fact at $statement in $method"

usvm-jvm/src/main/kotlin/org/usvm/machine/JcMethodCallInst.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface JcTransparentInstruction : JcInst {
2323
* Auxiliary instruction to handle method calls.
2424
* */
2525
sealed interface JcMethodCallBaseInst : JcTransparentInstruction {
26-
override val method: JcMethod
26+
val method: JcMethod
2727

2828
override val operands: List<JcExpr>
2929
get() = emptyList()

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/graph/EtsApplicationGraph.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ class EtsApplicationGraphImpl(
8080
) : EtsApplicationGraph {
8181

8282
override fun predecessors(node: EtsStmt): Sequence<EtsStmt> {
83-
val graph = node.method.flowGraph()
83+
val graph = node.location.method.flowGraph()
8484
val predecessors = graph.predecessors(node)
8585
return predecessors.asSequence()
8686
}
8787

8888
override fun successors(node: EtsStmt): Sequence<EtsStmt> {
89-
val graph = node.method.flowGraph()
89+
val graph = node.location.method.flowGraph()
9090
val successors = graph.successors(node)
9191
return successors.asSequence()
9292
}
@@ -139,8 +139,8 @@ class EtsApplicationGraphImpl(
139139
val callee = expr.callee
140140

141141
// Note: the resolving code below expects that at least the current method signature is known.
142-
check(node.method.signature.enclosingClass.isIdeal()) {
143-
"Incomplete signature in method: ${node.method}"
142+
check(node.location.method.signature.enclosingClass.isIdeal()) {
143+
"Incomplete signature in method: ${node.location.method}"
144144
}
145145

146146
// Note: specific resolve for constructor:
@@ -223,17 +223,17 @@ class EtsApplicationGraphImpl(
223223
// If the callee signature is not ideal, resolve it via a partial match...
224224
check(!callee.enclosingClass.isIdeal())
225225

226-
val cls = lookupClassWithIdealSignature(node.method.signature.enclosingClass).let {
226+
val cls = lookupClassWithIdealSignature(node.location.method.signature.enclosingClass).let {
227227
if (it.isNone) {
228-
error("Could not find the enclosing class: ${node.method.enclosingClass}")
228+
error("Could not find the enclosing class: ${node.location.method.enclosingClass}")
229229
}
230230
it.getOrThrow()
231231
}
232232

233233
// If the complete signature match failed,
234234
// try to find the unique not-the-same neighbour method in the same class:
235235
val neighbors = classMethodsByName[cls.signature].orEmpty()[callee.name].orEmpty()
236-
.filterNot { it.name == node.method.name }
236+
.filterNot { it.name == node.location.method.name }
237237
if (neighbors.isNotEmpty()) {
238238
val s = neighbors.singleOrNull()
239239
?: error("Multiple methods with the same name: $neighbors")
@@ -260,7 +260,7 @@ class EtsApplicationGraphImpl(
260260
.filterNot {
261261
compareClassSignatures(
262262
it.signature.enclosingClass,
263-
node.method.signature.enclosingClass
263+
node.location.method.signature.enclosingClass
264264
) != ComparisonResult.NotEqual
265265
}
266266
.toList()

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/ifds/EtsIfdsRunner.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import org.usvm.dataflow.ts.graph.EtsApplicationGraph
1616
import org.usvm.dataflow.ts.infer.AnalyzerEvent
1717
import org.usvm.dataflow.ts.infer.TypeInferenceManager
1818
import org.usvm.dataflow.ts.util.EtsTraits
19+
import org.usvm.dataflow.ts.util.etsMethod
1920

2021
class EtsIfdsRunner<Fact, Event : AnalyzerEvent>(
2122
override val graph: EtsApplicationGraph,
@@ -82,6 +83,6 @@ class EtsIfdsRunner<Fact, Event : AnalyzerEvent>(
8283
val (endStmt, endFact) = endVertex
8384

8485
val localPathEdge = EtsIfdsMethodRunner.PathEdge(endStmt.location.index, endFact)
85-
getMethodRunner(startVertex.statement.method).getSourceRunner(startVertex).propagate(localPathEdge)
86+
getMethodRunner(startVertex.etsMethod).getSourceRunner(startVertex).propagate(localPathEdge)
8687
}
8788
}

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/ifds/EtsIfdsSourceRunner.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.usvm.dataflow.ifds.Edge
55
import org.usvm.dataflow.ifds.Vertex
66
import org.usvm.dataflow.ts.ifds.EtsIfdsMethodRunner.PathEdge
77
import org.usvm.dataflow.ts.util.EtsTraits
8+
import org.usvm.dataflow.ts.util.etsMethod
89

910
internal class EtsIfdsSourceRunner<Fact>(
1011
val traits: EtsTraits,
@@ -112,7 +113,7 @@ internal class EtsIfdsSourceRunner<Fact>(
112113
// Propagate through the summary edge:
113114
for (callerPathEdge in callerPathEdges) {
114115
val summaryEdge = Edge(startVertex, currentVertex)
115-
val caller = callerPathEdge.from.statement.method
116+
val caller = callerPathEdge.from.etsMethod
116117
val callerRunner = methodRunner.commonRunner.getMethodRunner(caller)
117118
callerRunner.handleSummaryEdgeInCaller(currentEdge = callerPathEdge, summaryEdge = summaryEdge)
118119
}

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/infer/ApplicationGraph.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class EtsApplicationGraphWithExplicitEntryPoint(
5353
override fun successors(node: EtsStmt): Sequence<EtsStmt> {
5454
if (node.location.index == -1) {
5555
require(node is EtsNopStmt)
56-
return graph.entryPoints(node.method)
56+
return graph.entryPoints(node.location.method)
5757
}
5858
return graph.successors(node)
5959
}
@@ -64,7 +64,7 @@ class EtsApplicationGraphWithExplicitEntryPoint(
6464
return emptySequence()
6565
}
6666
if (node.location.index == 0) {
67-
return entryPoints(node.method)
67+
return entryPoints(node.location.method)
6868
}
6969
return graph.predecessors(node)
7070
}

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/infer/BackwardFlowFunctions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class BackwardFlowFunctions(
5353
return@FlowFunction listOf(fact)
5454
}
5555
}
56-
val liveVars = liveVariables(current.method)
56+
val liveVars = liveVariables(current.location.method)
5757
when (fact) {
5858
Zero -> sequentZero(current)
5959
is TypedVariable -> sequentTypedVariable(current, fact).filter {
@@ -82,7 +82,7 @@ class BackwardFlowFunctions(
8282
// ∅ |= x:unknown
8383
val returnValue = current.returnValue ?: return listOf(Zero)
8484
val type = if (doAddKnownTypes) {
85-
val knownType = returnValue.tryGetKnownType(current.method)
85+
val knownType = returnValue.tryGetKnownType(current.location.method)
8686
EtsTypeFact.from(knownType).fixAnyToUnknown()
8787
} else {
8888
EtsTypeFact.UnknownEtsTypeFact
@@ -103,7 +103,7 @@ class BackwardFlowFunctions(
103103
// Case `x... := y`
104104
// ∅ |= y:unknown
105105
val type = if (doAddKnownTypes) {
106-
val knownType = current.rhv.tryGetKnownType(current.method)
106+
val knownType = current.rhv.tryGetKnownType(current.location.method)
107107
EtsTypeFact.from(knownType).fixAnyToUnknown()
108108
} else {
109109
EtsTypeFact.UnknownEtsTypeFact

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/infer/ForwardAnalyzer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class ForwardAnalyzer(
3434
private fun variableIsDying(fact: ForwardTypeDomainFact, stmt: EtsStmt): Boolean {
3535
if (fact !is ForwardTypeDomainFact.TypedVariable) return false
3636
return when (val base = fact.variable.base) {
37-
is AccessPathBase.Local -> !flowFunctions.liveVariables(stmt.method).isAliveAt(base.name, stmt)
38-
is AccessPathBase.Arg -> !flowFunctions.liveVariables(stmt.method).isAliveAt("arg(${base.index})", stmt)
37+
is AccessPathBase.Local -> !flowFunctions.liveVariables(stmt.location.method).isAliveAt(base.name, stmt)
38+
is AccessPathBase.Arg -> !flowFunctions.liveVariables(stmt.location.method).isAliveAt("arg(${base.index})", stmt)
3939
else -> false
4040
}
4141
}

usvm-ts-dataflow/src/main/kotlin/org/usvm/dataflow/ts/infer/ForwardFlowFunctions.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class ForwardFlowFunctions(
167167
when (fact) {
168168
Zero -> sequentZero(current)
169169
is TypedVariable -> {
170-
val liveVars = liveVariables(current.method)
170+
val liveVars = liveVariables(current.location.method)
171171
sequentFact(current, fact).myFilter()
172172
.filter {
173173
when (val base = it.variable.base) {
@@ -184,7 +184,7 @@ class ForwardFlowFunctions(
184184

185185
val lhv = current.lhv.toPath()
186186
val result = mutableListOf<ForwardTypeDomainFact>(Zero)
187-
val preAliases = getAliases(current.method)[current.location.index]
187+
val preAliases = getAliases(current.location.method)[current.location.index]
188188

189189
fun addTypeFactWithAliases(path: AccessPath, type: EtsTypeFact) {
190190
result += TypedVariable(path, type)
@@ -193,7 +193,7 @@ class ForwardFlowFunctions(
193193
val base = AccessPath(path.base, emptyList())
194194
val aliases = preAliases.getAliases(base).filter {
195195
when (val b = it.base) {
196-
is AccessPathBase.Local -> liveVariables(current.method).isAliveAt(b.name, current)
196+
is AccessPathBase.Local -> liveVariables(current.location.method).isAliveAt(b.name, current)
197197
else -> true
198198
}
199199
}
@@ -302,7 +302,7 @@ class ForwardFlowFunctions(
302302
}
303303
}
304304

305-
val preAliases = getAliases(current.method)[current.location.index]
305+
val preAliases = getAliases(current.location.method)[current.location.index]
306306

307307
// Override LHS when RHS is const-like:
308308
if (rhv == null) {
@@ -479,7 +479,7 @@ class ForwardFlowFunctions(
479479

480480
val aliases = preAliases.getAliases(x).filter {
481481
when (val b = it.base) {
482-
is AccessPathBase.Local -> liveVariables(current.method).isAliveAt(b.name, current)
482+
is AccessPathBase.Local -> liveVariables(current.location.method).isAliveAt(b.name, current)
483483
else -> true
484484
}
485485
}

0 commit comments

Comments
 (0)