Skip to content

Commit

Permalink
Cumulative updates
Browse files Browse the repository at this point in the history
  • Loading branch information
amoeller committed Nov 1, 2021
1 parent cfdd9dd commit 823a25d
Show file tree
Hide file tree
Showing 14 changed files with 323 additions and 225 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature")
libraryDependencies += "org.parboiled" %% "parboiled" % "2.1.8"
libraryDependencies += "com.regblanc" % "scala-smtlib_2.12" % "0.2.1"

scalaSource in Compile := baseDirectory.value / "src"
Compile / scalaSource := baseDirectory.value / "src"
14 changes: 9 additions & 5 deletions src/tip/Tip.scala
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,15 @@ object Tip extends App {
log.error(s"Failure parsing the program: $file", e)
sys.exit(1)
case Success(parsedNode: AProgram) =>
// run normalizer
log.verb("Normalizing")
val programNode = options.normalizer.normalizeProgram(parsedNode)
if (options.normalizer != NoNormalizer)
Output.output(file, OtherOutput(OutputKindE.normalized), programNode.toString, options.out)
val programNode =
if (options.normalizer == NoNormalizer) parsedNode
else {
// run normalizer
log.verb("Normalizing")
val p = options.normalizer.normalizeProgram(parsedNode)
Output.output(file, OtherOutput(OutputKindE.normalized), p.toString, options.out)
p
}

// run declaration analysis
// (for information about the use of 'implicit', see [[tip.analysis.TypeAnalysis]])
Expand Down
2 changes: 1 addition & 1 deletion src/tip/analysis/AndersenAnalysis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AndersenAnalysis(program: AProgram)(implicit declData: DeclarationData) ex
override def toString = id.toString
}

val solver = new CubicSolver[Cell, Cell]
val solver = new SimpleCubicSolver[Cell, Cell]

import AstOps._
val cells: Set[Cell] = (program.appearingIds.map(Var): Set[Cell]) union program.appearingAllocs.map(Alloc)
Expand Down
4 changes: 2 additions & 2 deletions src/tip/analysis/ControlFlowAnalysis.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tip.analysis

import tip.ast.{AAssignStmt, AIdentifier, AProgram, AstNode, DepthFirstAstVisitor, _}
import tip.solvers.CubicSolver
import tip.solvers.SimpleCubicSolver
import tip.util.Log
import tip.ast.AstNodeData.{AstNodeWithDeclaration, DeclarationData}

Expand All @@ -24,7 +24,7 @@ class ControlFlowAnalysis(program: AProgram)(implicit declData: DeclarationData)
}
}

private val solver = new CubicSolver[AstVariable, Decl]
private val solver = new SimpleCubicSolver[AstVariable, Decl]

val allFunctions: Set[AFunDeclaration] = program.funs.toSet

Expand Down
2 changes: 1 addition & 1 deletion src/tip/analysis/CopyConstantPropagationAnalysis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trait CopyConstantPropagationAnalysisFunctions extends IDEAnalysis[ADeclaration,
case AAssignStmt(id: AIdentifier, right, _) =>
val edges = assign(d, id.declaration, right)
d match {
case Left(a) if id != a =>
case Left(a) if id.declaration != a =>
edges :+ ((d, IdEdge())) // not at the variable being written to, so add identity edge
case _ =>
edges
Expand Down
2 changes: 1 addition & 1 deletion src/tip/analysis/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ trait ContextSensitiveForwardDependencies[C <: CallContext] extends Dependencies
*/
override def outdep(n: (C, CfgNode)): Set[(C, CfgNode)] =
(n._2 match {
case call: CfgCallNode => Set()
case _: CfgCallNode => Set()
case _ => n._2.succ.toSet
}).map { d =>
(n._1, d)
Expand Down
2 changes: 1 addition & 1 deletion src/tip/analysis/SteensgaardAnalysis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ sealed trait StTerm
*/
case class AllocVariable(alloc: AAlloc) extends StTerm with Var[StTerm] {

override def toString: String = s"\u27E6alloc{${alloc.loc}}]]"
override def toString: String = s"\u27E6alloc{${alloc.loc}}\u27E7"
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/tip/analysis/TypeAnalysis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tip.analysis

import tip.ast._
import tip.solvers._
import tip.types.{AbsentFieldType, _}
import tip.types._
import tip.ast.AstNodeData._
import tip.util.{Log, TipProgramException}
import AstOps._
Expand Down
11 changes: 10 additions & 1 deletion src/tip/ast/AstOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ object AstOps {
* Checks whether the subtree of the node contains an 'input' expression.
*/
def containsInput: Boolean = {
var res = false;
var res = false
new DepthFirstAstVisitor[Unit] {
override def visit(node: AstNode, arg: Unit): Unit =
node match {
Expand All @@ -156,6 +156,15 @@ object AstOps {
case rec: ARecord =>
fields ++= rec.fields.map { _.field }
visitChildren(rec, ())
case as: AAssignStmt =>
as.left match {
case dfw: ADirectFieldWrite =>
fields += dfw.field
case ifw: AIndirectFieldWrite =>
fields += ifw.field
case _ =>
}
visitChildren(as, ())
case _ => visitChildren(node, ())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tip/ast/TipSublanguages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class NoFunctionPointers(implicit declData: DeclarationData) extends TipSublangu
LanguageRestrictionViolation(s"Indirect call not allowed, $targetFun is not a function", ast.loc)
}
args.foreach(visit(_, x))
case ACallFuncExpr(targetFun, args, _) =>
case ACallFuncExpr(targetFun, _, _) =>
LanguageRestrictionViolation(s"Indirect call not allowed, $targetFun is not a function", ast.loc)
case id: AIdentifier =>
id.declaration match {
Expand Down
206 changes: 0 additions & 206 deletions src/tip/solvers/CubicSolver.scala

This file was deleted.

7 changes: 3 additions & 4 deletions src/tip/solvers/IDESolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,13 @@ abstract class IDEPhase1Analysis[D, L <: Lattice](val cfg: InterproceduralProgra
*/
def summaries(): mutable.Map[AFunDeclaration, mutable.Map[DL, mutable.Map[DL, Edge]]] = {
import edgelattice.Edge
import mutable.Map
val res = Map[AFunDeclaration, Map[DL, Map[DL, Edge]]]()
val res = mutable.Map[AFunDeclaration, mutable.Map[DL, mutable.Map[DL, Edge]]]()
x.foreach {
case ((n, d1, d2), e) =>
n match {
case funexit: CfgFunExitNode =>
val m1 = res.getOrElseUpdate(funexit.data, Map[DL, Map[DL, Edge]]().withDefaultValue(Map[DL, Edge]()))
val m2 = m1.getOrElseUpdate(d1, Map[DL, Edge]())
val m1 = res.getOrElseUpdate(funexit.data, mutable.Map[DL, mutable.Map[DL, Edge]]().withDefaultValue(mutable.Map[DL, Edge]()))
val m2 = m1.getOrElseUpdate(d1, mutable.Map[DL, Edge]())
m2 += d2 -> e
case _ => // ignore other node kinds
}
Expand Down
Loading

0 comments on commit 823a25d

Please sign in to comment.