summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar wuestholz <unknown>2014-07-06 22:29:26 +0200
committerGravatar wuestholz <unknown>2014-07-06 22:29:26 +0200
commit40efa1496ae36400e0f334a215b86371a56a6b9c (patch)
tree49a7949bff9797dbc3955af8fe9b6e744353c2ba
parentbb6e253feab04cc13de3132520eac3ffc8150f01 (diff)
Worked on adding support for "canned errors".
-rw-r--r--Source/Core/Absy.cs11
-rw-r--r--Source/Core/AbsyCmd.cs2
-rw-r--r--Source/VCGeneration/ConditionGeneration.cs28
-rw-r--r--Source/VCGeneration/VC.cs2
-rw-r--r--Test/snapshots/Snapshots20.v0.bpl20
-rw-r--r--Test/snapshots/Snapshots20.v1.bpl20
-rw-r--r--Test/snapshots/runtest.snapshot2
-rw-r--r--Test/snapshots/runtest.snapshot.expect16
8 files changed, 92 insertions, 9 deletions
diff --git a/Source/Core/Absy.cs b/Source/Core/Absy.cs
index 2f4b4e8a..e67be411 100644
--- a/Source/Core/Absy.cs
+++ b/Source/Core/Absy.cs
@@ -2682,6 +2682,17 @@ namespace Microsoft.Boogie {
public ISet<byte[]> AssertionChecksumsInPreviousSnapshot { get; set; }
+ public IList<AssertCmd> CannedFailingAssertions { get; protected set; }
+
+ public void AddCannedFailingAssertion(AssertCmd assertion)
+ {
+ if (CannedFailingAssertions == null)
+ {
+ CannedFailingAssertions = new List<AssertCmd>();
+ }
+ CannedFailingAssertions.Add(assertion);
+ }
+
// Strongly connected components
private StronglyConnectedComponents<Block/*!*/> scc;
[ContractInvariantMethod]
diff --git a/Source/Core/AbsyCmd.cs b/Source/Core/AbsyCmd.cs
index 869c0dfa..466b2f0e 100644
--- a/Source/Core/AbsyCmd.cs
+++ b/Source/Core/AbsyCmd.cs
@@ -2550,7 +2550,7 @@ namespace Microsoft.Boogie {
private static Expr Conjunction(IEnumerable<Expr> conjuncts)
{
- // TODO(wuestholz): Should we use 'LiteralExpr.BinaryTreeAnd' instead?
+ // TODO(wuestholz): Maybe we should use 'LiteralExpr.BinaryTreeAnd' instead.
Expr result = null;
foreach (var c in conjuncts)
{
diff --git a/Source/VCGeneration/ConditionGeneration.cs b/Source/VCGeneration/ConditionGeneration.cs
index 9d8669dd..787477ad 100644
--- a/Source/VCGeneration/ConditionGeneration.cs
+++ b/Source/VCGeneration/ConditionGeneration.cs
@@ -1499,9 +1499,10 @@ namespace VC {
Contract.Assert(copy != null);
var isAssumePre = false;
if (pc is AssertCmd) {
- ((AssertCmd)pc).OrigExpr = pc.Expr;
- Contract.Assert(((AssertCmd)pc).IncarnationMap == null);
- ((AssertCmd)pc).IncarnationMap = (Dictionary<Variable, Expr>)cce.NonNull(new Dictionary<Variable, Expr>(incarnationMap));
+ var ac = (AssertCmd)pc;
+ ac.OrigExpr = ac.Expr;
+ Contract.Assert(ac.IncarnationMap == null);
+ ac.IncarnationMap = (Dictionary<Variable, Expr>)cce.NonNull(new Dictionary<Variable, Expr>(incarnationMap));
if (currentImplementation != null
&& ((currentImplementation.NoErrorsInCachedSnapshot
@@ -1510,20 +1511,33 @@ namespace VC {
|| (currentImplementation.AnyErrorsInCachedSnapshot
&& currentImplementation.InjectedAssumptionVariables != null
&& currentImplementation.InjectedAssumptionVariables.Any()
- && pc.Checksum != null
- && (currentImplementation.AssertionChecksumsInPreviousSnapshot != null && currentImplementation.AssertionChecksumsInPreviousSnapshot.Contains(pc.Checksum))
- && !currentImplementation.ErrorChecksumsInCachedSnapshot.Contains(pc.Checksum))))
+ && ac.Checksum != null
+ && (currentImplementation.AssertionChecksumsInPreviousSnapshot != null && currentImplementation.AssertionChecksumsInPreviousSnapshot.Contains(ac.Checksum))
+ && !currentImplementation.ErrorChecksumsInCachedSnapshot.Contains(ac.Checksum))))
{
// Bind the assertion expression to a local variable.
var incarnation = CreateIncarnation(CurrentTemporaryVariableForAssertions, new IdentifierExpr(Token.NoToken, CurrentTemporaryVariableForAssertions));
var identExpr = new IdentifierExpr(Token.NoToken, incarnation);
incarnationMap[incarnation] = identExpr;
- ((AssertCmd)pc).IncarnationMap[incarnation] = identExpr;
+ ac.IncarnationMap[incarnation] = identExpr;
passiveCmds.Add(new AssumeCmd(Token.NoToken, LiteralExpr.Eq(identExpr, copy)));
copy = identExpr;
var expr = LiteralExpr.Imp(currentImplementation.ConjunctionOfInjectedAssumptionVariables(incarnationMap), copy);
passiveCmds.Add(new AssumeCmd(Token.NoToken, expr));
}
+ else if (currentImplementation != null
+ && currentImplementation.AnyErrorsInCachedSnapshot
+ && currentImplementation.InjectedAssumptionVariables != null
+ && currentImplementation.InjectedAssumptionVariables.Any()
+ && ac.Checksum != null
+ && (currentImplementation.AssertionChecksumsInPreviousSnapshot != null && currentImplementation.AssertionChecksumsInPreviousSnapshot.Contains(ac.Checksum))
+ && currentImplementation.ErrorChecksumsInCachedSnapshot.Contains(ac.Checksum)
+ && !currentImplementation.InjectedAssumptionVariables.Any(v => incarnationMap.ContainsKey(v)))
+ {
+ ac.Attributes = new QKeyValue(Token.NoToken, "canned_failing_assertion", new List<object>(), ac.Attributes);
+ currentImplementation.AddCannedFailingAssertion(ac);
+ // TODO(wuestholz): Turn the 'assert' command into an 'assume' command.
+ }
}
else if (pc is AssumeCmd
&& QKeyValue.FindBoolAttribute(pc.Attributes, "precondition_previous_snapshot")
diff --git a/Source/VCGeneration/VC.cs b/Source/VCGeneration/VC.cs
index be3ab95d..505f18b7 100644
--- a/Source/VCGeneration/VC.cs
+++ b/Source/VCGeneration/VC.cs
@@ -1481,6 +1481,8 @@ namespace VC {
ModelViewInfo mvInfo;
var gotoCmdOrigins = PassifyImpl(impl, out mvInfo);
+ // TODO(wuestholz): Report all canned failing assertions for this implementation.
+
// If "expand" attribute is supplied, expand any assertion of conjunctions into multiple assertions, one per conjunct
foreach (var b in impl.Blocks)
{
diff --git a/Test/snapshots/Snapshots20.v0.bpl b/Test/snapshots/Snapshots20.v0.bpl
new file mode 100644
index 00000000..54934a05
--- /dev/null
+++ b/Test/snapshots/Snapshots20.v0.bpl
@@ -0,0 +1,20 @@
+procedure {:checksum "0"} M();
+
+implementation {:id "M"} {:checksum "1"} M()
+{
+ if (*)
+ {
+ call N();
+
+ assert 1 != 1;
+ }
+ else
+ {
+ assert 2 != 2; // error
+ }
+
+ assert 3 != 3;
+}
+
+procedure {:checksum "2"} N();
+ ensures 0 != 0;
diff --git a/Test/snapshots/Snapshots20.v1.bpl b/Test/snapshots/Snapshots20.v1.bpl
new file mode 100644
index 00000000..04fd0a6e
--- /dev/null
+++ b/Test/snapshots/Snapshots20.v1.bpl
@@ -0,0 +1,20 @@
+procedure {:checksum "0"} M();
+
+implementation {:id "M"} {:checksum "1"} M()
+{
+ if (*)
+ {
+ call N();
+
+ assert 1 != 1; // error
+ }
+ else
+ {
+ assert 2 != 2; // error
+ }
+
+ assert 3 != 3;
+}
+
+procedure {:checksum "3"} N();
+ ensures 0 == 0;
diff --git a/Test/snapshots/runtest.snapshot b/Test/snapshots/runtest.snapshot
index b36e1aa2..57ca7f5a 100644
--- a/Test/snapshots/runtest.snapshot
+++ b/Test/snapshots/runtest.snapshot
@@ -1,2 +1,2 @@
-// RUN: %boogie -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 > "%t"
+// RUN: %boogie -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 > "%t"
// RUN: %diff "%s.expect" "%t"
diff --git a/Test/snapshots/runtest.snapshot.expect b/Test/snapshots/runtest.snapshot.expect
index 554837e6..7b9241d8 100644
--- a/Test/snapshots/runtest.snapshot.expect
+++ b/Test/snapshots/runtest.snapshot.expect
@@ -190,3 +190,19 @@ Execution trace:
Snapshots19.v1.bpl(5,5): anon0
Boogie program verifier finished with 0 verified, 1 error
+Snapshots20.v0.bpl(13,9): Error BP5001: This assertion might not hold.
+Execution trace:
+ Snapshots20.v0.bpl(5,5): anon0
+ Snapshots20.v0.bpl(13,9): anon4_Else
+
+Boogie program verifier finished with 0 verified, 1 error
+Snapshots20.v1.bpl(9,9): Error BP5001: This assertion might not hold.
+Execution trace:
+ Snapshots20.v1.bpl(5,5): anon0
+ Snapshots20.v1.bpl(7,9): anon4_Then
+Snapshots20.v1.bpl(13,9): Error BP5001: This assertion might not hold.
+Execution trace:
+ Snapshots20.v1.bpl(5,5): anon0
+ Snapshots20.v1.bpl(13,9): anon4_Else
+
+Boogie program verifier finished with 0 verified, 2 errors