[cfe-commits] r156215 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp test/Analysis/retain-release.m
Jordy Rose
jediknil at belkadan.com
Fri May 4 20:56:22 PDT 2012
On May 4, 2012, at 18:18, Anna Zaks wrote:
> Author: zaks
> Date: Fri May 4 17:18:39 2012
> New Revision: 156215
>
> URL: http://llvm.org/viewvc/llvm-project?rev=156215&view=rev
> Log:
> [analyzer] RetainCountChecker: Allow objects to escape through callbacks
>
> Fixes radar://10973977.
>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
> cfe/trunk/test/Analysis/retain-release.m
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=156215&r1=156214&r2=156215&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Fri May 4 17:18:39 2012
> @@ -739,7 +739,8 @@
> InitializeMethodSummaries();
> }
>
> - const RetainSummary *getSummary(const FunctionDecl *FD);
> + const RetainSummary *getSummary(const FunctionDecl *FD,
> + const CallOrObjCMessage *CME = 0);
>
> const RetainSummary *getMethodSummary(Selector S, IdentifierInfo *ClsName,
> const ObjCInterfaceDecl *ID,
> @@ -886,7 +887,9 @@
> return FName.find("MakeCollectable") != StringRef::npos;
> }
>
> -const RetainSummary * RetainSummaryManager::getSummary(const FunctionDecl *FD) {
> +const RetainSummary *
> +RetainSummaryManager::getSummary(const FunctionDecl *FD,
> + const CallOrObjCMessage *CME) {
> // Look up a summary in our cache of FunctionDecls -> Summaries.
> FuncSummariesTy::iterator I = FuncSummaries.find(FD);
> if (I != FuncSummaries.end())
> @@ -1001,6 +1004,11 @@
> ScratchArgs = AF.add(ScratchArgs, 1, StopTracking);
> ScratchArgs = AF.add(ScratchArgs, 2, StopTracking);
> S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
> + } else if (CME && CME->hasNonZeroCallbackArg()) {
> + // Allow objects to escape throug callbacks. radar://10973977
> + for (unsigned I = 0; I < CME->getNumArgs(); ++I)
> + ScratchArgs = AF.add(ScratchArgs, I, StopTracking);
> + S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
> }
One of the arguments to getPersistentSummary is the default effect on the arguments, so you shouldn't have to use ScratchArgs to do this. In fact, since summaries are uniqued, not using ScratchArgs could actually save memory in callback-heavy code.
Jordy
More information about the cfe-commits
mailing list