diff options
-rw-r--r-- | lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp | 5 | ||||
-rw-r--r-- | test/Analysis/retain-release.m | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 93a77f440b..6710bfd3a5 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -1145,6 +1145,11 @@ RetainSummaryManager::getFunctionSummary(const FunctionDecl *FD) { break; if (RetTy->isPointerType()) { + if (FD->getAttr<CFAuditedTransferAttr>()) { + S = getCFCreateGetRuleSummary(FD); + break; + } + // For CoreFoundation ('CF') types. if (cocoa::isRefType(RetTy, "CF", FName)) { if (isRetain(FD, FName)) diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index da1477bb58..4280d69ba5 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -1885,3 +1885,16 @@ void testCFConsumeAndStopTracking() { id unretained = @[]; // +0 CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} } +//===----------------------------------------------------------------------===// +// Test 'pragma clang arc_cf_code_audited' support. +//===----------------------------------------------------------------------===// + +typedef void *MyCFType; +#pragma clang arc_cf_code_audited begin +MyCFType CreateMyCFType(); +#pragma clang arc_cf_code_audited end + +void test_custom_cf() { + MyCFType x = CreateMyCFType(); // expected-warning {{leak of an object stored into 'x'}} +} + |