]> granicus.if.org Git - clang/commitdiff
Synthesized getter/setter method declarations need not have
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 7 May 2008 20:53:44 +0000 (20:53 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 7 May 2008 20:53:44 +0000 (20:53 +0000)
an implementation. This fixes couple of failing prperty tests
caused by my previous patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50830 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp
lib/Sema/SemaDeclObjC.cpp

index 9079445f3a9c80273b6cfb9b06a2743529e812c3..1255c179256f1aa72f0f1fb8d4cd12cc0a896e63 100644 (file)
@@ -59,6 +59,9 @@ private:
   bool IsInstance : 1;
   bool IsVariadic : 1;
   
+  // Synthesized declaration method for a property setter/getter
+  bool IsSynthesized : 1;
+  
   // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
   /// @required/@optional
   unsigned DeclImplementation : 2;
@@ -95,10 +98,12 @@ private:
                  Decl *contextDecl,
                  AttributeList *M = 0, bool isInstance = true,
                  bool isVariadic = false,
+                 bool isSynthesized = false,
                  ImplementationControl impControl = None)
   : Decl(ObjCMethod, beginLoc),
     DeclContext(ObjCMethod),
     IsInstance(isInstance), IsVariadic(isVariadic),
+    IsSynthesized(isSynthesized),
     DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
     MethodContext(static_cast<NamedDecl*>(contextDecl)),
     SelName(SelInfo), MethodDeclType(T), 
@@ -113,6 +118,7 @@ public:
                                 QualType T, Decl *contextDecl,
                                 AttributeList *M = 0, bool isInstance = true,
                                 bool isVariadic = false,
+                                bool isSynthesized = false,
                                 ImplementationControl impControl = None);
   
   ObjCDeclQualifier getObjCDeclQualifier() const {
@@ -158,6 +164,8 @@ public:
   bool isInstance() const { return IsInstance; }
   bool isVariadic() const { return IsVariadic; }
   
+  bool isSynthesized() const { return IsSynthesized; }
+  
   // Related to protocols declared in  @protocol
   void setDeclImplementation(ImplementationControl ic) { 
     DeclImplementation = ic; 
index 3c89a6aa7df20a6d3eecad21795c9438422e6943..cda73d2ff9cdb0c2c579225c4b662fb971274a77 100644 (file)
@@ -26,12 +26,13 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
                                        Decl *contextDecl,
                                        AttributeList *M, bool isInstance,
                                        bool isVariadic,
+                                       bool isSynthesized,
                                        ImplementationControl impControl) {
   void *Mem = C.getAllocator().Allocate<ObjCMethodDecl>();
   return new (Mem) ObjCMethodDecl(beginLoc, endLoc,
                                   SelInfo, T, contextDecl,
                                   M, isInstance, 
-                                  isVariadic, impControl);
+                                  isVariadic, isSynthesized, impControl);
 }
 
 ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C,
@@ -294,7 +295,7 @@ void ObjCInterfaceDecl::addPropertyMethods(
                            property->getLocation(), 
                            property->getGetterName(), resultDeclType,
                            this, 0,
-                           true, false, ObjCMethodDecl::Required);
+                           true, false, true, ObjCMethodDecl::Required);
     property->setGetterMethodDecl(ObjCMethod);
     insMethods.push_back(ObjCMethod);
   }
index 96710cc20c1e5c6577152370e64e132221900117..a0fa6ecb2bc2a5b4295bc306439ead541443fcf2 100644 (file)
@@ -636,7 +636,7 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplementationDecl* IMPDecl,
   bool IncompleteImpl = false;
   for (ObjCInterfaceDecl::instmeth_iterator I = IDecl->instmeth_begin(),
        E = IDecl->instmeth_end(); I != E; ++I)
-    if (!InsMap.count((*I)->getSelector()))
+    if (!(*I)->isSynthesized() && !InsMap.count((*I)->getSelector()))
       WarnUndefinedMethod(IMPDecl->getLocation(), *I, IncompleteImpl);
       
   llvm::DenseSet<Selector> ClsMap;
@@ -964,6 +964,7 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
     ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType,
                            ClassDecl, AttrList, 
                            MethodType == tok::minus, isVariadic,
+                           false,
                            MethodDeclKind == tok::objc_optional ? 
                            ObjCMethodDecl::Optional : 
                            ObjCMethodDecl::Required);