From 98b8f16a0b056919f24206a8a3ca86f9ea75fa34 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 6 Apr 2011 09:02:12 +0000 Subject: [PATCH] When updating the retain summary based on {cf,ns}_consumed attributes, be sure to consume the argument index that actually had the attribute rather than always the first. rdar://problem/9234108 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128998 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/CFRefCount.cpp | 2 +- test/Analysis/retain-release.m | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/StaticAnalyzer/Core/CFRefCount.cpp b/lib/StaticAnalyzer/Core/CFRefCount.cpp index 416e1209ae..5131c73925 100644 --- a/lib/StaticAnalyzer/Core/CFRefCount.cpp +++ b/lib/StaticAnalyzer/Core/CFRefCount.cpp @@ -1201,7 +1201,7 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ, // Effects on the parameters. unsigned parm_idx = 0; for (FunctionDecl::param_const_iterator pi = FD->param_begin(), - pe = FD->param_end(); pi != pe; ++pi) { + pe = FD->param_end(); pi != pe; ++pi, ++parm_idx) { const ParmVarDecl *pd = *pi; if (pd->getAttr()) { if (!GCEnabled) diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 2a1d187d56..8306896b0c 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -1453,3 +1453,10 @@ static void rdar_8724287(CFErrorRef error) } } +// - Make sure the model applies cf_consumed +// correctly in argument positions besides the first. +extern void *CFStringCreate(void); +extern void rdar_9234108_helper(void *key, void * CF_CONSUMED value); +void rdar_9234108() { + rdar_9234108_helper(0, CFStringCreate()); +}