blob: 03292d1c49b3898cfb00f46460994e5ef821289e [file] [log] [blame]
Ted Kremenek2798e172008-04-16 18:39:25 +00001//== GRTransferFuncs.cpp - Path-Sens. Transfer Functions Interface -*- C++ -*--=
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines GRTransferFuncs, which provides a base-class that
11// defines an interface for transfer functions used by GRExprEngine.
12//
13//===----------------------------------------------------------------------===//
14
15#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
Ted Kremenek13922612008-04-16 20:40:59 +000016#include "clang/Analysis/PathSensitive/GRExprEngine.h"
Ted Kremenek2798e172008-04-16 18:39:25 +000017
18using namespace clang;
19
20void GRTransferFuncs::RegisterChecks(GRExprEngine& Eng) {}
Ted Kremenek13922612008-04-16 20:40:59 +000021
Ted Kremenek4adc81e2008-08-13 04:27:00 +000022void GRTransferFuncs::EvalStore(ExplodedNodeSet<GRState>& Dst,
Ted Kremenek13922612008-04-16 20:40:59 +000023 GRExprEngine& Eng,
Ted Kremenek4adc81e2008-08-13 04:27:00 +000024 GRStmtNodeBuilder<GRState>& Builder,
25 Expr* E, ExplodedNode<GRState>* Pred,
26 const GRState* St, RVal TargetLV, RVal Val) {
Ted Kremenek13922612008-04-16 20:40:59 +000027
28 // This code basically matches the "safety-net" logic of GRExprEngine:
29 // bind Val to TargetLV, and create a new node. We replicate it here
30 // because subclasses of GRTransferFuncs may wish to call it.
31
32 assert (!TargetLV.isUndef());
33
34 if (TargetLV.isUnknown())
35 Builder.MakeNode(Dst, E, Pred, St);
36 else
37 Builder.MakeNode(Dst, E, Pred,
38 Eng.getStateManager().SetRVal(St, cast<LVal>(TargetLV), Val));
39}
Ted Kremenekdf7533b2008-07-17 21:27:31 +000040
Ted Kremenek4adc81e2008-08-13 04:27:00 +000041void GRTransferFuncs::EvalBinOpNN(GRStateSet& OStates,
42 GRStateManager& StateMgr,
43 const GRState *St, Expr* Ex,
Ted Kremenekdf7533b2008-07-17 21:27:31 +000044 BinaryOperator::Opcode Op,
Ted Kremenek6297a8e2008-07-18 05:53:58 +000045 NonLVal L, NonLVal R) {
Ted Kremenekdf7533b2008-07-17 21:27:31 +000046
Ted Kremenekad8329e2008-07-18 15:27:58 +000047 OStates.Add(StateMgr.SetRVal(St, Ex, DetermEvalBinOpNN(StateMgr, Op, L, R)));
Ted Kremenekdf7533b2008-07-17 21:27:31 +000048}