Ted Kremenek | 2798e17 | 2008-04-16 18:39:25 +0000 | [diff] [blame] | 1 | //== 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 Kremenek | 1392261 | 2008-04-16 20:40:59 +0000 | [diff] [blame] | 16 | #include "clang/Analysis/PathSensitive/GRExprEngine.h" |
Ted Kremenek | 2798e17 | 2008-04-16 18:39:25 +0000 | [diff] [blame] | 17 | |
| 18 | using namespace clang; |
| 19 | |
| 20 | void GRTransferFuncs::RegisterChecks(GRExprEngine& Eng) {} |
Ted Kremenek | 1392261 | 2008-04-16 20:40:59 +0000 | [diff] [blame] | 21 | |
| 22 | void GRTransferFuncs::EvalStore(ExplodedNodeSet<ValueState>& Dst, |
| 23 | GRExprEngine& Eng, |
| 24 | GRStmtNodeBuilder<ValueState>& Builder, |
| 25 | Expr* E, ExplodedNode<ValueState>* Pred, |
Ted Kremenek | 4323a57 | 2008-07-10 22:03:41 +0000 | [diff] [blame^] | 26 | const ValueState* St, RVal TargetLV, RVal Val) { |
Ted Kremenek | 1392261 | 2008-04-16 20:40:59 +0000 | [diff] [blame] | 27 | |
| 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 | } |