aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CallInliner.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-12-23 08:56:18 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-12-23 08:56:18 +0000
commit3ff8481f4be3f30e1082488238d83f78342303e1 (patch)
tree4b0393b521b0d395502274983a02c5538d9a8d9b /lib/Analysis/CallInliner.cpp
parente7809d49413febf078d0503753987fe9f6061a68 (diff)
Migrate the call inliner to the Checker interface.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91991 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CallInliner.cpp')
-rw-r--r--lib/Analysis/CallInliner.cpp65
1 files changed, 36 insertions, 29 deletions
diff --git a/lib/Analysis/CallInliner.cpp b/lib/Analysis/CallInliner.cpp
index 43523c293d..2f748bd8bd 100644
--- a/lib/Analysis/CallInliner.cpp
+++ b/lib/Analysis/CallInliner.cpp
@@ -11,36 +11,43 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Analysis/PathSensitive/GRExprEngine.h"
-#include "clang/Analysis/PathSensitive/GRTransferFuncs.h"
+#include "clang/Analysis/PathSensitive/CheckerVisitor.h"
+#include "clang/Analysis/PathSensitive/GRState.h"
+#include "clang/Analysis/LocalCheckers.h"
using namespace clang;
namespace {
-
-class CallInliner : public GRTransferFuncs {
- ASTContext &Ctx;
+class CallInliner : public Checker {
public:
- CallInliner(ASTContext &ctx) : Ctx(ctx) {}
+ static void *getTag() {
+ static int x;
+ return &x;
+ }
- void EvalCall(ExplodedNodeSet& Dst, GRExprEngine& Engine,
- GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L,
- ExplodedNode* Pred);
-
+ virtual bool EvalCallExpr(CheckerContext &C, const CallExpr *CE);
};
+}
+void clang::RegisterCallInliner(GRExprEngine &Eng) {
+ Eng.registerCheck(new CallInliner());
}
-void CallInliner::EvalCall(ExplodedNodeSet& Dst, GRExprEngine& Engine,
- GRStmtNodeBuilder& Builder, CallExpr* CE, SVal L,
- ExplodedNode* Pred) {
- FunctionDecl const *FD = L.getAsFunctionDecl();
+bool CallInliner::EvalCallExpr(CheckerContext &C, const CallExpr *CE) {
+ const GRState *state = C.getState();
+ const Expr *Callee = CE->getCallee();
+ SVal L = state->getSVal(Callee);
+
+ const FunctionDecl *FD = L.getAsFunctionDecl();
if (!FD)
- return; // GRExprEngine is responsible for the autotransition.
+ return false;
+
+ if (!FD->isThisDeclarationADefinition())
+ return false;
// Make a new LocationContext.
- StackFrameContext const *LocCtx =
- Engine.getAnalysisManager().getStackFrame(FD, Pred->getLocationContext(), CE);
+ const StackFrameContext *LocCtx = C.getAnalysisManager().getStackFrame(FD,
+ C.getPredecessor()->getLocationContext(), CE);
CFGBlock const *Entry = &(LocCtx->getCFG()->getEntry());
@@ -54,22 +61,22 @@ void CallInliner::EvalCall(ExplodedNodeSet& Dst, GRExprEngine& Engine,
// Construct an edge representing the starting location in the function.
BlockEdge Loc(Entry, SuccB, LocCtx);
- GRState const *state = Builder.GetState(Pred);
- state = Engine.getStoreManager().EnterStackFrame(state, LocCtx);
-
+ state = C.getStoreManager().EnterStackFrame(state, LocCtx);
+ // This is a hack. We really should not use the GRStmtNodeBuilder.
bool isNew;
- ExplodedNode *SuccN = Engine.getGraph().getNode(Loc, state, &isNew);
- SuccN->addPredecessor(Pred, Engine.getGraph());
+ GRExprEngine &Eng = C.getEngine();
+ ExplodedNode *Pred = C.getPredecessor();
+ GRStmtNodeBuilder &Builder = C.getNodeBuilder();
- Builder.Deferred.erase(Pred);
-
- // This is a hack. We really should not use the GRStmtNodeBuilder.
+ ExplodedNode *SuccN = Eng.getGraph().getNode(Loc, state, &isNew);
+ SuccN->addPredecessor(Pred, Eng.getGraph());
+ C.getNodeBuilder().Deferred.erase(Pred);
+
if (isNew)
Builder.getWorkList()->Enqueue(SuccN);
Builder.HasGeneratedNode = true;
+
+ return true;
}
-
-GRTransferFuncs *clang::CreateCallInliner(ASTContext &ctx) {
- return new CallInliner(ctx);
-}
+