summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar wuestholz <unknown>2014-10-13 23:26:57 +0200
committerGravatar wuestholz <unknown>2014-10-13 23:26:57 +0200
commit1db1508be2b8206fd1a9051f887f2fb20970c4c0 (patch)
tree2fda3b8a2e1c34d0896a0be895c80482f10e2419
parent446723cdee734937e3467d9d27ae90bfe088a19b (diff)
Fix issue in verification result caching for assertions without subsumption.
-rw-r--r--Source/VCGeneration/ConditionGeneration.cs32
-rw-r--r--Test/snapshots/Snapshots24.v0.bpl25
-rw-r--r--Test/snapshots/Snapshots24.v1.bpl25
-rw-r--r--Test/snapshots/runtest.snapshot2
-rw-r--r--Test/snapshots/runtest.snapshot.expect8
5 files changed, 81 insertions, 11 deletions
diff --git a/Source/VCGeneration/ConditionGeneration.cs b/Source/VCGeneration/ConditionGeneration.cs
index 689a8a73..628ceb0f 100644
--- a/Source/VCGeneration/ConditionGeneration.cs
+++ b/Source/VCGeneration/ConditionGeneration.cs
@@ -1482,7 +1482,10 @@ namespace VC {
Contract.Assert(ac.IncarnationMap == null);
ac.IncarnationMap = (Dictionary<Variable, Expr>)cce.NonNull(new Dictionary<Variable, Expr>(incarnationMap));
- if (currentImplementation != null
+ var subsumption = Wlp.Subsumption(ac);
+ var alwaysUseSubsumption = subsumption == CommandLineOptions.SubsumptionOption.Always;
+ if (alwaysUseSubsumption
+ && currentImplementation != null
&& ((currentImplementation.NoErrorsInCachedSnapshot
&& currentImplementation.InjectedAssumptionVariables != null
&& 2 <= currentImplementation.InjectedAssumptionVariables.Count)
@@ -1510,11 +1513,13 @@ namespace VC {
&& !currentImplementation.ErrorChecksumToCachedError.ContainsKey(ac.Checksum)
&& (currentImplementation.InjectedAssumptionVariables == null || !currentImplementation.InjectedAssumptionVariables.Any(v => incarnationMap.ContainsKey(v))))
{
- // Turn it into an assume statement.
- pc = new AssumeCmd(ac.tok, copy);
- pc.Attributes = new QKeyValue(Token.NoToken, "verified_assertion", new List<object>(), pc.Attributes);
- // TODO(wuestholz): Should we uncomment this?
- // dropCmd = QKeyValue.FindIntAttribute(ac.Attributes, "subsumption", -1) == 0;
+ if (alwaysUseSubsumption)
+ {
+ // Turn it into an assume statement.
+ pc = new AssumeCmd(ac.tok, copy);
+ pc.Attributes = new QKeyValue(Token.NoToken, "verified_assertion", new List<object>(), pc.Attributes);
+ }
+ dropCmd = subsumption == CommandLineOptions.SubsumptionOption.Never;
}
else if (currentImplementation != null
&& currentImplementation.AnyErrorsInCachedSnapshot
@@ -1523,10 +1528,17 @@ namespace VC {
&& currentImplementation.ErrorChecksumToCachedError.ContainsKey(ac.Checksum)
&& (currentImplementation.InjectedAssumptionVariables == null || !currentImplementation.InjectedAssumptionVariables.Any(v => incarnationMap.ContainsKey(v))))
{
- // Turn it into an assume statement.
- pc = new AssumeCmd(ac.tok, copy);
- pc.Attributes = new QKeyValue(Token.NoToken, "recycled_failing_assertion", new List<object>(), pc.Attributes);
- currentImplementation.AddRecycledFailingAssertion(ac);
+ if (alwaysUseSubsumption)
+ {
+ // Turn it into an assume statement.
+ pc = new AssumeCmd(ac.tok, copy);
+ pc.Attributes = new QKeyValue(Token.NoToken, "recycled_failing_assertion", new List<object>(), pc.Attributes);
+ }
+ dropCmd = subsumption == CommandLineOptions.SubsumptionOption.Never;
+ if (dropCmd || alwaysUseSubsumption)
+ {
+ currentImplementation.AddRecycledFailingAssertion(ac);
+ }
}
}
else if (pc is AssumeCmd
diff --git a/Test/snapshots/Snapshots24.v0.bpl b/Test/snapshots/Snapshots24.v0.bpl
new file mode 100644
index 00000000..1289399b
--- /dev/null
+++ b/Test/snapshots/Snapshots24.v0.bpl
@@ -0,0 +1,25 @@
+procedure {:checksum "0"} M();
+
+implementation {:id "M"} {:checksum "1"} M()
+{
+ if (*)
+ {
+ assert {:subsumption 0} 1 != 1; // error
+ }
+ else if (*)
+ {
+ assert {:subsumption 1} 5 != 5; // error
+ }
+ else if (*)
+ {
+ assert {:subsumption 2} 6 != 6; // error
+ }
+ else
+ {
+ assert {:subsumption 1} 2 == 2;
+ assert {:subsumption 2} 4 == 4;
+ assert 5 == 5;
+ }
+
+ assert {:subsumption 0} 3 == 3;
+}
diff --git a/Test/snapshots/Snapshots24.v1.bpl b/Test/snapshots/Snapshots24.v1.bpl
new file mode 100644
index 00000000..00d65961
--- /dev/null
+++ b/Test/snapshots/Snapshots24.v1.bpl
@@ -0,0 +1,25 @@
+procedure {:checksum "0"} M();
+
+implementation {:id "M"} {:checksum "2"} M()
+{
+ if (*)
+ {
+ assert {:subsumption 0} 1 == 1;
+ }
+ else if (*)
+ {
+ assert {:subsumption 1} 5 == 5;
+ }
+ else if (*)
+ {
+ assert {:subsumption 2} 6 != 6; // error
+ }
+ else
+ {
+ assert {:subsumption 1} 2 == 2;
+ assert {:subsumption 2} 4 == 4;
+ assert 5 == 5;
+ }
+
+ assert {:subsumption 0} 3 == 3;
+}
diff --git a/Test/snapshots/runtest.snapshot b/Test/snapshots/runtest.snapshot
index 32c88216..04943c25 100644
--- a/Test/snapshots/runtest.snapshot
+++ b/Test/snapshots/runtest.snapshot
@@ -1,2 +1,2 @@
-// RUN: %boogie -errorTrace:0 -verifySnapshots:2 -verifySeparately Snapshots0.bpl Snapshots1.bpl Snapshots2.bpl Snapshots3.bpl Snapshots4.bpl Snapshots5.bpl Snapshots6.bpl Snapshots7.bpl Snapshots8.bpl Snapshots9.bpl Snapshots10.bpl Snapshots11.bpl Snapshots12.bpl Snapshots13.bpl Snapshots14.bpl Snapshots15.bpl Snapshots16.bpl Snapshots17.bpl Snapshots18.bpl Snapshots19.bpl Snapshots20.bpl Snapshots21.bpl Snapshots22.bpl Snapshots23.bpl > "%t"
+// RUN: %boogie -errorTrace:0 -verifySnapshots:2 -verifySeparately Snapshots0.bpl Snapshots1.bpl Snapshots2.bpl Snapshots3.bpl Snapshots4.bpl Snapshots5.bpl Snapshots6.bpl Snapshots7.bpl Snapshots8.bpl Snapshots9.bpl Snapshots10.bpl Snapshots11.bpl Snapshots12.bpl Snapshots13.bpl Snapshots14.bpl Snapshots15.bpl Snapshots16.bpl Snapshots17.bpl Snapshots18.bpl Snapshots19.bpl Snapshots20.bpl Snapshots21.bpl Snapshots22.bpl Snapshots23.bpl Snapshots24.bpl > "%t"
// RUN: %diff "%s.expect" "%t"
diff --git a/Test/snapshots/runtest.snapshot.expect b/Test/snapshots/runtest.snapshot.expect
index fd054579..899cd914 100644
--- a/Test/snapshots/runtest.snapshot.expect
+++ b/Test/snapshots/runtest.snapshot.expect
@@ -152,3 +152,11 @@ Boogie program verifier finished with 1 verified, 1 error
Snapshots23.v0.bpl(7,9): Error BP5001: This assertion might not hold.
Boogie program verifier finished with 1 verified, 1 error
+Snapshots24.v0.bpl(7,9): Error BP5001: This assertion might not hold.
+Snapshots24.v0.bpl(11,9): Error BP5001: This assertion might not hold.
+Snapshots24.v0.bpl(15,9): Error BP5001: This assertion might not hold.
+
+Boogie program verifier finished with 0 verified, 3 errors
+Snapshots24.v0.bpl(15,9): Error BP5001: This assertion might not hold.
+
+Boogie program verifier finished with 0 verified, 1 error