From 97bbab2df74cbfe221fb20454738d607a41f3ca4 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 21 Dec 2011 19:48:07 +0000 Subject: [PATCH] objc, objc rewriter. Fixes couple of bugs one because of recent refactoring and one in the rewriter. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147070 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclObjC.h | 5 +++-- lib/Rewrite/RewriteObjC.cpp | 4 ++-- test/Rewriter/rewrite-implementation.mm | 3 +++ test/Rewriter/rewrite-super-message.mm | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 8cc6e7374d..a6f60f383e 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -898,8 +898,9 @@ public: /// isImplicitInterfaceDecl - check that this is an implicitly declared /// ObjCInterfaceDecl node. This is for legacy objective-c @implementation /// declaration without an @interface declaration. - bool isImplicitInterfaceDecl() const { return isImplicit(); } - void setImplicitInterfaceDecl(bool val) { setImplicit(val); } + bool isImplicitInterfaceDecl() const { + return hasDefinition() ? Data->Definition->isImplicit() : isImplicit(); + } /// ClassImplementsProtocol - Checks that 'lProto' protocol /// has been implemented in IDecl class, its super class or categories (if diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index 8fa1e83340..57acba3de0 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -2478,7 +2478,7 @@ void RewriteObjC::SynthGetSuperClassFunctionDecl() { false); } -// SynthGetMetaClassFunctionDecl - id objc_getClass(const char *name); +// SynthGetMetaClassFunctionDecl - id objc_getMetaClass(const char *name); void RewriteObjC::SynthGetMetaClassFunctionDecl() { IdentifierInfo *getClassIdent = &Context->Idents.get("objc_getMetaClass"); SmallVector ArgTys; @@ -2673,7 +2673,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // (Class)objc_getClass("CurrentClass") CastExpr *ArgExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCClassType(), - CK_CPointerToObjCPointerCast, Cls); + CK_BitCast, Cls); ClsExprs.clear(); ClsExprs.push_back(ArgExpr); Cls = SynthesizeCallToFunctionDecl(GetSuperClassFunctionDecl, diff --git a/test/Rewriter/rewrite-implementation.mm b/test/Rewriter/rewrite-implementation.mm index c1d89a3c36..afe0f9718a 100644 --- a/test/Rewriter/rewrite-implementation.mm +++ b/test/Rewriter/rewrite-implementation.mm @@ -11,3 +11,6 @@ @implementation b @end +@interface NSArray @end +@class NSArray; +@implementation NSArray @end diff --git a/test/Rewriter/rewrite-super-message.mm b/test/Rewriter/rewrite-super-message.mm index be0a963c55..2def280834 100644 --- a/test/Rewriter/rewrite-super-message.mm +++ b/test/Rewriter/rewrite-super-message.mm @@ -18,3 +18,21 @@ void *sel_registerName(const char *); @end // CHECK: call %struct.objc_class* @class_getSuperclass + +@class NSZone; + +@interface NSObject { +} + ++ (id)allocWithZone:(NSZone *)zone; +@end + + +@interface NSArray : NSObject +@end + +@implementation NSArray ++ (id)allocWithZone:(NSZone *)zone { + return [super allocWithZone:zone]; +} +@end -- 2.50.1