blob: e30e0712c510d61b445cbb3d0bb21e63b7bcfb3f [file] [log] [blame]
Ted Kremenek36cf32c2008-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 Kremenek7aef4842008-04-16 20:40:59 +000016#include "clang/Analysis/PathSensitive/GRExprEngine.h"
Ted Kremenek36cf32c2008-04-16 18:39:25 +000017
18using namespace clang;
19
20void GRTransferFuncs::RegisterChecks(GRExprEngine& Eng) {}
Ted Kremenek7aef4842008-04-16 20:40:59 +000021
22void GRTransferFuncs::EvalStore(ExplodedNodeSet<ValueState>& Dst,
23 GRExprEngine& Eng,
24 GRStmtNodeBuilder<ValueState>& Builder,
25 Expr* E, ExplodedNode<ValueState>* Pred,
Ted Kremenekf22f8682008-07-10 22:03:41 +000026 const ValueState* St, RVal TargetLV, RVal Val) {
Ted Kremenek7aef4842008-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 Kremenekfa81dff2008-07-17 21:27:31 +000040
Ted Kremenek9c4ce602008-07-18 05:53:58 +000041void GRTransferFuncs::EvalBinOpNN(ValueStateSet& OStates,
42 ValueStateManager& StateMgr,
43 const ValueState *St, Expr* Ex,
Ted Kremenekfa81dff2008-07-17 21:27:31 +000044 BinaryOperator::Opcode Op,
Ted Kremenek9c4ce602008-07-18 05:53:58 +000045 NonLVal L, NonLVal R) {
Ted Kremenekfa81dff2008-07-17 21:27:31 +000046
Ted Kremenek589f8812008-07-18 15:27:58 +000047 OStates.Add(StateMgr.SetRVal(St, Ex, DetermEvalBinOpNN(StateMgr, Op, L, R)));
Ted Kremenekfa81dff2008-07-17 21:27:31 +000048}