public override CBAProgram runCBAPass(CBAProgram p) { if (!aggressive) { return(null); } var procsWithAsserts = procsWithAssertions(p); HashSet <string> procsToDelete = new HashSet <string>(); // Gather the set of procedures to delete foreach (Declaration d in p.TopLevelDeclarations) { if (d is Procedure) { var proc = d as Procedure; if (proc.Name.Equals(p.mainProcName)) { continue; } if (procsWithAsserts.Contains(proc.Name)) { continue; } if (proc.OutParams.Count > 0) { continue; } var modifiesShared = false; foreach (IdentifierExpr ie in proc.Modifies) { if (LanguageSemantics.isShared(ie.Decl.Name)) { modifiesShared = true; break; } } if (!modifiesShared) { procsToDelete.Add(proc.Name); } } } // Delete the implementations CBAProgram ret = new CBAProgram(new Program(), p.mainProcName, p.contextBound); foreach (Declaration d in p.TopLevelDeclarations) { if (d is Implementation) { Implementation impl = d as Implementation; if (procsToDelete.Contains(impl.Name) && !BoogieUtil.hasAssert(impl)) { Log.WriteLine(Log.Debug, "Deleting " + impl.Name); continue; } ret.AddTopLevelDeclaration(d); } else { ret.AddTopLevelDeclaration(d); } } Log.WriteLine(Log.Debug, "Empty Mod Sets: Deleted " + (p.TopLevelDeclarations.Count() - ret.TopLevelDeclarations.Count()).ToString() + " implementations"); return(ret); }