[cfe-commits] r166975 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Anna Zaks ganna at apple.com
Mon Oct 29 15:51:45 PDT 2012


Author: zaks
Date: Mon Oct 29 17:51:44 2012
New Revision: 166975

URL: http://llvm.org/viewvc/llvm-project?rev=166975&view=rev
Log:
[analyzer] Add checker helpers to CheckerContext.

- Adding Immutable Map to GDM and getIdentifierInfo helper method.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
    cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h?rev=166975&r1=166974&r2=166975&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h Mon Oct 29 17:51:44 2012
@@ -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 @@
   /// \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);

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp?rev=166975&r1=166974&r2=166975&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp Mon Oct 29 17:51:44 2012
@@ -406,11 +406,13 @@
 
 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;
 





More information about the cfe-commits mailing list