@@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory
1717import viper .silver .ast
1818import viper .silver .frontend .{DefaultStates , SilFrontend }
1919import viper .silver .reporter ._
20- import viper .silver .verifier .{Counterexample => SilCounterexample , DefaultDependency => SilDefaultDependency , Failure => SilFailure , Success => SilSuccess , TimeoutOccurred => SilTimeoutOccurred , VerificationResult => SilVerificationResult , Verifier => SilVerifier }
20+ import viper .silver .verifier .{AbstractVerificationError => SilAbstractVerificationError , DefaultDependency => SilDefaultDependency , Failure => SilFailure , Success => SilSuccess , TimeoutOccurred => SilTimeoutOccurred , VerificationResult => SilVerificationResult , Verifier => SilVerifier }
2121import viper .silicon .common .config .Version
2222import viper .silicon .interfaces .Failure
2323import viper .silicon .logger .SymbExLogger
@@ -256,16 +256,13 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
256256 * of all failures that report the same error (but on different branches, with different CounterExample)
257257 * and put those into one failure */
258258 if (config.enableBranchconditionReporting())
259- allResults.groupBy(_.message.readableMessage(withId = true , withPosition = true ) ).map{case (_ : String , fs: List [Failure ]) =>
259+ allResults.groupBy(failureFilterAndGroupingCriterion ).map{case (_ : String , fs: List [Failure ]) =>
260260 fs.head.message.failureContexts = fs.flatMap(_.message.failureContexts)
261261 Failure (fs.head.message)
262262 }.toList
263- else allResults.distinctBy(f => f.message.readableMessage(withId = true , withPosition = true ))
264- })
265- .sortBy(_.message.pos match { /* Order failures according to source position */
266- case pos : ast.HasLineColumn => (pos.line, pos.column)
267- case _ => (- 1 , - 1 )
263+ else allResults.distinctBy(failureFilterAndGroupingCriterion)
268264 })
265+ .sortBy(failureSortingCriterion)
269266
270267// if (config.showStatistics.isDefined) {
271268// val proverStats = verifier.decider.statistics()
@@ -296,6 +293,28 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
296293 failures
297294 }
298295
296+ private def failureFilterAndGroupingCriterion (f : Failure ): String = {
297+ // apply transformers if available:
298+ val transformedError = f.message match {
299+ case e : SilAbstractVerificationError => e.transformedError()
300+ case e => e
301+ }
302+ // create a string that identifies the given failure:
303+ transformedError.readableMessage(withId = true , withPosition = true )
304+ }
305+
306+ private def failureSortingCriterion (f : Failure ): (Int , Int ) = {
307+ // apply transformers if available:
308+ val transformedError = f.message match {
309+ case e : SilAbstractVerificationError => e.transformedError()
310+ case e => e
311+ }
312+ transformedError.pos match { /* Order failures according to source position */
313+ case pos : ast.HasLineColumn => (pos.line, pos.column)
314+ case _ => (- 1 , - 1 )
315+ }
316+ }
317+
299318 private def logFailure (failure : Failure , log : String => Unit ): Unit = { // TODO:J log context?
300319 log(" \n " + failure.message.readableMessage(withId = true , withPosition = true ))
301320 }
0 commit comments