[analyzer] Add 'bool ignorePrefix' parameter to cocoa::deriveNamingConvention to control whether

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.

llvm-svn: 123262
This commit is contained in:
Argyrios Kyrtzidis
2011-01-11 19:45:16 +00:00
parent 1790c975e7
commit 52f04650ae
2 changed files with 7 additions and 2 deletions

View File

@@ -54,7 +54,8 @@ static const char* parseWord(const char* s) {
return s;
}
cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S) {
cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S,
bool ignorePrefix) {
IdentifierInfo *II = S.getIdentifierInfoForSlot(0);
if (!II)
@@ -62,6 +63,7 @@ cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S) {
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') {
@@ -73,6 +75,9 @@ cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S) {
break;
}
if (!ignorePrefix && s != orig)
return NoConvention;
// Parse the first word, and look for specific keywords.
const char *wordEnd = parseWord(s);
assert(wordEnd > s);