aboutsummaryrefslogtreecommitdiff
path: root/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-10-29 22:51:44 +0000
committerAnna Zaks <ganna@apple.com>2012-10-29 22:51:44 +0000
commit5ac1df3e15f91ed663826faec7efe2462c18d98c (patch)
tree763d3687ea05d2fa94f4034c4ecad9168e80f7e1 /include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
parent8e68ef0e4c3892b80d9fec77b5d477cd54e90db9 (diff)
[analyzer] Add checker helpers to CheckerContext.
- Adding Immutable Map to GDM and getIdentifierInfo helper method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166975 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h')
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
index 953527da34..4351fe16f0 100644
--- a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -16,6 +16,21 @@
#define LLVM_CLANG_SA_CORE_PATHSENSITIVE_CHECKERCONTEXT
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "llvm/ADT/ImmutableMap.h"
+
+// Declare an immutable map suitable for placement into program states's GDM.
+#define REGISTER_MAP_WITH_GDM(Map, Key, Value) \
+ typedef llvm::ImmutableMap<Key, Value> Map; \
+ namespace clang { \
+ namespace ento { \
+ template <> \
+ struct ProgramStateTrait<Map> \
+ : public ProgramStatePartialTrait<Map> { \
+ static void *GDMIndex() { static int Index; return &Index; } \
+ }; \
+ } \
+ }
+
namespace clang {
namespace ento {
@@ -197,6 +212,15 @@ public:
/// \brief Get the name of the called function (path-sensitive).
StringRef getCalleeName(const FunctionDecl *FunDecl) const;
+ /// \brief Get the identifier of the called function (path-sensitive).
+ const IdentifierInfo *getCalleeIdentifier(const CallExpr *CE) const {
+ const FunctionDecl *FunDecl = getCalleeDecl(CE);
+ if (FunDecl)
+ return FunDecl->getIdentifier();
+ else
+ return 0;
+ }
+
/// \brief Get the name of the called function (path-sensitive).
StringRef getCalleeName(const CallExpr *CE) const {
const FunctionDecl *FunDecl = getCalleeDecl(CE);