]> granicus.if.org Git - clang/commitdiff
[analyzer] CheckerContext::getPredecessor() cleanup
authorAnna Zaks <ganna@apple.com>
Tue, 1 Nov 2011 22:41:01 +0000 (22:41 +0000)
committerAnna Zaks <ganna@apple.com>
Tue, 1 Nov 2011 22:41:01 +0000 (22:41 +0000)
Remove unnecessary calls to CheckerContext::getPredecessor() + Comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143513 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp

index 077c6b6abcc2b25026f2bf6ed13abfa8067a90ab..2ef306d7b1b24a507976f2de70466016afaf892c 100644 (file)
@@ -48,6 +48,9 @@ public:
     return Eng.getStoreManager();
   }
 
+  /// \brief Returns the previous node in the exploded graph, which includes
+  /// the state of the program before the checker ran. Note, checkers should
+  /// not retain the node in their state since the nodes might get invalidated.
   ExplodedNode *getPredecessor() { return Pred; }
   const ProgramState *getState() { return Pred->getState(); }
 
index 944bff6626c051bdc01dc34ea6d56ef89a440ec8..914b806dd74daa8577dcb6b952ed048f61ed6039 100644 (file)
@@ -307,8 +307,8 @@ void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C,
   }
 
   // Other cases: check if sizeof(return type) > sizeof(void*)
-  if (CanRetTy != Ctx.VoidTy &&
-      C.getPredecessor()->getParentMap().isConsumedExpr(msg.getOriginExpr())) {
+  if (CanRetTy != Ctx.VoidTy && C.getLocationContext()->getParentMap()
+                                  .isConsumedExpr(msg.getOriginExpr())) {
     // Compute: sizeof(void *) and sizeof(return type)
     const uint64_t voidPtrSize = Ctx.getTypeSize(Ctx.VoidPtrTy);
     const uint64_t returnTypeSize = Ctx.getTypeSize(CanRetTy);
index 8f9f7d51fc0f594ae66c8c8da4c58ce3758b3356..4969546de273bdaaa36c1ef94b5c7a46f9817b29 100644 (file)
@@ -2606,13 +2606,12 @@ void RetainCountChecker::checkPostStmt(const CXXConstructExpr *CE,
 void RetainCountChecker::checkPostObjCMessage(const ObjCMessage &Msg, 
                                               CheckerContext &C) const {
   const ProgramState *state = C.getState();
-  ExplodedNode *Pred = C.getPredecessor();
 
   RetainSummaryManager &Summaries = getSummaryManager(C);
 
   const RetainSummary *Summ;
   if (Msg.isInstanceMessage()) {
-    const LocationContext *LC = Pred->getLocationContext();
+    const LocationContext *LC = C.getLocationContext();
     Summ = Summaries.getInstanceMethodSummary(Msg, state, LC);
   } else {
     Summ = Summaries.getClassMethodSummary(Msg);