diff options
author | Anna Zaks <ganna@apple.com> | 2013-04-10 22:56:30 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-04-10 22:56:30 +0000 |
commit | ee9043ba7c6934d248d4f0e2abded18e26b81df8 (patch) | |
tree | 4a89b1f915ee63a9ccc907c9730f29dfa98740a4 /lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp | |
parent | 337ad7627ca82b1bcba37618d40129c3e59be86b (diff) |
[analyzer] Address Jordan’s code review of r 179221
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179234 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index f6168457a2..6163cc19c6 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -2138,10 +2138,10 @@ PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N, // treated as interesting. struct AllocationInfo { const ExplodedNode* N; - const MemRegion* R; + const MemRegion *R; const LocationContext *InterestingMethodContext; - AllocationInfo(const ExplodedNode* InN, - const MemRegion* InR, + AllocationInfo(const ExplodedNode *InN, + const MemRegion *InR, const LocationContext *InInterestingMethodContext) : N(InN), R(InR), InterestingMethodContext(InInterestingMethodContext) {} }; @@ -2185,22 +2185,26 @@ GetAllocationSite(ProgramStateManager& StateMgr, const ExplodedNode *N, if (NContext == LeakContext) AllocationNodeInCurrentContext = N; - // If init was called on the given symbol, store the init method's location - // context. - if (Optional<CallEnter> CEP = N->getLocation().getAs<CallEnter>()) { - const Stmt *CE = CEP->getCallExpr(); - if (const ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(CE)) { - SVal RecVal = St->getSVal(ME->getInstanceReceiver(), NContext); - if (RecVal.getAsSymbol() == Sym && ME->getMethodFamily() == OMF_init) - InitMethodContext = CEP->getCalleeContext(); + // Find the last init that was called on the given symbol and store the + // init method's location context. + if (!InitMethodContext) + if (Optional<CallEnter> CEP = N->getLocation().getAs<CallEnter>()) { + const Stmt *CE = CEP->getCallExpr(); + if (const ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(CE)) { + const Stmt *RecExpr = ME->getInstanceReceiver(); + if (RecExpr) { + SVal RecV = St->getSVal(RecExpr, NContext); + if (ME->getMethodFamily() == OMF_init && RecV.getAsSymbol() == Sym) + InitMethodContext = CEP->getCalleeContext(); + } + } } - } N = N->pred_empty() ? NULL : *(N->pred_begin()); } // If we are reporting a leak of the object that was allocated with alloc, - // mark it's init method as interesting. + // mark its init method as interesting. const LocationContext *InterestingMethodContext = 0; if (InitMethodContext) { const ProgramPoint AllocPP = AllocationNode->getLocation(); |