コード例 #1
0
        private List <Cmd> GenArrayBoundChecks(bool onlyLower, AccessRecord ar, int arrDim)
        {
            List <Cmd> boundChecks = new List <Cmd>();

            var ArrayOffset = verifier.FindOrCreateArrayOffsetVariable(ar.v.Name);

            boundChecks.Add(new AssignCmd(Token.NoToken,
                                          new List <AssignLhs> {
                new SimpleAssignLhs(Token.NoToken, Expr.Ident(ArrayOffset))
            },
                                          new List <Expr> {
                ar.Index
            }));

            boundChecks.Add(new AssumeCmd(Token.NoToken, Expr.True,
                                          new QKeyValue(Token.NoToken, "do_not_predicate", new List <object> {
            },
                                                        new QKeyValue(Token.NoToken, "check_id", new List <object> {
                "bounds_check_state_" + ArraySourceID
            },
                                                                      new QKeyValue(Token.NoToken, "captureState", new List <object> {
                "bounds_check_state_" + ArraySourceID
            },
                                                                                    null)))));
            boundChecks.Add(GenBoundCheck(BOUND_TYPE.LOWER, ar, arrDim, ArrayOffset));

            if (!onlyLower)
            {
                boundChecks.Add(GenBoundCheck(BOUND_TYPE.UPPER, ar, arrDim, ArrayOffset));
            }

            ArraySourceID++;
            return(boundChecks);
        }
コード例 #2
0
        private AssertCmd GenBoundCheck(BOUND_TYPE btype, AccessRecord ar, int arrDim, Variable offsetVar)
        {
            Expr           boundExpr     = null;
            IdentifierExpr offsetVarExpr = new IdentifierExpr(Token.NoToken, offsetVar);

            switch (btype)
            {
            case BOUND_TYPE.LOWER:
                boundExpr = verifier.IntRep.MakeSge(offsetVarExpr, verifier.IntRep.GetLiteral(0, verifier.size_t_bits)); break;

            case BOUND_TYPE.UPPER:
                boundExpr = verifier.IntRep.MakeSlt(offsetVarExpr, verifier.IntRep.GetLiteral(arrDim, verifier.size_t_bits)); break;
            }

            return(new AssertCmd(Token.NoToken, boundExpr,
                                 new QKeyValue(Token.NoToken, "array_bounds", new List <object> {
            },
                                               new QKeyValue(Token.NoToken, "sourceloc_num", new List <object> {
                new LiteralExpr(Token.NoToken, Microsoft.Basetypes.BigNum.FromInt(CurrSourceLocNum))
            },
                                                             new QKeyValue(Token.NoToken, "check_id", new List <object> {
                "bounds_check_state_" + ArraySourceID
            },
                                                                           new QKeyValue(Token.NoToken, "array_name", new List <object> {
                ar.v.Name
            },
                                                                                         null))))));
        }
コード例 #3
0
        public override AssignLhs VisitMapAssignLhs(MapAssignLhs node)
        {
            Debug.Assert(NoWrittenVariable());

            if (!State.ContainsConstantArray(node.DeepAssignedVariable))
            {
                return(node);
            }

            Variable WrittenVariable = node.DeepAssignedVariable;

            CheckMapIndex(node);
            Debug.Assert(!(node.Map is MapAssignLhs));

            access = new AccessRecord(WrittenVariable, node.Indexes[0]);

            return(node);
        }
コード例 #4
0
ファイル: WriteCollector.cs プロジェクト: Robinping/gpuverify
        public override AssignLhs VisitMapAssignLhs(MapAssignLhs node)
        {
            Debug.Assert(NoWrittenVariable());

            if (!State.ContainsGlobalOrGroupSharedArray(node.DeepAssignedVariable, true) &&
                !State.ContainsPrivateArray(node.DeepAssignedVariable))
            {
                return(node);
            }

            Variable WrittenVariable = node.DeepAssignedVariable;

            CheckMapIndex(node);
            Debug.Assert(!(node.Map is MapAssignLhs));

            access = new AccessRecord(WrittenVariable, node.Indexes[0]);

            isPrivate = (State.ContainsPrivateArray(WrittenVariable));

            return(node);
        }
コード例 #5
0
 private void AddNoAccessAssumes(List <Cmd> result, AccessRecord ar)
 {
     result.Add(new AssumeCmd(Token.NoToken, Expr.Neq(new IdentifierExpr(Token.NoToken, verifier.FindOrCreateNotAccessedVariable(ar.v.Name, ar.Index.Type)), ar.Index)));
 }