Skip to content

Commit 98477cf

Browse files
Fix hash code definition of PD vars
1 parent ee321b1 commit 98477cf

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

OPAL/br/src/main/scala/org/opalj/br/PDUVar.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@ abstract class PDUVar[+Value <: ValueInformation] {
3434
}
3535

3636
class PDVar[+Value <: ValueInformation /*org.opalj.ai.ValuesDomain#DomainValue*/ ] private (
37-
val value: Value,
38-
val usePCs: PCs
37+
val originPC: Int,
38+
val value: Value,
39+
val usePCs: PCs
3940
) extends PDUVar[Value] {
4041

4142
def defPCs: Nothing = throw new UnsupportedOperationException
4243

44+
override def hashCode(): Int = scala.util.hashing.MurmurHash3.productHash((originPC, usePCs))
45+
4346
override def equals(other: Any): Boolean = {
4447
other match {
45-
case that: PDVar[_] => this.usePCs == that.usePCs
48+
case that: PDVar[_] => this.originPC == that.originPC && this.usePCs == that.usePCs
4649
case _ => false
4750
}
4851
}
@@ -54,9 +57,11 @@ class PDVar[+Value <: ValueInformation /*org.opalj.ai.ValuesDomain#DomainValue*/
5457

5558
object PDVar {
5659

57-
def apply[Value <: ValueInformation](value: Value, useSites: IntTrieSet): PDVar[Value] = new PDVar(value, useSites)
60+
def apply[Value <: ValueInformation](originSite: Int, value: Value, useSites: IntTrieSet): PDVar[Value] =
61+
new PDVar(originSite, value, useSites)
5862

59-
def unapply[Value <: ValueInformation](d: PDVar[Value]): Some[(Value, IntTrieSet)] = Some((d.value, d.usePCs))
63+
def unapply[Value <: ValueInformation](d: PDVar[Value]): Some[(Int, Value, IntTrieSet)] =
64+
Some((d.originPC, d.value, d.usePCs))
6065
}
6166

6267
class PUVar[+Value <: ValueInformation /*org.opalj.ai.ValuesDomain#DomainValue*/ ] private (
@@ -66,6 +71,8 @@ class PUVar[+Value <: ValueInformation /*org.opalj.ai.ValuesDomain#DomainValue*/
6671

6772
def usePCs: Nothing = throw new UnsupportedOperationException
6873

74+
override def hashCode(): Int = defPCs.hashCode()
75+
6976
override def equals(other: Any): Boolean = {
7077
other match {
7178
case that: PUVar[_] => this.defPCs == that.defPCs

OPAL/tac/src/main/scala/org/opalj/tac/DUVar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class DVar[+Value <: ValueInformation /*org.opalj.ai.ValuesDomain#DomainValue*/
199199

200200
override def toPersistentForm(
201201
implicit stmts: Array[Stmt[V]]
202-
): PDVar[Value] = PDVar(value, usedBy.map(pcOfDefSite _))
202+
): PDVar[Value] = PDVar(pcOfDefSite(origin), value, usedBy.map(pcOfDefSite _))
203203

204204
}
205205

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/string/StringAnalysis.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private[string] class ContextFreeStringAnalysis(override val project: SomeProjec
163163
case PUVar(_, defPCs) =>
164164
defPCs.map(pc => mapDefPCToStringTree(pc))
165165

166-
case PDVar(_, _) =>
166+
case PDVar(_, _, _) =>
167167
Set(mapDefPCToStringTree(state.entity.pc))
168168
}
169169

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/string/trivial/TrivialStringAnalysis.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class TrivialStringAnalysis(override val project: SomeProject) extends FPCFAnaly
9696
case PUVar(_, defPCs) =>
9797
StringTreeOr(defPCs.map(pc => mapDefPCToStringTree(pc)))
9898

99-
case PDVar(_, _) =>
99+
case PDVar(_, _, _) =>
100100
mapDefPCToStringTree(state.entity.pc)
101101
}
102102

0 commit comments

Comments
 (0)