CheckerContext.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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. #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
  15. using namespace clang;
  16. using namespace ento;
  17. const FunctionDecl *CheckerContext::getCalleeDecl(const CallExpr *CE) const {
  18. const ProgramState *State = getState();
  19. const Expr *Callee = CE->getCallee();
  20. SVal L = State->getSVal(Callee);
  21. return L.getAsFunctionDecl();
  22. }
  23. StringRef CheckerContext::getCalleeName(const CallExpr *CE) const {
  24. const FunctionDecl *funDecl = getCalleeDecl(CE);
  25. if (!funDecl)
  26. return StringRef();
  27. IdentifierInfo *funI = funDecl->getIdentifier();
  28. if (!funI)
  29. return StringRef();
  30. return funI->getName();
  31. }