]> granicus.if.org Git - clang/commitdiff
[static analyzer] Tweak RetainCountChecker's diagnostics to correctly indicate if...
authorTed Kremenek <kremenek@apple.com>
Mon, 14 Nov 2011 21:59:21 +0000 (21:59 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 14 Nov 2011 21:59:21 +0000 (21:59 +0000)
potentially be refactored for other clients, and this is a regression from the refactoring of property acceses.

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

lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
test/Analysis/retain-release-path-notes.m

index 4969546de273bdaaa36c1ef94b5c7a46f9817b29..9537b31290b49bc7f6ed80397c3eb952e8f51b53 100644 (file)
@@ -18,6 +18,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Analysis/DomainSpecific/CocoaConventions.h"
+#include "clang/AST/ParentMap.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
@@ -1815,6 +1816,20 @@ static inline bool contains(const SmallVectorImpl<ArgEffect>& V,
   return false;
 }
 
+static bool isPropertyAccess(const Stmt *S, ParentMap &PM) {
+  unsigned maxDepth = 4;
+  while (S && maxDepth) {
+    if (const PseudoObjectExpr *PO = dyn_cast<PseudoObjectExpr>(S)) {
+      if (!isa<ObjCMessageExpr>(PO->getSyntacticForm()))
+        return true;
+      return false;
+    }
+    S = PM.getParent(S);
+    --maxDepth;
+  }
+  return false;
+}
+
 PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N,
                                                    const ExplodedNode *PrevN,
                                                    BugReporterContext &BRC,
@@ -1851,10 +1866,11 @@ PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N,
       else
         os << "function call";
     }
-    else if (isa<ObjCMessageExpr>(S)) {
-      os << "Method";
-    } else {
-      os << "Property";
+    else {
+      assert(isa<ObjCMessageExpr>(S));      
+      // The message expression may have between written directly or as
+      // a property access.  Lazily determine which case we are looking at.
+      os << (isPropertyAccess(S, N->getParentMap()) ? "Property" : "Method");
     }
 
     if (CurrV.getObjKind() == RetEffect::CF) {
index dfe44748e65faa03f65d8a0220d0791998be8bd4..f9676d1abd9799329089e6378c51e93a0c1d0167 100644 (file)
@@ -3,7 +3,6 @@
 // This actually still works after the pseudo-object refactor, it just
 // uses messages that say 'method' instead of 'property'.  Ted wanted
 // this xfailed and filed as a bug.  rdar://problem/10402993
-// XFAIL: *
 
 /***
 This file is for testing the path-sensitive notes for retain/release errors.