Example #1
0
        List <Cmd> ProcessAssign(AssignCmd cmd, Dictionary <string, string> varDecls)
        {
            var ret = new List <Cmd>();

            var reads = new GatherMemAccesses();

            cmd.Lhss.Iter(e => reads.VisitExpr(e.AsExpr));
            cmd.Rhss.Iter(e => reads.VisitExpr(e));
            foreach (var tup in reads.accesses)
            {
                var    ptr = tup.Item2;
                string basePtr;
                if (varDecls.TryGetValue(ptr.ToString(), out basePtr))
                {
                    ret.Add(MkAssert(Expr.Ident(BoogieAstFactory.MkFormal(basePtr, btype.Int, true))));
                }
                else
                {
                    ret.Add(MkAssert(ptr));
                }
            }
            ret.Add(cmd);

            return(ret);
        }
Example #2
0
        List <Cmd> ProcessAssume(AssumeCmd cmd)
        {
            var ret = new List <Cmd>();

            var gm = new GatherMemAccesses();

            gm.VisitExpr(cmd.Expr);
            foreach (var tup in gm.accesses)
            {
                ret.Add(MkAssert(tup.Item2));
            }
            ret.Add(cmd);
            return(ret);
        }
Example #3
0
        List <Cmd> ProcessCall(CallCmd cmd)
        {
            var ret = new List <Cmd>();

            var gm = new GatherMemAccesses();

            cmd.Ins.Where(e => e != null).Iter(e => gm.VisitExpr(e));

            foreach (var tup in gm.accesses)
            {
                ret.Add(MkAssert(tup.Item2));
            }
            ret.Add(cmd);

            return(ret);
        }
Example #4
0
        public override Implementation VisitImplementation(Implementation node)
        {
            var varDecls = new Dictionary <string, string>();
            var cb       = new CollectBasePointer(varDecls);

            cb.VisitImplementation(node);
            foreach (var b in node.Blocks)
            {
                var newCmds = new List <Cmd>();
                foreach (var c in b.Cmds)
                {
                    if (c is AssumeCmd)
                    {
                        var asmCmd = c as AssumeCmd;
                        if (BoogieUtil.checkAttrExists("nonnull", asmCmd.Attributes))
                        {
                            var expr = asmCmd.Expr as NAryExpr;
                            expr.Args[1] = nil;
                            newCmds.Add(c);
                            continue;
                        }
                    }
                    if (c is AssignCmd)
                    {
                        var asnCmd = c as AssignCmd;
                        var reads  = new GatherMemAccesses();
                        asnCmd.Rhss.Iter(e => reads.VisitExpr(e));
                        foreach (var tup in reads.accesses)
                        {
                            var    ptr = tup.Item2;
                            string basePtr;
                            if (varDecls.TryGetValue(ptr.ToString(), out basePtr))
                            {
                                newCmds.Add(MkAssume(Expr.Ident(BoogieAstFactory.MkFormal(basePtr, btype.Int, true))));
                            }
                            else
                            {
                                newCmds.Add(MkAssume(ptr));
                            }
                        }
                    }
                    newCmds.Add(c);
                }
                b.cmds = newCmds;
            }
            return(node);
        }
Example #5
0
        List <Cmd> ProcessAssign(AssignCmd cmd)
        {
            var ret = new List <Cmd>();

            var reads = new GatherMemAccesses();

            cmd.Lhss.Iter(e => reads.VisitExpr(e.AsExpr));
            cmd.Rhss.Iter(e => reads.VisitExpr(e));
            foreach (var tup in reads.accesses)
            {
                ret.Add(MkAssert(tup.Item2));
            }

            ret.Add(cmd);

            return(ret);
        }