Index: cfe/trunk/include/clang/Analysis/ObjCRetainCount.h =================================================================== --- cfe/trunk/include/clang/Analysis/ObjCRetainCount.h +++ cfe/trunk/include/clang/Analysis/ObjCRetainCount.h @@ -65,6 +65,9 @@ /// if CFRetain has been called on the argument. IncRef, + /// Used to mark an argument as collectible in GC mode, currently a noop. + MakeCollectable, + /// The argument is a pointer to a retain-counted object; on exit, the new /// value of the pointer is a +0 value or NULL. UnretainedOutParameter, Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp @@ -581,6 +581,8 @@ case DecRefMsgAndStopTrackingHard: E = IgnoreRetainMsg ? StopTracking : DecRefAndStopTrackingHard; break; + case MakeCollectable: + E = DoNothing; } // Handle all use-after-releases. @@ -593,8 +595,9 @@ switch (E) { case DecRefMsg: case IncRefMsg: + case MakeCollectable: case DecRefMsgAndStopTrackingHard: - llvm_unreachable("DecRefMsg/IncRefMsg already converted"); + llvm_unreachable("DecRefMsg/IncRefMsg/MakeCollectable already converted"); case UnretainedOutParameter: case RetainedOutParameter: Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.h =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.h +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.h @@ -315,7 +315,7 @@ /// data in ScratchArgs. ArgEffects getArgEffects(); - enum UnaryFuncKind { cfretain, cfrelease, cfautorelease }; + enum UnaryFuncKind { cfretain, cfrelease, cfautorelease, cfmakecollectable }; const RetainSummary *getUnarySummary(const FunctionType* FT, UnaryFuncKind func); Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp @@ -78,6 +78,10 @@ FName.endswith_lower("autorelease"); } +static bool isMakeCollectable(StringRef FName) { + return FName.contains_lower("MakeCollectable"); +} + const RetainSummary * RetainSummaryManager::generateSummary(const FunctionDecl *FD, bool &AllowAnnotations) { @@ -111,6 +115,11 @@ // Part of: and . // This will be addressed better with IPA. return getPersistentStopSummary(); + } else if(FName == "NSMakeCollectable") { + // Handle: id NSMakeCollectable(CFTypeRef) + AllowAnnotations = false; + return RetTy->isObjCIdType() ? getUnarySummary(FT, cfmakecollectable) + : getPersistentStopSummary(); } else if (FName == "CFPlugInInstanceCreate") { return getPersistentSummary(RetEffect::MakeNoRet()); } else if (FName == "IORegistryEntrySearchCFProperty" || @@ -207,6 +216,9 @@ AllowAnnotations = false; return getUnarySummary(FT, cfautorelease); + } else if (isMakeCollectable(FName)) { + AllowAnnotations = false; + return getUnarySummary(FT, cfmakecollectable); } else { return getCFCreateGetRuleSummary(FD); } @@ -301,7 +313,6 @@ // Summary creation for functions (largely uses of Core Foundation). //===----------------------------------------------------------------------===// - static ArgEffect getStopTrackingHardEquivalent(ArgEffect E) { switch (E) { case DoNothing: @@ -309,6 +320,7 @@ case DecRefBridgedTransferred: case IncRef: case IncRefMsg: + case MakeCollectable: case UnretainedOutParameter: case RetainedOutParameter: case MayEscape: @@ -458,14 +470,17 @@ FName = FName.substr(FName.find_first_not_of('_')); QualType ResultTy = CE->getCallReturnType(Ctx); - if (ResultTy->isPointerType()) { + if (ResultTy->isObjCIdType()) { + return II->isStr("NSMakeCollectable"); + } else if (ResultTy->isPointerType()) { // Handle: (CF|CG|CV)Retain // CFAutorelease // It's okay to be a little sloppy here. if (cocoa::isRefType(ResultTy, "CF", FName) || cocoa::isRefType(ResultTy, "CG", FName) || cocoa::isRefType(ResultTy, "CV", FName)) - return isRetain(FD, FName) || isAutorelease(FD, FName); + return isRetain(FD, FName) || isAutorelease(FD, FName) || + isMakeCollectable(FName); if (FD->getDefinition()) { bool out = isTrustedReferenceCountImplementation(FD->getDefinition()); @@ -495,6 +510,7 @@ case cfretain: Effect = IncRef; break; case cfrelease: Effect = DecRef; break; case cfautorelease: Effect = Autorelease; break; + case cfmakecollectable: Effect = MakeCollectable; break; } ScratchArgs = AF.add(ScratchArgs, 0, Effect); Index: cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist =================================================================== --- cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist +++ cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist @@ -7,7 +7,7 @@ kindevent location - line44 + line47 col15 file0 @@ -15,12 +15,12 @@ - line44 + line47 col15 file0 - line44 + line47 col37 file0 @@ -40,12 +40,12 @@ start - line44 + line47 col3 file0 - line44 + line47 col4 file0 @@ -53,12 +53,12 @@ end - line45 + line48 col3 file0 - line45 + line48 col8 file0 @@ -70,7 +70,7 @@ kindevent location - line45 + line48 col3 file0 @@ -78,12 +78,12 @@ - line45 + line48 col3 file0 - line45 + line48 col8 file0 @@ -107,7 +107,7 @@ issue_hash_function_offset1 location - line45 + line48 col3 file0 @@ -119,7 +119,7 @@ kindevent location - line49 + line52 col22 file0 @@ -127,12 +127,12 @@ - line49 + line52 col22 file0 - line49 + line52 col40 file0 @@ -152,12 +152,12 @@ start - line49 + line52 col3 file0 - line49 + line52 col11 file0 @@ -165,12 +165,12 @@ end - line50 + line53 col3 file0 - line50 + line53 col8 file0 @@ -182,7 +182,7 @@ kindevent location - line50 + line53 col3 file0 @@ -190,12 +190,12 @@ - line50 + line53 col3 file0 - line50 + line53 col8 file0 @@ -219,7 +219,7 @@ issue_hash_function_offset1 location - line50 + line53 col3 file0 @@ -231,7 +231,7 @@ kindevent location - line54 + line57 col15 file0 @@ -239,12 +239,12 @@ - line54 + line57 col15 file0 - line54 + line57 col35 file0 @@ -264,12 +264,12 @@ start - line54 + line57 col3 file0 - line54 + line57 col4 file0 @@ -277,12 +277,12 @@ end - line55 + line58 col3 file0 - line55 + line58 col3 file0 @@ -294,7 +294,7 @@ kindevent location - line55 + line58 col3 file0 @@ -302,24 +302,24 @@ - line55 + line58 col3 file0 - line55 + line58 col17 file0 - line55 + line58 col4 file0 - line55 + line58 col9 file0 @@ -339,12 +339,12 @@ start - line55 + line58 col3 file0 - line55 + line58 col3 file0 @@ -352,12 +352,12 @@ end - line56 + line59 col3 file0 - line56 + line59 col3 file0 @@ -369,7 +369,7 @@ kindevent location - line56 + line59 col3 file0 @@ -377,24 +377,24 @@ - line56 + line59 col3 file0 - line56 + line59 col17 file0 - line56 + line59 col4 file0 - line56 + line59 col9 file0 @@ -414,12 +414,12 @@ start - line56 + line59 col3 file0 - line56 + line59 col3 file0 @@ -427,12 +427,12 @@ end - line57 + line60 col3 file0 - line57 + line60 col3 file0 @@ -444,7 +444,7 @@ kindevent location - line57 + line60 col3 file0 @@ -452,24 +452,24 @@ - line57 + line60 col3 file0 - line57 + line60 col18 file0 - line57 + line60 col4 file0 - line57 + line60 col9 file0 @@ -489,12 +489,12 @@ start - line57 + line60 col3 file0 - line57 + line60 col3 file0 @@ -502,12 +502,12 @@ end - line58 + line61 col3 file0 - line58 + line61 col8 file0 @@ -519,7 +519,7 @@ kindevent location - line58 + line61 col3 file0 @@ -527,12 +527,12 @@ - line58 + line61 col3 file0 - line58 + line61 col8 file0 @@ -556,7 +556,7 @@ issue_hash_function_offset1 location - line58 + line61 col3 file0 @@ -568,7 +568,7 @@ kindevent location - line62 + line65 col19 file0 @@ -576,12 +576,12 @@ - line62 + line65 col19 file0 - line62 + line65 col31 file0 @@ -601,12 +601,12 @@ start - line62 + line65 col3 file0 - line62 + line65 col4 file0 @@ -614,12 +614,12 @@ end - line63 + line66 col3 file0 - line63 + line66 col3 file0 @@ -631,7 +631,7 @@ kindevent location - line63 + line66 col3 file0 @@ -639,24 +639,24 @@ - line63 + line66 col3 file0 - line63 + line66 col17 file0 - line63 + line66 col4 file0 - line63 + line66 col9 file0 @@ -676,12 +676,12 @@ start - line63 + line66 col3 file0 - line63 + line66 col3 file0 @@ -689,12 +689,12 @@ end - line64 + line67 col3 file0 - line64 + line67 col8 file0 @@ -706,7 +706,7 @@ kindevent location - line64 + line67 col3 file0 @@ -714,12 +714,12 @@ - line64 + line67 col3 file0 - line64 + line67 col8 file0 @@ -743,7 +743,7 @@ issue_hash_function_offset1 location - line64 + line67 col3 file0 @@ -755,7 +755,7 @@ kindevent location - line68 + line71 col22 file0 @@ -763,12 +763,12 @@ - line68 + line71 col22 file0 - line68 + line71 col37 file0 @@ -788,12 +788,12 @@ start - line68 + line71 col3 file0 - line68 + line71 col11 file0 @@ -801,12 +801,12 @@ end - line69 + line72 col3 file0 - line69 + line72 col10 file0 @@ -818,7 +818,7 @@ kindevent location - line69 + line72 col3 file0 @@ -826,24 +826,24 @@ - line69 + line72 col3 file0 - line69 + line72 col18 file0 - line69 + line72 col12 file0 - line69 + line72 col17 file0 @@ -863,12 +863,12 @@ start - line69 + line72 col3 file0 - line69 + line72 col10 file0 @@ -876,12 +876,12 @@ end - line70 + line73 col3 file0 - line70 + line73 col8 file0 @@ -893,7 +893,7 @@ kindevent location - line70 + line73 col3 file0 @@ -901,12 +901,12 @@ - line70 + line73 col3 file0 - line70 + line73 col8 file0 @@ -930,7 +930,7 @@ issue_hash_function_offset1 location - line70 + line73 col3 file0 @@ -942,7 +942,7 @@ kindevent location - line74 + line77 col15 file0 @@ -950,12 +950,12 @@ - line74 + line77 col15 file0 - line74 + line77 col37 file0 @@ -975,12 +975,12 @@ start - line74 + line77 col3 file0 - line74 + line77 col4 file0 @@ -988,12 +988,12 @@ end - line75 + line78 col3 file0 - line75 + line78 col3 file0 @@ -1005,7 +1005,7 @@ kindevent location - line75 + line78 col3 file0 @@ -1013,24 +1013,24 @@ - line75 + line78 col3 file0 - line75 + line78 col18 file0 - line75 + line78 col4 file0 - line75 + line78 col9 file0 @@ -1050,12 +1050,12 @@ start - line75 + line78 col3 file0 - line75 + line78 col3 file0 @@ -1063,12 +1063,12 @@ end - line76 + line79 col3 file0 - line76 + line79 col3 file0 @@ -1080,7 +1080,7 @@ kindevent location - line76 + line79 col3 file0 @@ -1088,12 +1088,12 @@ - line76 + line79 col4 file0 - line76 + line79 col9 file0 @@ -1117,7 +1117,7 @@ issue_hash_function_offset3 location - line76 + line79 col3 file0 @@ -1129,7 +1129,7 @@ kindevent location - line80 + line83 col15 file0 @@ -1137,12 +1137,12 @@ - line80 + line83 col15 file0 - line80 + line83 col37 file0 @@ -1162,12 +1162,12 @@ start - line80 + line83 col3 file0 - line80 + line83 col4 file0 @@ -1175,12 +1175,12 @@ end - line81 + line84 col3 file0 - line81 + line84 col3 file0 @@ -1192,7 +1192,7 @@ kindevent location - line81 + line84 col3 file0 @@ -1200,24 +1200,24 @@ - line81 + line84 col3 file0 - line81 + line84 col18 file0 - line81 + line84 col4 file0 - line81 + line84 col9 file0 @@ -1237,12 +1237,12 @@ start - line81 + line84 col3 file0 - line81 + line84 col3 file0 @@ -1250,12 +1250,12 @@ end - line82 + line85 col3 file0 - line82 + line85 col3 file0 @@ -1267,7 +1267,7 @@ kindevent location - line82 + line85 col3 file0 @@ -1275,12 +1275,12 @@ - line82 + line85 col4 file0 - line82 + line85 col9 file0 @@ -1304,7 +1304,7 @@ issue_hash_function_offset3 location - line82 + line85 col3 file0 @@ -1316,7 +1316,7 @@ kindevent location - line86 + line89 col15 file0 @@ -1324,12 +1324,12 @@ - line86 + line89 col15 file0 - line86 + line89 col37 file0 @@ -1349,12 +1349,12 @@ start - line86 + line89 col3 file0 - line86 + line89 col4 file0 @@ -1362,12 +1362,12 @@ end - line87 + line90 col3 file0 - line87 + line90 col3 file0 @@ -1379,7 +1379,7 @@ kindevent location - line87 + line90 col3 file0 @@ -1387,24 +1387,24 @@ - line87 + line90 col3 file0 - line87 + line90 col22 file0 - line87 + line90 col4 file0 - line87 + line90 col9 file0 @@ -1424,12 +1424,12 @@ start - line87 + line90 col3 file0 - line87 + line90 col3 file0 @@ -1437,12 +1437,12 @@ end - line88 + line91 col3 file0 - line88 + line91 col3 file0 @@ -1454,7 +1454,7 @@ kindevent location - line88 + line91 col3 file0 @@ -1462,24 +1462,24 @@ - line88 + line91 col3 file0 - line88 + line91 col22 file0 - line88 + line91 col4 file0 - line88 + line91 col9 file0 @@ -1499,12 +1499,12 @@ start - line88 + line91 col3 file0 - line88 + line91 col3 file0 @@ -1512,12 +1512,12 @@ end - line89 + line92 col3 file0 - line89 + line92 col8 file0 @@ -1529,7 +1529,7 @@ kindevent location - line89 + line92 col3 file0 @@ -1537,12 +1537,12 @@ - line89 + line92 col3 file0 - line89 + line92 col8 file0 @@ -1566,7 +1566,7 @@ issue_hash_function_offset4 location - line89 + line92 col3 file0 @@ -1578,7 +1578,7 @@ kindevent location - line93 + line96 col19 file0 @@ -1586,12 +1586,12 @@ - line93 + line96 col19 file0 - line93 + line96 col31 file0 @@ -1611,12 +1611,12 @@ start - line93 + line96 col3 file0 - line93 + line96 col4 file0 @@ -1624,12 +1624,12 @@ end - line94 + line97 col3 file0 - line94 + line97 col3 file0 @@ -1641,7 +1641,7 @@ kindevent location - line94 + line97 col3 file0 @@ -1649,24 +1649,24 @@ - line94 + line97 col3 file0 - line94 + line97 col22 file0 - line94 + line97 col4 file0 - line94 + line97 col9 file0 @@ -1686,12 +1686,12 @@ start - line94 + line97 col3 file0 - line94 + line97 col3 file0 @@ -1699,12 +1699,12 @@ end - line95 + line98 col3 file0 - line95 + line98 col8 file0 @@ -1716,7 +1716,7 @@ kindevent location - line95 + line98 col3 file0 @@ -1724,12 +1724,12 @@ - line95 + line98 col3 file0 - line95 + line98 col8 file0 @@ -1753,7 +1753,119 @@ issue_hash_function_offset3 location - line95 + line98 + col3 + file0 + + + + path + + + kindevent + location + + line102 + col22 + file0 + + ranges + + + + line102 + col22 + file0 + + + line102 + col40 + file0 + + + + depth0 + extended_message + Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count + message + Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count + + + kindcontrol + edges + + + start + + + line102 + col3 + file0 + + + line102 + col11 + file0 + + + end + + + line105 + col3 + file0 + + + line105 + col8 + file0 + + + + + + + kindevent + location + + line105 + col3 + file0 + + ranges + + + + line105 + col3 + file0 + + + line105 + col8 + file0 + + + + depth0 + extended_message + Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 + message + Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 + + + descriptionPotential leak of an object stored into 'leaked' + categoryMemory (Core Foundation/Objective-C) + typeLeak + check_nameosx.cocoa.RetainCount + + issue_hash_content_of_line_in_context3f08690fae9687c29bb23b7a7cb7995b + issue_context_kindfunction + issue_contextmakeCollectableIgnored + issue_hash_function_offset1 + location + + line105 col3 file0 @@ -1765,7 +1877,7 @@ kindevent location - line99 + line109 col22 file0 @@ -1773,12 +1885,12 @@ - line99 + line109 col22 file0 - line99 + line109 col37 file0 @@ -1798,12 +1910,12 @@ start - line99 + line109 col3 file0 - line99 + line109 col11 file0 @@ -1811,12 +1923,12 @@ end - line100 + line110 col3 file0 - line100 + line110 col8 file0 @@ -1828,7 +1940,7 @@ kindevent location - line100 + line110 col3 file0 @@ -1836,24 +1948,24 @@ - line100 + line110 col3 file0 - line100 + line110 col15 file0 - line100 + line110 col10 file0 - line100 + line110 col15 file0 @@ -1869,7 +1981,7 @@ kindevent location - line100 + line110 col3 file0 @@ -1877,12 +1989,12 @@ - line100 + line110 col3 file0 - line100 + line110 col15 file0 @@ -1906,7 +2018,7 @@ issue_hash_function_offset2 location - line100 + line110 col3 file0 @@ -1918,7 +2030,7 @@ kindevent location - line104 + line114 col22 file0 @@ -1926,12 +2038,12 @@ - line104 + line114 col22 file0 - line104 + line114 col40 file0 @@ -1951,12 +2063,12 @@ start - line104 + line114 col3 file0 - line104 + line114 col11 file0 @@ -1964,12 +2076,12 @@ end - line105 + line115 col3 file0 - line105 + line115 col8 file0 @@ -1981,7 +2093,7 @@ kindevent location - line105 + line115 col3 file0 @@ -1989,24 +2101,24 @@ - line105 + line115 col3 file0 - line105 + line115 col15 file0 - line105 + line115 col10 file0 - line105 + line115 col15 file0 @@ -2022,7 +2134,7 @@ kindevent location - line105 + line115 col3 file0 @@ -2030,12 +2142,12 @@ - line105 + line115 col3 file0 - line105 + line115 col15 file0 @@ -2059,7 +2171,7 @@ issue_hash_function_offset1 location - line105 + line115 col3 file0 @@ -2071,7 +2183,7 @@ kindevent location - line110 + line120 col20 file0 @@ -2079,12 +2191,12 @@ - line110 + line120 col20 file0 - line110 + line120 col32 file0 @@ -2104,12 +2216,12 @@ start - line110 + line120 col3 file0 - line110 + line120 col4 file0 @@ -2117,12 +2229,12 @@ end - line111 + line121 col3 file0 - line111 + line121 col8 file0 @@ -2134,7 +2246,7 @@ kindevent location - line111 + line121 col3 file0 @@ -2142,24 +2254,24 @@ - line111 + line121 col3 file0 - line111 + line121 col15 file0 - line111 + line121 col10 file0 - line111 + line121 col15 file0 @@ -2175,7 +2287,7 @@ kindevent location - line111 + line121 col3 file0 @@ -2183,12 +2295,12 @@ - line111 + line121 col3 file0 - line111 + line121 col15 file0 @@ -2212,7 +2324,7 @@ issue_hash_function_offset2 location - line111 + line121 col3 file0 @@ -2224,7 +2336,7 @@ kindevent location - line115 + line125 col15 file0 @@ -2232,12 +2344,12 @@ - line115 + line125 col15 file0 - line115 + line125 col18 file0 @@ -2257,12 +2369,12 @@ start - line115 + line125 col3 file0 - line115 + line125 col4 file0 @@ -2270,12 +2382,12 @@ end - line116 + line126 col3 file0 - line116 + line126 col8 file0 @@ -2287,7 +2399,7 @@ kindevent location - line116 + line126 col3 file0 @@ -2295,24 +2407,24 @@ - line116 + line126 col3 file0 - line116 + line126 col15 file0 - line116 + line126 col10 file0 - line116 + line126 col15 file0 @@ -2328,7 +2440,7 @@ kindevent location - line116 + line126 col3 file0 @@ -2336,12 +2448,12 @@ - line116 + line126 col3 file0 - line116 + line126 col15 file0 @@ -2365,7 +2477,7 @@ issue_hash_function_offset2 location - line116 + line126 col3 file0 @@ -2377,7 +2489,7 @@ kindevent location - line120 + line130 col15 file0 @@ -2385,12 +2497,12 @@ - line120 + line130 col15 file0 - line120 + line130 col18 file0 @@ -2410,12 +2522,12 @@ start - line120 + line130 col3 file0 - line120 + line130 col4 file0 @@ -2423,12 +2535,12 @@ end - line121 + line131 col3 file0 - line121 + line131 col8 file0 @@ -2440,7 +2552,7 @@ kindevent location - line121 + line131 col3 file0 @@ -2448,24 +2560,24 @@ - line121 + line131 col3 file0 - line121 + line131 col15 file0 - line121 + line131 col10 file0 - line121 + line131 col15 file0 @@ -2481,7 +2593,7 @@ kindevent location - line121 + line131 col3 file0 @@ -2489,12 +2601,12 @@ - line121 + line131 col3 file0 - line121 + line131 col15 file0 @@ -2518,7 +2630,7 @@ issue_hash_function_offset2 location - line121 + line131 col3 file0 @@ -2530,7 +2642,7 @@ kindevent location - line125 + line135 col15 file0 @@ -2538,12 +2650,12 @@ - line125 + line135 col15 file0 - line125 + line135 col32 file0 @@ -2563,12 +2675,12 @@ start - line125 + line135 col3 file0 - line125 + line135 col4 file0 @@ -2576,12 +2688,12 @@ end - line126 + line136 col3 file0 - line126 + line136 col8 file0 @@ -2593,7 +2705,7 @@ kindevent location - line126 + line136 col3 file0 @@ -2601,24 +2713,24 @@ - line126 + line136 col3 file0 - line126 + line136 col15 file0 - line126 + line136 col10 file0 - line126 + line136 col15 file0 @@ -2634,7 +2746,7 @@ kindevent location - line126 + line136 col3 file0 @@ -2642,12 +2754,12 @@ - line126 + line136 col3 file0 - line126 + line136 col15 file0 @@ -2671,7 +2783,7 @@ issue_hash_function_offset1 location - line126 + line136 col3 file0 @@ -2683,7 +2795,7 @@ kindevent location - line130 + line140 col15 file0 @@ -2691,12 +2803,12 @@ - line130 + line140 col15 file0 - line130 + line140 col32 file0 @@ -2716,12 +2828,12 @@ start - line130 + line140 col3 file0 - line130 + line140 col4 file0 @@ -2729,12 +2841,12 @@ end - line131 + line141 col3 file0 - line131 + line141 col3 file0 @@ -2746,7 +2858,7 @@ kindevent location - line131 + line141 col3 file0 @@ -2754,24 +2866,24 @@ - line131 + line141 col3 file0 - line131 + line141 col22 file0 - line131 + line141 col4 file0 - line131 + line141 col9 file0 @@ -2791,12 +2903,12 @@ start - line131 + line141 col3 file0 - line131 + line141 col3 file0 @@ -2804,12 +2916,12 @@ end - line132 + line142 col3 file0 - line132 + line142 col8 file0 @@ -2821,7 +2933,7 @@ kindevent location - line132 + line142 col3 file0 @@ -2829,12 +2941,12 @@ - line132 + line142 col3 file0 - line132 + line142 col15 file0 @@ -2858,7 +2970,7 @@ issue_hash_function_offset3 location - line132 + line142 col3 file0 @@ -2870,7 +2982,7 @@ kindevent location - line160 + line170 col15 file0 @@ -2878,12 +2990,12 @@ - line160 + line170 col15 file0 - line160 + line170 col16 file0 @@ -2903,12 +3015,12 @@ start - line160 + line170 col3 file0 - line160 + line170 col4 file0 @@ -2916,12 +3028,12 @@ end - line161 + line171 col3 file0 - line161 + line171 col3 file0 @@ -2933,7 +3045,7 @@ kindevent location - line161 + line171 col3 file0 @@ -2941,12 +3053,12 @@ - line161 + line171 col4 file0 - line161 + line171 col9 file0 @@ -2970,7 +3082,7 @@ issue_hash_function_offset2 location - line161 + line171 col3 file0 @@ -2982,7 +3094,7 @@ kindevent location - line165 + line175 col15 file0 @@ -2990,12 +3102,12 @@ - line165 + line175 col15 file0 - line165 + line175 col18 file0 @@ -3015,12 +3127,12 @@ start - line165 + line175 col3 file0 - line165 + line175 col4 file0 @@ -3028,12 +3140,12 @@ end - line166 + line176 col3 file0 - line166 + line176 col3 file0 @@ -3045,7 +3157,7 @@ kindevent location - line166 + line176 col3 file0 @@ -3053,12 +3165,12 @@ - line166 + line176 col4 file0 - line166 + line176 col9 file0 @@ -3082,7 +3194,7 @@ issue_hash_function_offset2 location - line166 + line176 col3 file0 @@ -3094,7 +3206,7 @@ kindevent location - line170 + line180 col15 file0 @@ -3102,12 +3214,12 @@ - line170 + line180 col15 file0 - line170 + line180 col20 file0 @@ -3127,12 +3239,12 @@ start - line170 + line180 col3 file0 - line170 + line180 col4 file0 @@ -3140,12 +3252,12 @@ end - line171 + line181 col3 file0 - line171 + line181 col3 file0 @@ -3157,7 +3269,7 @@ kindevent location - line171 + line181 col3 file0 @@ -3165,12 +3277,12 @@ - line171 + line181 col4 file0 - line171 + line181 col9 file0 @@ -3194,7 +3306,7 @@ issue_hash_function_offset2 location - line171 + line181 col3 file0 @@ -3206,7 +3318,7 @@ kindevent location - line175 + line185 col15 file0 @@ -3214,12 +3326,12 @@ - line175 + line185 col15 file0 - line175 + line185 col20 file0 @@ -3239,12 +3351,12 @@ start - line175 + line185 col3 file0 - line175 + line185 col4 file0 @@ -3252,12 +3364,12 @@ end - line176 + line186 col3 file0 - line176 + line186 col3 file0 @@ -3269,7 +3381,7 @@ kindevent location - line176 + line186 col3 file0 @@ -3277,12 +3389,12 @@ - line176 + line186 col4 file0 - line176 + line186 col9 file0 @@ -3306,7 +3418,7 @@ issue_hash_function_offset2 location - line176 + line186 col3 file0 @@ -3318,7 +3430,7 @@ kindevent location - line180 + line190 col15 file0 @@ -3326,12 +3438,12 @@ - line180 + line190 col15 file0 - line180 + line190 col27 file0 @@ -3351,12 +3463,12 @@ start - line180 + line190 col3 file0 - line180 + line190 col4 file0 @@ -3364,12 +3476,12 @@ end - line181 + line191 col3 file0 - line181 + line191 col3 file0 @@ -3381,7 +3493,7 @@ kindevent location - line181 + line191 col3 file0 @@ -3389,12 +3501,12 @@ - line181 + line191 col4 file0 - line181 + line191 col9 file0 @@ -3418,7 +3530,7 @@ issue_hash_function_offset2 location - line181 + line191 col3 file0 @@ -3434,12 +3546,12 @@ start - line216 + line226 col3 file0 - line216 + line226 col4 file0 @@ -3447,12 +3559,12 @@ end - line216 + line226 col11 file0 - line216 + line226 col11 file0 @@ -3464,7 +3576,7 @@ kindevent location - line216 + line226 col11 file0 @@ -3472,12 +3584,12 @@ - line216 + line226 col11 file0 - line216 + line226 col23 file0 @@ -3493,7 +3605,7 @@ kindevent location - line216 + line226 col10 file0 @@ -3501,12 +3613,12 @@ - line216 + line226 col10 file0 - line216 + line226 col30 file0 @@ -3522,7 +3634,7 @@ kindevent location - line196 + line206 col1 file0 @@ -3540,12 +3652,12 @@ start - line196 + line206 col1 file0 - line196 + line206 col1 file0 @@ -3553,12 +3665,12 @@ end - line197 + line207 col3 file0 - line197 + line207 col4 file0 @@ -3574,12 +3686,12 @@ start - line197 + line207 col3 file0 - line197 + line207 col4 file0 @@ -3587,12 +3699,12 @@ end - line197 + line207 col7 file0 - line197 + line207 col10 file0 @@ -3604,7 +3716,7 @@ kindevent location - line197 + line207 col7 file0 @@ -3612,12 +3724,12 @@ - line197 + line207 col7 file0 - line197 + line207 col10 file0 @@ -3637,12 +3749,12 @@ start - line197 + line207 col7 file0 - line197 + line207 col10 file0 @@ -3650,12 +3762,12 @@ end - line199 + line209 col5 file0 - line199 + line209 col10 file0 @@ -3667,7 +3779,7 @@ kindevent location - line216 + line226 col10 file0 @@ -3675,12 +3787,12 @@ - line216 + line226 col10 file0 - line216 + line226 col30 file0 @@ -3700,12 +3812,12 @@ start - line216 + line226 col10 file0 - line216 + line226 col10 file0 @@ -3713,12 +3825,12 @@ end - line216 + line226 col3 file0 - line216 + line226 col4 file0 @@ -3730,7 +3842,7 @@ kindevent location - line216 + line226 col3 file0 @@ -3738,12 +3850,12 @@ - line216 + line226 col3 file0 - line216 + line226 col6 file0 @@ -3767,7 +3879,7 @@ issue_hash_function_offset2 location - line216 + line226 col3 file0 @@ -3783,12 +3895,12 @@ start - line216 + line226 col3 file0 - line216 + line226 col4 file0 @@ -3796,12 +3908,12 @@ end - line222 + line232 col3 file0 - line222 + line232 col4 file0 @@ -3817,12 +3929,12 @@ start - line222 + line232 col3 file0 - line222 + line232 col4 file0 @@ -3830,12 +3942,12 @@ end - line222 + line232 col10 file0 - line222 + line232 col10 file0 @@ -3847,7 +3959,7 @@ kindevent location - line222 + line232 col10 file0 @@ -3855,12 +3967,12 @@ - line222 + line232 col10 file0 - line222 + line232 col30 file0 @@ -3876,7 +3988,7 @@ kindevent location - line204 + line214 col1 file0 @@ -3894,12 +4006,12 @@ start - line204 + line214 col1 file0 - line204 + line214 col1 file0 @@ -3907,12 +4019,12 @@ end - line205 + line215 col3 file0 - line205 + line215 col6 file0 @@ -3924,7 +4036,7 @@ kindevent location - line205 + line215 col10 file0 @@ -3932,12 +4044,12 @@ - line205 + line215 col10 file0 - line205 + line215 col21 file0 @@ -3957,12 +4069,12 @@ start - line205 + line215 col3 file0 - line205 + line215 col6 file0 @@ -3970,12 +4082,12 @@ end - line206 + line216 col3 file0 - line206 + line216 col8 file0 @@ -3987,7 +4099,7 @@ kindevent location - line222 + line232 col10 file0 @@ -3995,12 +4107,12 @@ - line222 + line232 col10 file0 - line222 + line232 col30 file0 @@ -4020,12 +4132,12 @@ start - line222 + line232 col10 file0 - line222 + line232 col10 file0 @@ -4033,12 +4145,12 @@ end - line222 + line232 col3 file0 - line222 + line232 col4 file0 @@ -4054,12 +4166,12 @@ start - line222 + line232 col3 file0 - line222 + line232 col4 file0 @@ -4067,12 +4179,12 @@ end - line227 + line237 col3 file0 - line227 + line237 col4 file0 @@ -4088,12 +4200,12 @@ start - line227 + line237 col3 file0 - line227 + line237 col4 file0 @@ -4101,12 +4213,12 @@ end - line227 + line237 col11 file0 - line227 + line237 col11 file0 @@ -4118,7 +4230,7 @@ kindevent location - line227 + line237 col11 file0 @@ -4126,12 +4238,12 @@ - line227 + line237 col11 file0 - line227 + line237 col23 file0 @@ -4155,7 +4267,7 @@ issue_hash_function_offset8 location - line227 + line237 col11 file0 @@ -4167,7 +4279,7 @@ kindevent location - line237 + line247 col22 file0 @@ -4175,12 +4287,12 @@ - line237 + line247 col22 file0 - line237 + line247 col40 file0 @@ -4200,12 +4312,12 @@ start - line237 + line247 col3 file0 - line237 + line247 col11 file0 @@ -4213,12 +4325,12 @@ end - line238 + line248 col3 file0 - line238 + line248 col15 file0 @@ -4230,7 +4342,7 @@ kindevent location - line238 + line248 col3 file0 @@ -4238,24 +4350,24 @@ - line238 + line248 col3 file0 - line238 + line248 col23 file0 - line238 + line248 col17 file0 - line238 + line248 col22 file0 @@ -4275,12 +4387,12 @@ start - line238 + line248 col3 file0 - line238 + line248 col15 file0 @@ -4288,12 +4400,12 @@ end - line239 + line249 col3 file0 - line239 + line249 col15 file0 @@ -4305,7 +4417,7 @@ kindevent location - line239 + line249 col3 file0 @@ -4313,24 +4425,24 @@ - line239 + line249 col3 file0 - line239 + line249 col23 file0 - line239 + line249 col17 file0 - line239 + line249 col22 file0 @@ -4350,12 +4462,12 @@ start - line239 + line249 col3 file0 - line239 + line249 col15 file0 @@ -4363,12 +4475,12 @@ end - line240 + line250 col3 file0 - line240 + line250 col8 file0 @@ -4380,7 +4492,7 @@ kindevent location - line240 + line250 col3 file0 @@ -4388,12 +4500,12 @@ - line240 + line250 col3 file0 - line240 + line250 col8 file0 @@ -4417,7 +4529,7 @@ issue_hash_function_offset4 location - line240 + line250 col3 file0 @@ -4429,7 +4541,7 @@ kindevent location - line244 + line254 col22 file0 @@ -4437,12 +4549,12 @@ - line244 + line254 col22 file0 - line244 + line254 col37 file0 @@ -4462,12 +4574,12 @@ start - line244 + line254 col3 file0 - line244 + line254 col11 file0 @@ -4475,12 +4587,12 @@ end - line245 + line255 col3 file0 - line245 + line255 col15 file0 @@ -4492,7 +4604,7 @@ kindevent location - line245 + line255 col3 file0 @@ -4500,24 +4612,24 @@ - line245 + line255 col3 file0 - line245 + line255 col23 file0 - line245 + line255 col17 file0 - line245 + line255 col22 file0 @@ -4537,12 +4649,12 @@ start - line245 + line255 col3 file0 - line245 + line255 col15 file0 @@ -4550,12 +4662,12 @@ end - line246 + line256 col3 file0 - line246 + line256 col8 file0 @@ -4567,7 +4679,7 @@ kindevent location - line246 + line256 col3 file0 @@ -4575,12 +4687,12 @@ - line246 + line256 col3 file0 - line246 + line256 col8 file0 @@ -4604,7 +4716,7 @@ issue_hash_function_offset3 location - line246 + line256 col3 file0 @@ -4616,7 +4728,7 @@ kindevent location - line250 + line260 col22 file0 @@ -4624,12 +4736,12 @@ - line250 + line260 col22 file0 - line250 + line260 col37 file0 @@ -4649,12 +4761,12 @@ start - line250 + line260 col3 file0 - line250 + line260 col11 file0 @@ -4662,12 +4774,12 @@ end - line251 + line261 col3 file0 - line251 + line261 col15 file0 @@ -4679,7 +4791,7 @@ kindevent location - line251 + line261 col3 file0 @@ -4687,24 +4799,24 @@ - line251 + line261 col3 file0 - line251 + line261 col23 file0 - line251 + line261 col17 file0 - line251 + line261 col22 file0 @@ -4724,12 +4836,12 @@ start - line251 + line261 col3 file0 - line251 + line261 col15 file0 @@ -4737,12 +4849,12 @@ end - line252 + line262 col3 file0 - line252 + line262 col3 file0 @@ -4754,7 +4866,7 @@ kindevent location - line252 + line262 col3 file0 @@ -4762,24 +4874,24 @@ - line252 + line262 col3 file0 - line252 + line262 col26 file0 - line252 + line262 col4 file0 - line252 + line262 col13 file0 @@ -4799,12 +4911,12 @@ start - line252 + line262 col3 file0 - line252 + line262 col3 file0 @@ -4812,12 +4924,12 @@ end - line253 + line263 col3 file0 - line253 + line263 col8 file0 @@ -4829,7 +4941,7 @@ kindevent location - line253 + line263 col3 file0 @@ -4837,12 +4949,12 @@ - line253 + line263 col3 file0 - line253 + line263 col8 file0 @@ -4866,7 +4978,7 @@ issue_hash_function_offset4 location - line253 + line263 col3 file0 Index: cfe/trunk/test/Analysis/retain-release-path-notes.m =================================================================== --- cfe/trunk/test/Analysis/retain-release-path-notes.m +++ cfe/trunk/test/Analysis/retain-release-path-notes.m @@ -36,6 +36,9 @@ void CFRelease(CFTypeRef); CFTypeRef CFAutorelease(CFTypeRef __attribute__((cf_consumed))); +id NSMakeCollectable(CFTypeRef); +CFTypeRef CFMakeCollectable(CFTypeRef); + CFTypeRef CFCreateSomething(); CFTypeRef CFGetSomething(); @@ -95,6 +98,13 @@ return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased but has a +0 retain count}} } +void makeCollectableIgnored() { + CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}} + CFMakeCollectable(leaked); + NSMakeCollectable(leaked); + return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}} +} + CFTypeRef CFCopyRuleViolation () { CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count}} return object; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} Index: cfe/trunk/test/Analysis/retain-release.m =================================================================== --- cfe/trunk/test/Analysis/retain-release.m +++ cfe/trunk/test/Analysis/retain-release.m @@ -318,6 +318,9 @@ + (id)array; @end +// This is how NSMakeCollectable is declared in the OS X 10.8 headers. +id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained)); + typedef const struct __CFUUID * CFUUIDRef; extern @@ -2073,6 +2076,16 @@ } } +id makeCollectableNonLeak() { + extern CFTypeRef CFCreateSomething(); + + CFTypeRef object = CFCreateSomething(); // +1 + CFRetain(object); // +2 + id objCObject = NSMakeCollectable(object); // +2 + [objCObject release]; // +1 + return [objCObject autorelease]; // +0 +} + void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void)); void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void));