New AST representation for each objc2's property declaration.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49699 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 6e348ca..7a99f0f 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -111,9 +111,10 @@
 
 ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C,
                                            SourceLocation L,
+                                           IdentifierInfo *Id,
                                            QualType T) {
   void *Mem = C.getAllocator().Allocate<ObjCPropertyDecl>();
-  return new (Mem) ObjCPropertyDecl(L, T);
+  return new (Mem) ObjCPropertyDecl(L, Id, T);
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index cc57bdc..ec40e36 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -248,7 +248,32 @@
         if (contextKey != tok::objc_protocol)
           Diag(AtLoc, diag::err_objc_protocol_optional);
       } else if (ocKind == tok::objc_property) {
-        allProperties.push_back(ParseObjCPropertyDecl(interfaceDecl, AtLoc));
+        ObjCDeclSpec OCDS;
+        ConsumeToken(); // the "property" identifier
+        // Parse property attribute list, if any. 
+        if (Tok.is(tok::l_paren)) {
+          // property has attribute list.
+          ParseObjCPropertyAttribute(OCDS);
+        }
+        // Parse all the comma separated declarators.
+        DeclSpec DS;
+        llvm::SmallVector<FieldDeclarator, 8> FieldDeclarators;
+        ParseStructDeclaration(DS, FieldDeclarators);
+        
+        if (Tok.is(tok::semi)) 
+          ConsumeToken();
+        else {
+          Diag(Tok, diag::err_expected_semi_decl_list);
+          SkipUntil(tok::r_brace, true, true);
+        }
+        // Convert them all to property declarations.
+        for (unsigned i = 0, e = FieldDeclarators.size(); i != e; ++i) {
+          FieldDeclarator &FD = FieldDeclarators[i];
+          // Install the property declarator into interfaceDecl.
+          DeclTy *Property = Actions.ActOnProperty(CurScope,
+                               DS.getSourceRange().getBegin(), FD, OCDS);
+          allProperties.push_back(Property);
+        }
         continue;
       } else {
         Diag(Tok, diag::err_objc_illegal_interface_qual);
@@ -370,39 +395,6 @@
   }
 }
 
-///   Main routine to parse property declaration.
-///
-///   @property property-attr-decl[opt] property-component-decl ';'
-///
-Parser::DeclTy *Parser::ParseObjCPropertyDecl(DeclTy *interfaceDecl, 
-                                              SourceLocation AtLoc) {
-  assert(Tok.isObjCAtKeyword(tok::objc_property) &&
-         "ParseObjCPropertyDecl(): Expected @property");
-  ObjCDeclSpec OCDS;
-  ConsumeToken(); // the "property" identifier
-  // Parse property attribute list, if any. 
-  if (Tok.is(tok::l_paren)) {
-    // property has attribute list.
-    ParseObjCPropertyAttribute(OCDS);
-  }
-  // Parse declaration portion of @property.
-  llvm::SmallVector<DeclTy*, 8> PropertyDecls;
-  
-  // Parse all the comma separated declarators.
-  DeclSpec DS;
-  llvm::SmallVector<FieldDeclarator, 8> FieldDeclarators;
-  ParseStructDeclaration(DS, FieldDeclarators);
-    
-  if (Tok.is(tok::semi)) 
-    ConsumeToken();
-  else {
-    Diag(Tok, diag::err_expected_semi_decl_list);
-    SkipUntil(tok::r_brace, true, true);
-  }
-  return Actions.ActOnAddObjCProperties(CurScope, AtLoc, &FieldDeclarators[0],
-                                        FieldDeclarators.size(), OCDS);
-}
-
 ///   objc-method-proto:
 ///     objc-instance-method objc-method-decl objc-method-attributes[opt] 
 ///     objc-class-method objc-method-decl objc-method-attributes[opt]
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 7b30573..50842f7 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -655,10 +655,8 @@
                       DeclTy **allMethods = 0, unsigned allNum = 0,
                       DeclTy **allProperties = 0, unsigned pNum = 0);
   
-  virtual DeclTy *ActOnAddObjCProperties(Scope *S, SourceLocation AtLoc, 
-                                         FieldDeclarator *allProperties,
-                                         unsigned NumProperties,
-                                         ObjCDeclSpec &ODS);  
+  virtual DeclTy *ActOnProperty(Scope *S, SourceLocation AtLoc,
+                                FieldDeclarator &FD, ObjCDeclSpec &ODS);  
   virtual DeclTy *ActOnMethodDeclaration(
     SourceLocation BeginLoc, // location of the + or -.
     SourceLocation EndLoc,   // location of the ; or {.
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 7eb132e..bf9af85 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -886,13 +886,12 @@
   return ObjCMethod;
 }
 
-Sema::DeclTy *Sema::ActOnAddObjCProperties(Scope *S, SourceLocation AtLoc, 
-                                           FieldDeclarator *propertyDeclarators,
-                                           unsigned NumPropertyDeclarators, 
-                                           ObjCDeclSpec &ODS) {
-  FieldDeclarator &FD = propertyDeclarators[0];
+Sema::DeclTy *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, 
+                                  FieldDeclarator &FD,
+                                  ObjCDeclSpec &ODS) {
   QualType T = GetTypeForDeclarator(FD.D, S);
-  ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, AtLoc, T);
+  ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, AtLoc, 
+                                                     FD.D.getIdentifier(), T);
   
   if (ODS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_readonly)
     PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readonly);
@@ -922,16 +921,6 @@
   if (ODS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nonatomic)
     PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_nonatomic);
   
-  if (NumPropertyDeclarators != 0) {
-    NamedDecl **propertyName = new NamedDecl*[NumPropertyDeclarators];
-    PDecl->setPropertyDecls(propertyName);
-    PDecl->setNumPropertyDecls(NumPropertyDeclarators);
-    for (unsigned i = 0; i < NumPropertyDeclarators; i++) {
-      Declarator &D = propertyDeclarators[i].D;
-      propertyName[i] = new NamedDecl(Decl::ObjCProperty, 
-                                      D.getIdentifierLoc(), D.getIdentifier());
-    }
-  }
   return PDecl;
 }