the prefix should be ignored.
E.g. if ignorePrefix is true, "_init" and "init" selectors will both be result in InitRule, but if
ignorePrefix is false, only "init" will return InitRule.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123262
91177308-0d34-0410-b5e6-
96231b3b80d8
enum NamingConvention { NoConvention, CreateRule, InitRule };
- NamingConvention deriveNamingConvention(Selector S);
+ NamingConvention deriveNamingConvention(Selector S, bool ignorePrefix = true);
static inline bool followsFundamentalRule(Selector S) {
return deriveNamingConvention(S) == CreateRule;
return s;
}
-cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S) {
+cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S,
+ bool ignorePrefix) {
IdentifierInfo *II = S.getIdentifierInfoForSlot(0);
if (!II)
const char *s = II->getNameStart();
+ const char *orig = s;
// A method/function name may contain a prefix. We don't know it is there,
// however, until we encounter the first '_'.
while (*s != '\0') {
break;
}
+ if (!ignorePrefix && s != orig)
+ return NoConvention;
+
// Parse the first word, and look for specific keywords.
const char *wordEnd = parseWord(s);
assert(wordEnd > s);