Skip to content

Commit efb5e4e

Browse files
committed
Use separate Info specifically for smoke detection
1 parent ef73f42 commit efb5e4e

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

src/main/scala/viper/silver/plugin/standard/refute/RefuteErrors.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
package viper.silver.plugin.standard.refute
88

99
import viper.silver.ast.FalseLit
10-
import viper.silver.cfg.utility.IdInfo
10+
import viper.silver.plugin.standard.smoke.SmokeDetectionInfo
1111
import viper.silver.verifier._
1212

1313
sealed abstract class RefuteError extends ExtensionAbstractVerificationError
1414
sealed abstract class RefuteErrorReason extends ExtensionAbstractErrorReason
1515

1616
case class RefuteFailed(override val offendingNode: Refute, override val reason: ErrorReason, override val cached: Boolean = false) extends RefuteError {
1717
override val id = "refute.failed"
18-
override val text = if (offendingNode.exp.isInstanceOf[FalseLit] && offendingNode.info.getUniqueInfo[IdInfo].isDefined)
19-
"Smoke detected: False could be proven here (which should never hold)." else
18+
override val text: String = if (offendingNode.exp.isInstanceOf[FalseLit] && offendingNode.info.getUniqueInfo[SmokeDetectionInfo].isDefined)
19+
"Smoke detection: False could be proven here (which should never hold)." else
2020
"Refute holds in all cases or could not be reached (e.g. see Silicon `numberOfErrorsToReport`)."
2121

2222
override def withNode(offendingNode: errors.ErrorNode = this.offendingNode): RefuteFailed =

src/main/scala/viper/silver/plugin/standard/smoke/SmokeDetectionPlugin.scala

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import viper.silver.ast._
55
import viper.silver.ast.utility.ViperStrategy
66
import viper.silver.cfg.silver.SilverCfg
77
import viper.silver.cfg.silver.SilverCfg.SilverBlock
8-
import viper.silver.cfg.utility.IdInfo
98
import viper.silver.parser.FastParser
109
import viper.silver.plugin.standard.refute.Refute
1110
import viper.silver.plugin.{ParserPluginTemplate, SilverPlugin}
@@ -85,7 +84,7 @@ class SmokeDetectionPlugin(@unused reporter: viper.silver.reporter.Reporter,
8584

8685
ViperStrategy.Slim({
8786
case r@Refute(_) =>
88-
val idInfo = r.info.getUniqueInfo[IdInfo]
87+
val idInfo = r.info.getUniqueInfo[SmokeDetectionInfo]
8988

9089
if (idInfo.isDefined &&
9190
!result._1.contains(idInfo.get.id) && // not marked reachable
@@ -124,7 +123,7 @@ class SmokeDetectionPlugin(@unused reporter: viper.silver.reporter.Reporter,
124123
* @return a [[Refute]] instance with with the `exp` set to `false` and the given position and ID
125124
*/
126125
private def refuteFalse(pos: Position, id: Int): Refute = {
127-
Refute(FalseLit()(pos))(pos, IdInfo(id))
126+
Refute(FalseLit()(pos))(pos, SmokeDetectionInfo(id))
128127
}
129128

130129
/**
@@ -176,7 +175,7 @@ class SmokeDetectionPlugin(@unused reporter: viper.silver.reporter.Reporter,
176175
unreachableSuccessors = true
177176
case refute: Refute if refute.exp.isInstanceOf[FalseLit] =>
178177
// Encountered `refute false` statement -> add ID to list if it is reachable
179-
val idInfo = refute.info.getUniqueInfo[IdInfo]
178+
val idInfo = refute.info.getUniqueInfo[SmokeDetectionInfo]
180179

181180
if (idInfo.isDefined) {
182181
val id = idInfo.get.id
@@ -222,3 +221,15 @@ class SmokeDetectionPlugin(@unused reporter: viper.silver.reporter.Reporter,
222221
successors.forall(s => collectRefutesToKeepUntilExit(cfg, s, exits, seen, refutesToKeep, seenRefutes, unreachableSuccessors))
223222
}
224223
}
224+
225+
/**
226+
* An info used to mark AST nodes (more specifically, `refute false` statements) as used in smoke detection,
227+
* also assigning a unique identifier to it.
228+
*
229+
* @param id the ID of the node
230+
*/
231+
case class SmokeDetectionInfo(id: Int) extends Info {
232+
override def comment: Seq[String] = Seq(s"`refute false` #$id")
233+
234+
override def isCached: Boolean = false
235+
}

0 commit comments

Comments
 (0)