Started partitioning of transfer function logic (and thus the policy behind
these operations) into GRTransferFuncs and its subclasses. Originally all
of this logic was handled by the class RValue, but in reality different
analyses will want more flexibility on how they evaluate different values.
Transfer functions migrated so far: "Cast"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47125 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Analysis/GRTransferFuncs.cpp b/Analysis/GRTransferFuncs.cpp
new file mode 100644
index 0000000..3716ed9
--- /dev/null
+++ b/Analysis/GRTransferFuncs.cpp
@@ -0,0 +1,41 @@
+//== GRTransferFuncs.cpp - Path-Sens. Transfer Functions Interface -*- C++ -*--=
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This files defines GRTransferFuncs, which provides a base-class that
+// defines an interface for transfer functions used by GRExprEngine.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
+
+using namespace clang;
+
+//===----------------------------------------------------------------------===//
+// Transfer function for Casts.
+//===----------------------------------------------------------------------===//
+
+RValue GRTransferFuncs::EvalCast(ValueManager& ValMgr, RValue X,
+ Expr* CastExpr) {
+
+ switch (X.getBaseKind()) {
+ default:
+ assert(false && "Invalid RValue."); break;
+
+ case RValue::LValueKind:
+ return EvalCast(ValMgr, cast<LValue>(X), CastExpr);
+
+ case RValue::NonLValueKind:
+ return EvalCast(ValMgr, cast<NonLValue>(X), CastExpr);
+
+ case RValue::UninitializedKind:
+ case RValue::UnknownKind: break;
+ }
+
+ return X;
+}