aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-12-21 19:48:07 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-12-21 19:48:07 +0000
commit97bbab2df74cbfe221fb20454738d607a41f3ca4 (patch)
tree7877a2eb2971c411d6c86154b9b3c78eba9b9935
parent3b7a48fbc681c6fb59e5304a210c30dbb49dabea (diff)
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
-rw-r--r--include/clang/AST/DeclObjC.h5
-rw-r--r--lib/Rewrite/RewriteObjC.cpp4
-rw-r--r--test/Rewriter/rewrite-implementation.mm3
-rw-r--r--test/Rewriter/rewrite-super-message.mm18
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<QualType, 16> 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