Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ class UInputToAllocatedSymbolicRefSetUnionAdapter<SetType>(

override fun collectSetElements(elements: USymbolicSetElementsCollector.Elements<UHeapRef>) {
val setElements = USymbolicSetElementsCollector.collect(setOfKeys.updates)
if (setElements.isInput) {
elements.isInput = true
}
// The initial input collection can contain elements absent from its update tree.
elements.isInput = true
setElements.elements.mapTo(elements.elements) { it.second }
}

Expand Down Expand Up @@ -211,9 +210,8 @@ class UInputToInputSymbolicRefSetUnionAdapter<SetType>(

override fun collectSetElements(elements: USymbolicSetElementsCollector.Elements<USymbolicSetElement<UAddressSort>>) {
val setElements = USymbolicSetElementsCollector.collect(setOfKeys.updates)
if (setElements.isInput) {
elements.isInput = true
}
// The initial input collection can contain elements absent from its update tree.
elements.isInput = true
setElements.elements.mapTo(elements.elements) { dstSetRef to it.second }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,35 @@ class ObjectMapTest : SymbolicCollectionTestBase() {
testMapMerge(symbolicMap0, symbolicMap1)
}

@Test
fun testCopiedInputMapCanSelectAnInitialKey() = testInputCopyRetainsUnknownKey(throughSecondCopy = false)

@Test
fun testRepeatedInputMapCopyCanSelectAnInitialKey() = testInputCopyRetainsUnknownKey(throughSecondCopy = true)

private fun testInputCopyRetainsUnknownKey(throughSecondCopy: Boolean) = scope.doWithState {
val source = ctx.mkRegisterReading(idx = 99, sort = ctx.addressSort)
val firstCopy = mkSymbolicObjectMap(mapType)

symbolicObjectMapMergeInto(firstCopy, source, mapType, ctx.sizeSort)
val copy = if (throughSecondCopy) {
val secondCopy = mkSymbolicObjectMap(mapType)
symbolicObjectMapMergeInto(secondCopy, firstCopy, mapType, ctx.sizeSort)
secondCopy
} else {
firstCopy
}

val selectedKey = symbolicObjectMapAnyKey(copy, mapType)
val sourceContains = symbolicObjectMapContains(source, selectedKey, mapType)
val copyContains = symbolicObjectMapContains(copy, selectedKey, mapType)

checkWithSolver {
assertPossible { mkAnd(mkNot(mkHeapRefEq(source, nullRef)), sourceContains, copyContains) }
assertImpossible { mkAnd(copyContains, mkNot(sourceContains)) }
}
}

@Test
fun testMapRetrieveAnyKey() = scope.doWithState {
callStack.push(method = Any(), returnSite = null)
Expand Down
Loading