Ted Kremenek | 3ca9429 | 2008-02-14 18:28:23 +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 files 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" |
| 16 | |
| 17 | using namespace clang; |
| 18 | |
| 19 | //===----------------------------------------------------------------------===// |
| 20 | // Transfer function for Casts. |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | |
| 23 | RValue GRTransferFuncs::EvalCast(ValueManager& ValMgr, RValue X, |
| 24 | Expr* CastExpr) { |
| 25 | |
| 26 | switch (X.getBaseKind()) { |
| 27 | default: |
| 28 | assert(false && "Invalid RValue."); break; |
| 29 | |
| 30 | case RValue::LValueKind: |
| 31 | return EvalCast(ValMgr, cast<LValue>(X), CastExpr); |
| 32 | |
| 33 | case RValue::NonLValueKind: |
| 34 | return EvalCast(ValMgr, cast<NonLValue>(X), CastExpr); |
| 35 | |
| 36 | case RValue::UninitializedKind: |
| 37 | case RValue::UnknownKind: break; |
| 38 | } |
| 39 | |
| 40 | return X; |
| 41 | } |
Ted Kremenek | cf7cf8e | 2008-02-14 19:37:24 +0000 | [diff] [blame] | 42 | |
| 43 | // Binary Operators (except assignments and comma). |
| 44 | |
| 45 | RValue GRTransferFuncs::EvalBinaryOp(ValueManager& ValMgr, |
| 46 | BinaryOperator::Opcode Op, |
| 47 | LValue LHS, LValue RHS) { |
| 48 | |
| 49 | switch (Op) { |
| 50 | default: |
| 51 | assert (false && "Not yet implemented."); |
| 52 | |
| 53 | case BinaryOperator::EQ: |
| 54 | return EvalEQ(ValMgr, LHS, RHS); |
| 55 | |
| 56 | case BinaryOperator::NE: |
| 57 | return EvalNE(ValMgr, LHS, RHS); |
| 58 | } |
| 59 | } |