]> granicus.if.org Git - clang/commitdiff
When updating the retain summary based on {cf,ns}_consumed attributes,
authorJohn McCall <rjmccall@apple.com>
Wed, 6 Apr 2011 09:02:12 +0000 (09:02 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 6 Apr 2011 09:02:12 +0000 (09:02 +0000)
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
test/Analysis/retain-release.m

index 416e1209ae6ad2540a97053bd64c3f1b04d775e6..5131c73925749e10c2567ee6b64339e9162b9144 100644 (file)
@@ -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<NSConsumedAttr>()) {
       if (!GCEnabled)
index 2a1d187d56372bec0f71b4ca68feacc50357cb8b..8306896b0c4a31878ccd2f2ac0ed2ce7fe221948 100644 (file)
@@ -1453,3 +1453,10 @@ static void rdar_8724287(CFErrorRef error)
     }
 }
 
+// <rdar://problem/9234108> - 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());
+}