aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-02-26 23:04:29 +0000
committerTed Kremenek <kremenek@apple.com>2008-02-26 23:04:29 +0000
commit06747691096654742d9ed7342e63828456b4f40c (patch)
treeb73348ddaebdae5a38f40f3836f6107e50199069
parent0015541bcfd2f3282fa3ce50f1e840681fad0853 (diff)
Added boilerplate for plug-in transfer function support for CallExprs.
GRSimpleVals performs the following action: invalidate all values passed-by-reference. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47638 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Analysis/GRSimpleVals.cpp25
-rw-r--r--Analysis/GRSimpleVals.h7
-rw-r--r--include/clang/Analysis/PathSensitive/GRExprEngine.h2
-rw-r--r--include/clang/Analysis/PathSensitive/GRTransferFuncs.h10
4 files changed, 43 insertions, 1 deletions
diff --git a/Analysis/GRSimpleVals.cpp b/Analysis/GRSimpleVals.cpp
index 549aa0bb4f..4d9dccf621 100644
--- a/Analysis/GRSimpleVals.cpp
+++ b/Analysis/GRSimpleVals.cpp
@@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "GRSimpleVals.h"
+#include "ValueState.h"
#include "clang/Basic/Diagnostic.h"
using namespace clang;
@@ -329,3 +330,27 @@ RVal GRSimpleVals::EvalNE(ValueManager& ValMgr, LVal L, LVal R) {
return NonLVal::MakeIntTruthVal(ValMgr, true);
}
+
+//===----------------------------------------------------------------------===//
+// Transfer function for Function Calls.
+//===----------------------------------------------------------------------===//
+
+ValueStateImpl*
+GRSimpleVals::EvalCall(ValueStateManager& StateMgr, ValueManager& ValMgr,
+ CallExpr* CE, LVal L, ValueStateImpl* StImpl) {
+
+ ValueState St(StImpl);
+
+ // Invalidate all arguments passed in by reference (LVals).
+
+ for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end();
+ I != E; ++I) {
+
+ RVal V = StateMgr.GetRVal(St, *I);
+
+ if (isa<LVal>(V))
+ St = StateMgr.SetRVal(St, cast<LVal>(V), UnknownVal());
+ }
+
+ return St.getImpl();
+}
diff --git a/Analysis/GRSimpleVals.h b/Analysis/GRSimpleVals.h
index 870166e8f4..10d4acd4b9 100644
--- a/Analysis/GRSimpleVals.h
+++ b/Analysis/GRSimpleVals.h
@@ -50,6 +50,13 @@ public:
virtual RVal EvalBinOp(ValueManager& ValMgr, BinaryOperator::Opcode Op,
LVal L, NonLVal R);
+ // Calls.
+
+ virtual ValueStateImpl* EvalCall(ValueStateManager& StateMgr,
+ ValueManager& ValMgr,
+ CallExpr* CE, LVal L,
+ ValueStateImpl* StImpl);
+
protected:
// Equality operators for LVals.
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h
index a5f88354b8..5c9092943b 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h
@@ -410,7 +410,7 @@ protected:
}
StateTy EvalCall(CallExpr* CE, LVal L, StateTy St) {
- return St;
+ return StateTy(TF->EvalCall(StateMgr, ValMgr, CE, L, St.getImpl()));
}
StateTy MarkBranch(StateTy St, Stmt* Terminator, bool branchTaken);
diff --git a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
index 2a8ec2b6f7..b4953d6401 100644
--- a/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
+++ b/include/clang/Analysis/PathSensitive/GRTransferFuncs.h
@@ -19,6 +19,9 @@
namespace clang {
+ class ValueStateImpl;
+ class ValueStateManager;
+
class GRTransferFuncs {
public:
GRTransferFuncs() {}
@@ -47,6 +50,13 @@ public:
virtual RVal EvalBinOp(ValueManager& ValMgr, BinaryOperator::Opcode Op,
LVal L, NonLVal R) = 0;
+
+ // Calls.
+
+ virtual ValueStateImpl* EvalCall(ValueStateManager& StateMgr,
+ ValueManager& ValMgr,
+ CallExpr* CE, LVal L,
+ ValueStateImpl* StImpl) = 0;
};
} // end clang namespace