Anna Zaks | 8687397 | 2011-11-17 01:09:15 +0000 | [diff] [blame] | 1 | //== CheckerContext.cpp - Context info for path-sensitive checkers-----------=// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines CheckerContext that provides contextual info for |
| 11 | // path-sensitive checkers. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" |
| 16 | using namespace clang; |
| 17 | using namespace ento; |
| 18 | |
Anna Zaks | b805c8f | 2011-12-01 05:57:37 +0000 | [diff] [blame^] | 19 | const FunctionDecl *CheckerContext::getCalleeDecl(const CallExpr *CE) const { |
Anna Zaks | 8687397 | 2011-11-17 01:09:15 +0000 | [diff] [blame] | 20 | const ProgramState *State = getState(); |
| 21 | const Expr *Callee = CE->getCallee(); |
| 22 | SVal L = State->getSVal(Callee); |
Anna Zaks | b805c8f | 2011-12-01 05:57:37 +0000 | [diff] [blame^] | 23 | return L.getAsFunctionDecl(); |
| 24 | } |
Anna Zaks | 8687397 | 2011-11-17 01:09:15 +0000 | [diff] [blame] | 25 | |
Anna Zaks | b805c8f | 2011-12-01 05:57:37 +0000 | [diff] [blame^] | 26 | StringRef CheckerContext::getCalleeName(const CallExpr *CE) const { |
| 27 | const FunctionDecl *funDecl = getCalleeDecl(CE); |
Anna Zaks | 8687397 | 2011-11-17 01:09:15 +0000 | [diff] [blame] | 28 | if (!funDecl) |
| 29 | return StringRef(); |
| 30 | IdentifierInfo *funI = funDecl->getIdentifier(); |
| 31 | if (!funI) |
| 32 | return StringRef(); |
| 33 | return funI->getName(); |
| 34 | } |