2011-11-17 01:09:15 +00:00
|
|
|
//== CheckerContext.cpp - Context info for path-sensitive checkers-----------=//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines CheckerContext that provides contextual info for
|
|
|
|
// path-sensitive checkers.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
|
|
|
|
using namespace clang;
|
|
|
|
using namespace ento;
|
|
|
|
|
2011-12-01 05:57:37 +00:00
|
|
|
const FunctionDecl *CheckerContext::getCalleeDecl(const CallExpr *CE) const {
|
2011-11-17 01:09:15 +00:00
|
|
|
const ProgramState *State = getState();
|
|
|
|
const Expr *Callee = CE->getCallee();
|
2012-01-06 22:09:28 +00:00
|
|
|
SVal L = State->getSVal(Callee, Pred->getLocationContext());
|
2011-12-01 05:57:37 +00:00
|
|
|
return L.getAsFunctionDecl();
|
|
|
|
}
|
2011-11-17 01:09:15 +00:00
|
|
|
|
2011-12-01 05:57:37 +00:00
|
|
|
StringRef CheckerContext::getCalleeName(const CallExpr *CE) const {
|
|
|
|
const FunctionDecl *funDecl = getCalleeDecl(CE);
|
2011-11-17 01:09:15 +00:00
|
|
|
if (!funDecl)
|
|
|
|
return StringRef();
|
|
|
|
IdentifierInfo *funI = funDecl->getIdentifier();
|
|
|
|
if (!funI)
|
|
|
|
return StringRef();
|
|
|
|
return funI->getName();
|
|
|
|
}
|