summaryrefslogtreecommitdiffstats
path: root/clang
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
commit2ab0321b0d88d84ac71a1cb9cf78b0f9c3741f25 (patch)
tree3a271921c1e6fb58317b26d8baf406a31b7a8c7a /clang
parent382df5eb18ca25da9b978692738513e14105fde7 (diff)
downloadbcm5719-llvm-2ab0321b0d88d84ac71a1cb9cf78b0f9c3741f25.tar.gz
bcm5719-llvm-2ab0321b0d88d84ac71a1cb9cf78b0f9c3741f25.zip
[analyzer] Add checker helpers to CheckerContext.
- Adding Immutable Map to GDM and getIdentifierInfo helper method. llvm-svn: 166975
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h24
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp2
2 files changed, 26 insertions, 0 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
index 953527da34a..4351fe16f0a 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ b/clang/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);
diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 510556dc9a5..ab1e2a71f9d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -406,11 +406,13 @@ ProgramStateRef StreamChecker::CheckDoubleClose(const CallExpr *CE,
void StreamChecker::checkDeadSymbols(SymbolReaper &SymReaper,
CheckerContext &C) const {
+ // TODO: Clean up the state.
for (SymbolReaper::dead_iterator I = SymReaper.dead_begin(),
E = SymReaper.dead_end(); I != E; ++I) {
SymbolRef Sym = *I;
ProgramStateRef state = C.getState();
const StreamState *SS = state->get<StreamState>(Sym);
+ // TODO: Shouldn't we have a continue here?
if (!SS)
return;
OpenPOWER on IntegriCloud