2009-09-11 04:13:42 +00:00
|
|
|
//===--- CallInliner.cpp - Transfer function that inlines callee ----------===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
//
|
|
|
|
|
// This file implements the callee inlining transfer function.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2010-01-25 04:41:41 +00:00
|
|
|
#include "clang/Checker/PathSensitive/CheckerVisitor.h"
|
|
|
|
|
#include "clang/Checker/PathSensitive/GRState.h"
|
2010-01-26 22:59:55 +00:00
|
|
|
#include "clang/Checker/Checkers/LocalCheckers.h"
|
2009-09-11 04:13:42 +00:00
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
|
|
namespace {
|
2009-12-23 08:56:18 +00:00
|
|
|
class CallInliner : public Checker {
|
2009-09-11 04:13:42 +00:00
|
|
|
public:
|
2009-12-23 08:56:18 +00:00
|
|
|
static void *getTag() {
|
|
|
|
|
static int x;
|
|
|
|
|
return &x;
|
|
|
|
|
}
|
2009-09-11 04:13:42 +00:00
|
|
|
|
2009-12-23 08:56:18 +00:00
|
|
|
virtual bool EvalCallExpr(CheckerContext &C, const CallExpr *CE);
|
2009-09-11 04:13:42 +00:00
|
|
|
};
|
2009-12-23 08:56:18 +00:00
|
|
|
}
|
2009-09-11 04:13:42 +00:00
|
|
|
|
2009-12-23 08:56:18 +00:00
|
|
|
void clang::RegisterCallInliner(GRExprEngine &Eng) {
|
|
|
|
|
Eng.registerCheck(new CallInliner());
|
2009-09-11 04:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
2009-12-23 08:56:18 +00:00
|
|
|
bool CallInliner::EvalCallExpr(CheckerContext &C, const CallExpr *CE) {
|
|
|
|
|
const GRState *state = C.getState();
|
|
|
|
|
const Expr *Callee = CE->getCallee();
|
2010-02-08 16:18:51 +00:00
|
|
|
SVal L = state->getSVal(Callee);
|
2009-12-24 03:34:38 +00:00
|
|
|
|
2009-12-23 08:56:18 +00:00
|
|
|
const FunctionDecl *FD = L.getAsFunctionDecl();
|
2009-10-13 02:36:42 +00:00
|
|
|
if (!FD)
|
2009-12-23 08:56:18 +00:00
|
|
|
return false;
|
|
|
|
|
|
2010-02-28 06:39:11 +00:00
|
|
|
if (!FD->getBody(FD))
|
2009-12-23 08:56:18 +00:00
|
|
|
return false;
|
2009-10-13 02:36:42 +00:00
|
|
|
|
2010-02-25 19:01:53 +00:00
|
|
|
// Now we have the definition of the callee, create a CallEnter node.
|
|
|
|
|
CallEnter Loc(CE, FD, C.getPredecessor()->getLocationContext());
|
|
|
|
|
C.addTransition(state, Loc);
|
2009-12-23 08:56:18 +00:00
|
|
|
|
|
|
|
|
return true;
|
2009-09-11 04:13:42 +00:00
|
|
|
}
|
2009-12-23 08:56:18 +00:00
|
|
|
|