diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-11 19:45:16 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-11 19:45:16 +0000 |
commit | 5078d46af381b27be1c7e3c3e0c517e4cf7cc064 (patch) | |
tree | 0896e5f2adec7426f5b14bd83e997a1d0c3e3607 /lib/Analysis/CocoaConventions.cpp | |
parent | f7fbbda62705352a53ac3b495a1128946a34ced3 (diff) |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123262 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CocoaConventions.cpp')
-rw-r--r-- | lib/Analysis/CocoaConventions.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Analysis/CocoaConventions.cpp b/lib/Analysis/CocoaConventions.cpp index 2c263cadad..422652544d 100644 --- a/lib/Analysis/CocoaConventions.cpp +++ b/lib/Analysis/CocoaConventions.cpp @@ -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); |