mirror of
https://github.com/intel/llvm.git
synced 2026-02-07 16:11:27 +08:00
Fix <rdar://problem/7033733>. The CF_RETURNS_RETAINED attribute should work if the return type on an Objective-C method is a CF type reference, not just an Objective-C object reference.
llvm-svn: 74841
This commit is contained in:
@@ -1267,15 +1267,23 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
|
||||
if (!MD)
|
||||
return;
|
||||
|
||||
bool isTrackedLoc = false;
|
||||
|
||||
// Determine if there is a special return effect for this method.
|
||||
if (isTrackedObjCObjectType(MD->getResultType())) {
|
||||
if (MD->getAttr<NSReturnsRetainedAttr>()) {
|
||||
Summ.setRetEffect(ObjCAllocRetE);
|
||||
return;
|
||||
}
|
||||
else if (MD->getAttr<CFReturnsRetainedAttr>()) {
|
||||
Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
|
||||
}
|
||||
|
||||
isTrackedLoc = true;
|
||||
}
|
||||
|
||||
if (!isTrackedLoc)
|
||||
isTrackedLoc = MD->getResultType()->getAsPointerType() != NULL;
|
||||
|
||||
if (isTrackedLoc && MD->getAttr<CFReturnsRetainedAttr>())
|
||||
Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
|
||||
}
|
||||
|
||||
RetainSummary*
|
||||
|
||||
@@ -815,7 +815,9 @@ void test_attr_1b(TestOwnershipAttr *X) {
|
||||
|
||||
@interface MyClassTestCFAttr : NSObject {}
|
||||
- (NSDate*) returnsCFRetained __attribute__((cf_returns_retained));
|
||||
- (CFDateRef) returnsCFRetainedAsCF __attribute__((cf_returns_retained));
|
||||
- (NSDate*) alsoReturnsRetained;
|
||||
- (CFDateRef) alsoReturnsRetainedAsCF;
|
||||
- (NSDate*) returnsNSRetained __attribute__((ns_returns_retained));
|
||||
@end
|
||||
|
||||
@@ -829,10 +831,20 @@ CFDateRef returnsRetainedCFDate() {
|
||||
return (NSDate*) returnsRetainedCFDate(); // No leak.
|
||||
}
|
||||
|
||||
- (CFDateRef) returnsCFRetainedAsCF {
|
||||
return returnsRetainedCFDate(); // No leak.
|
||||
}
|
||||
|
||||
|
||||
- (NSDate*) alsoReturnsRetained {
|
||||
return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}}
|
||||
}
|
||||
|
||||
- (CFDateRef) alsoReturnsRetainedAsCF {
|
||||
return returnsRetainedCFDate(); // expected-warning{{leak}}
|
||||
}
|
||||
|
||||
|
||||
- (NSDate*) returnsNSRetained {
|
||||
return (NSDate*) returnsRetainedCFDate(); // no-warning
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user