// because the reference count is quite possibly handled by a delegate
// method.
if (S.isKeywordSelector()) {
- const std::string &str = S.getAsString();
- assert(!str.empty());
- if (StrInStrNoCase(str, "delegate:") != StringRef::npos)
- ReceiverEff = StopTracking;
+ for (unsigned i = 0, e = S.getNumArgs(); i != e; ++i) {
+ StringRef Slot = S.getNameForSlot(i);
+ if (Slot.substr(Slot.size() - 8).equals_lower("delegate")) {
+ if (ResultEff == ObjCInitRetE)
+ ResultEff = RetEffect::MakeNoRet();
+ else
+ ReceiverEff = StopTracking;
+ }
+ }
}
if (ScratchArgs.isEmpty() && ReceiverEff == DoNothing &&
}
@end
+
+@interface ObjectThatRequiresDelegate : NSObject
+- (id)initWithDelegate:(id)delegate;
+- (id)initWithNumber:(int)num delegate:(id)delegate;
+@end
+
+
+@interface DelegateRequirerTest
+@end
+@implementation DelegateRequirerTest
+
+- (void)test {
+ (void)[[ObjectThatRequiresDelegate alloc] initWithDelegate:self];
+ (void)[[ObjectThatRequiresDelegate alloc] initWithNumber:0 delegate:self];
+ // no leak warnings -- these objects could be released in callback methods
+}
+
+@end