Added boilerplate for plug-in transfer function support for CallExprs.

GRSimpleVals performs the following action: invalidate all values passed-by-reference.

llvm-svn: 47638
This commit is contained in:
Ted Kremenek 2008-02-26 23:04:29 +00:00
parent f287e7dcc6
commit 448538d860
4 changed files with 43 additions and 1 deletions

View File

@ -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();
}

View File

@ -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.

View File

@ -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);

View File

@ -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