Skip to content

Commit

Permalink
fix: Skip empty splits (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomadge authored Oct 14, 2024
1 parent 398413d commit ff43b61
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ procedure Procedure(y: int)

// The implicit return at the end gets a separate VC.
// first split is empty. Maybe it can be optimized away
Assert.AreEqual(5, tasks.Count);
Assert.AreEqual(4, tasks.Count);

var outcomes = new List<SolverOutcome> { SolverOutcome.Invalid, SolverOutcome.Valid, SolverOutcome.Invalid, SolverOutcome.Valid };
for (var index = 0; index < outcomes.Count; index++)
Expand Down
3 changes: 2 additions & 1 deletion Source/VCGeneration/Splits/ManualSplitFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public static IEnumerable<ManualSplit> GetParts(VCGenOptions options, Implementa
IsolateAttributeOnAssertsHandler.GetParts(options, withoutIsolatedJumps, createPart);
var splitParts = SplitAttributeHandler.GetParts(withoutIsolatedAssertions);
return isolatedJumps.Concat(isolatedAssertions).Concat(splitParts);
var splits = isolatedJumps.Concat(isolatedAssertions).Concat(splitParts).Where(s => s.Asserts.Any()).ToList();
return splits.Any() ? splits : new List<ManualSplit> { focussedPart };
});
return result;
}
Expand Down
22 changes: 11 additions & 11 deletions Test/commandline/SplitOnEveryAssert.bpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// RUN: %OutputCheck --file-to-check "%t" "%s"

// CHECK: Verifying Ex ...
// CHECK: checking split 1/12 .*
// CHECK: checking split 2/12 .*
// CHECK: checking split 3/12 .*
// CHECK: checking split 4/12 .*
// CHECK: checking split 1/11 .*
// CHECK: checking split 2/11 .*
// CHECK: checking split 3/11 .*
// CHECK: checking split 4/11 .*
// CHECK: --> split #4 done, \[.* s\] Invalid
// CHECK: checking split 5/12 .*
// CHECK: checking split 6/12 .*
// CHECK: checking split 7/12 .*
// CHECK: checking split 8/12 .*
// CHECK: checking split 9/12 .*
// CHECK: checking split 10/12 .*
// CHECK: checking split 11/12 .*
// CHECK: checking split 5/11 .*
// CHECK: checking split 6/11 .*
// CHECK: checking split 7/11 .*
// CHECK: checking split 8/11 .*
// CHECK: checking split 9/11 .*
// CHECK: checking split 10/11 .*
// CHECK: checking split 11/11 .*
// CHECK-L: SplitOnEveryAssert.bpl(31,5): Error: this assertion could not be proved

procedure Ex() returns (y: int)
Expand Down
22 changes: 11 additions & 11 deletions Test/test0/SplitOnEveryAssert.bpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// RUN: %OutputCheck --file-to-check "%t" "%s"

// CHECK: Verifying DoTheSplitting ...
// CHECK: checking split 1/12.*
// CHECK: checking split 2/12.*
// CHECK: checking split 3/12.*
// CHECK: checking split 4/12.*
// CHECK: checking split 1/11.*
// CHECK: checking split 2/11.*
// CHECK: checking split 3/11.*
// CHECK: checking split 4/11.*
// CHECK: --> split #4 done, \[.* s\] Invalid
// CHECK: checking split 5/12.*
// CHECK: checking split 6/12.*
// CHECK: checking split 7/12.*
// CHECK: checking split 8/12.*
// CHECK: checking split 9/12.*
// CHECK: checking split 10/12.*
// CHECK: checking split 11/12.*
// CHECK: checking split 5/11.*
// CHECK: checking split 6/11.*
// CHECK: checking split 7/11.*
// CHECK: checking split 8/11.*
// CHECK: checking split 9/11.*
// CHECK: checking split 10/11.*
// CHECK: checking split 11/11.*
// CHECK-L: SplitOnEveryAssert.bpl(36,5): Error: this assertion could not be proved

// Verify the second procedure is NOT split. .* is necessary to match the blank line in-between.
Expand Down

0 comments on commit ff43b61

Please sign in to comment.