r188303 - ObjectiveC migrator: Fixes a crash and makes couple
Fariborz Jahanian
fjahanian at apple.com
Tue Aug 13 11:01:43 PDT 2013
Author: fjahanian
Date: Tue Aug 13 13:01:42 2013
New Revision: 188303
URL: http://llvm.org/viewvc/llvm-project?rev=188303&view=rev
Log:
ObjectiveC migrator: Fixes a crash and makes couple
of harmless changes.
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/test/ARCMT/objcmt-instancetype-2.m
cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=188303&r1=188302&r2=188303&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Tue Aug 13 13:01:42 2013
@@ -46,9 +46,11 @@ class ObjCMigrateASTConsumer : public AS
ObjCMethodDecl *OM,
ObjCInstanceTypeFamily OIT_Family = OIT_None);
- void migrateFunctionDeclAnnotation(ASTContext &Ctx, FunctionDecl *FuncDecl);
+ void migrateFunctionDeclAnnotation(ASTContext &Ctx,
+ const FunctionDecl *FuncDecl);
- void migrateObjCMethodDeclAnnotation(ASTContext &Ctx, ObjCMethodDecl *MethodDecl);
+ void migrateObjCMethodDeclAnnotation(ASTContext &Ctx,
+ const ObjCMethodDecl *MethodDecl);
public:
std::string MigrateDir;
bool MigrateLiterals;
@@ -713,6 +715,10 @@ void ObjCMigrateASTConsumer::migrateFact
LoweredClassName = StringLoweredClassName;
IdentifierInfo *MethodIdName = OM->getSelector().getIdentifierInfoForSlot(0);
+ // Handle method with no name at its first selector slot; e.g. + (id):(int)x.
+ if (!MethodIdName)
+ return;
+
std::string MethodName = MethodIdName->getName();
if (OIT_Family == OIT_Singleton) {
StringRef STRefMethodName(MethodName);
@@ -745,19 +751,21 @@ void ObjCMigrateASTConsumer::migrateFact
void ObjCMigrateASTConsumer::migrateFunctionDeclAnnotation(
ASTContext &Ctx,
- FunctionDecl *FuncDecl) {
+ const FunctionDecl *FuncDecl) {
if (FuncDecl->hasAttr<CFAuditedTransferAttr>() ||
FuncDecl->getAttr<CFReturnsRetainedAttr>() ||
- FuncDecl->getAttr<CFReturnsNotRetainedAttr>())
+ FuncDecl->getAttr<CFReturnsNotRetainedAttr>() ||
+ FuncDecl->hasBody())
return;
}
void ObjCMigrateASTConsumer::migrateObjCMethodDeclAnnotation(
ASTContext &Ctx,
- ObjCMethodDecl *MethodDecl) {
+ const ObjCMethodDecl *MethodDecl) {
if (MethodDecl->hasAttr<CFAuditedTransferAttr>() ||
MethodDecl->getAttr<CFReturnsRetainedAttr>() ||
- MethodDecl->getAttr<CFReturnsNotRetainedAttr>())
+ MethodDecl->getAttr<CFReturnsNotRetainedAttr>() ||
+ MethodDecl->hasBody())
return;
}
@@ -799,6 +807,11 @@ void ObjCMigrateASTConsumer::HandleTrans
if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(*N))
migrateNSEnumDecl(Ctx, ED, TD);
}
+ else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*D))
+ migrateFunctionDeclAnnotation(Ctx, FD);
+ else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*D))
+ migrateObjCMethodDeclAnnotation(Ctx, MD);
+
// migrate methods which can have instancetype as their result type.
if (ObjCContainerDecl *CDecl = dyn_cast<ObjCContainerDecl>(*D))
migrateInstanceType(Ctx, CDecl);
Modified: cfe/trunk/test/ARCMT/objcmt-instancetype-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-instancetype-2.m?rev=188303&r1=188302&r2=188303&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-instancetype-2.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-instancetype-2.m Tue Aug 13 13:01:42 2013
@@ -85,3 +85,17 @@ typedef enum NSURLBookmarkResolutionOpti
@interface UIApplication
+ (id)sharedApplication;
@end
+
+//===----------------------------------------------------------------------===//
+// Method name that has a null IdentifierInfo* for its first selector slot.
+// This test just makes sure that we handle it.
+//===----------------------------------------------------------------------===//
+ at interface TestNullIdentifier
+ at end
+
+ at implementation TestNullIdentifier
++ (id):(int)x, ... {
+ return 0;
+}
+ at end
+
Modified: cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result?rev=188303&r1=188302&r2=188303&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-instancetype-2.m.result Tue Aug 13 13:01:42 2013
@@ -85,3 +85,17 @@ typedef enum NSURLBookmarkResolutionOpti
@interface UIApplication
+ (instancetype)sharedApplication;
@end
+
+//===----------------------------------------------------------------------===//
+// Method name that has a null IdentifierInfo* for its first selector slot.
+// This test just makes sure that we handle it.
+//===----------------------------------------------------------------------===//
+ at interface TestNullIdentifier
+ at end
+
+ at implementation TestNullIdentifier
++ (id):(int)x, ... {
+ return 0;
+}
+ at end
+
More information about the cfe-commits
mailing list