return s;
}
-static NamingConvention deriveNamingConvention(const char* s) {
+static NamingConvention deriveNamingConvention(Selector S) {
+ IdentifierInfo *II = S.getIdentifierInfoForSlot(0);
+
+ if (!II)
+ return NoConvention;
+
+ const char *s = II->getName();
+
// A method/function name may contain a prefix. We don't know it is there,
// however, until we encounter the first '_'.
bool InPossiblePrefix = true;
return C;
}
-static bool followsFundamentalRule(const char* s) {
- return deriveNamingConvention(s) == CreateRule;
+static bool followsFundamentalRule(Selector S) {
+ return deriveNamingConvention(S) == CreateRule;
}
static const ObjCMethodDecl*
if (isTrackedObjCObjectType(RetTy)) {
// EXPERIMENTAL: Assume the Cocoa conventions for all objects returned
// by instance methods.
- RetEffect E =
- followsFundamentalRule(S.getIdentifierInfoForSlot(0)->getName())
- ? ObjCAllocRetE : RetEffect::MakeNotOwned(RetEffect::ObjC);
+ RetEffect E = followsFundamentalRule(S)
+ ? ObjCAllocRetE : RetEffect::MakeNotOwned(RetEffect::ObjC);
return getPersistentSummary(E, ReceiverEff, MayEscape);
}
// Look for methods that return an owned core foundation object.
if (isTrackedCFObjectType(RetTy)) {
- RetEffect E =
- followsFundamentalRule(S.getIdentifierInfoForSlot(0)->getName())
- ? RetEffect::MakeOwned(RetEffect::CF, true)
- : RetEffect::MakeNotOwned(RetEffect::CF);
+ RetEffect E = followsFundamentalRule(S)
+ ? RetEffect::MakeOwned(RetEffect::CF, true)
+ : RetEffect::MakeNotOwned(RetEffect::CF);
return getPersistentSummary(E, ReceiverEff, MayEscape);
}
RetainSummary *Summ = 0;
// "initXXX": pass-through for receiver.
- if (deriveNamingConvention(S.getIdentifierInfoForSlot(0)->getName())
- == InitRule)
+ if (deriveNamingConvention(S) == InitRule)
Summ = getInitMethodSummary(RetTy);
else
Summ = getCommonMethodSummary(MD, S, RetTy);
[NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning
}
+//===----------------------------------------------------------------------===//
+// Method name that has a null IdentifierInfo* for its first selector slot.
+// This test just makes sure that we handle it.
+//===----------------------------------------------------------------------===//
+
+@interface TestNullIdentifier
+@end
+
+@implementation TestNullIdentifier
++ (id):(int)x, ... {
+ return [[NSString alloc] init]; // expected-warning{{leak}}
+}
+
//===----------------------------------------------------------------------===//
// Tests of ownership attributes.
//===----------------------------------------------------------------------===//