r186981 - ObjC migrator: Define family of methods
Fariborz Jahanian
fjahanian at apple.com
Tue Jul 23 12:31:18 PDT 2013
Author: fjahanian
Date: Tue Jul 23 14:31:17 2013
New Revision: 186981
URL: http://llvm.org/viewvc/llvm-project?rev=186981&view=rev
Log:
ObjC migrator: Define family of methods
which are candidate for migrating to
'instancetype'. wip.
Modified:
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/lib/Basic/IdentifierTable.cpp
Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=186981&r1=186980&r2=186981&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Tue Jul 23 14:31:17 2013
@@ -578,6 +578,20 @@ enum { ObjCMethodFamilyBitWidth = 4 };
/// \brief An invalid value of ObjCMethodFamily.
enum { InvalidObjCMethodFamily = (1 << ObjCMethodFamilyBitWidth) - 1 };
+/// \brief A family of Objective-C methods.
+///
+/// These are family of methods whose result type is initially 'id', but
+/// but are candidate for the result type to be changed to 'instancetype'.
+enum ObjCInstanceTypeFamily {
+ OIT_None,
+ OIT_Array,
+ OIT_Dictionary,
+ OIT_MemManage,
+ OIT_NSString,
+ OIT_NSSet,
+ OIT_NSURL
+};
+
/// \brief Smart pointer class that efficiently represents Objective-C method
/// names.
///
@@ -623,6 +637,8 @@ class Selector {
}
static ObjCMethodFamily getMethodFamilyImpl(Selector sel);
+
+ static ObjCInstanceTypeFamily getInstTypeMethodFamilyImpl(Selector sel);
public:
friend class SelectorTable; // only the SelectorTable can create these
Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=186981&r1=186980&r2=186981&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Tue Jul 23 14:31:17 2013
@@ -452,6 +452,39 @@ ObjCMethodFamily Selector::getMethodFami
return OMF_None;
}
+ObjCInstanceTypeFamily Selector::getInstTypeMethodFamilyImpl(Selector sel) {
+ IdentifierInfo *first = sel.getIdentifierInfoForSlot(0);
+ if (!first) return OIT_None;
+
+ StringRef name = first->getName();
+
+ if (name.empty()) return OIT_None;
+ switch (name.front()) {
+ case 'a':
+ if (startsWithWord(name, "alloc")) return OIT_MemManage;
+ else
+ if (startsWithWord(name, "array")) return OIT_Array;
+ break;
+ case 'd':
+ if (startsWithWord(name, "dictionary")) return OIT_Dictionary;
+ break;
+ case 'i':
+ if (startsWithWord(name, "init")) return OIT_MemManage;
+ break;
+ case 's':
+ if (startsWithWord(name, "string")) return OIT_NSString;
+ else
+ if (startsWithWord(name, "set")) return OIT_NSSet;
+ break;
+ case 'U':
+ if (startsWithWord(name, "URL")) return OIT_NSURL;
+ break;
+ default:
+ break;
+ }
+ return OIT_None;
+}
+
namespace {
struct SelectorTableImpl {
llvm::FoldingSet<MultiKeywordSelector> Table;
More information about the cfe-commits
mailing list