]> granicus.if.org Git - clang/commitdiff
Patch to store ivars into interface class object.
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 14 Sep 2007 21:08:27 +0000 (21:08 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 14 Sep 2007 21:08:27 +0000 (21:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41961 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Decl.cpp
Parse/ParseObjc.cpp
Sema/Sema.h
Sema/SemaDecl.cpp
clang.xcodeproj/project.pbxproj
include/clang/AST/Decl.h
include/clang/Parse/Action.h

index 4b668c268637e73435d1f48b9ef951f8ca90c09a..965ba2180a46b6dd5f7d2b70a29ba938b6cbea2b 100644 (file)
@@ -186,6 +186,18 @@ ObjcMethodDecl::~ObjcMethodDecl() {
   delete[] ParamInfo;
 }
 
+/// ObjcAddInstanceVariablesToClass - Inserts instance variables
+/// into ObjcInterfaceDecl's fields.
+///
+void ObjcInterfaceDecl::ObjcAddInstanceVariablesToClass(ObjcIvarDecl **ivars,
+                                                       unsigned numIvars) {
+  NumIvars = numIvars;
+  if (numIvars) {
+    Ivars = new ObjcIvarDecl*[numIvars];
+    memcpy(Ivars, ivars, numIvars*sizeof(ObjcIvarDecl*));
+  }
+}
+
 /// addObjcMethods - Insert instance and methods declarations into
 /// ObjcInterfaceDecl's InsMethods and ClsMethods fields.
 ///
index 22b3985ef003a6d40ea355eddaadc720642809df..29f8001c13527f50b43bf6141dc2faaa76188fa9 100644 (file)
@@ -659,7 +659,7 @@ void Parser::ParseObjCClassInstanceVariables(DeclTy *interfaceDecl) {
     }
   }
   if (AllIvarDecls.size()) {  // Check for {} - no ivars in braces
-    Actions.ObjcAddInstanceVariable(interfaceDecl, 
+    Actions.ObjcAddVisibilityToIvars(interfaceDecl, 
              &AllIvarDecls[0], AllIvarDecls.size(), &AllVisibilities[0]);
     Actions.ParseRecordBody(LBraceLoc, interfaceDecl, 
                            &AllIvarDecls[0], AllIvarDecls.size());
index 1e74321fd9e01bc6ad2c9cc2c41d2b7b3813b4d6..2b50f5e354f7759669a099e6166378a149adc8d7 100644 (file)
@@ -369,9 +369,9 @@ public:
                    tok::TokenKind MethodType, TypeTy *ReturnType,
                    IdentifierInfo *SelectorName, AttributeList *AttrList);
                                       
-  virtual void ObjcAddInstanceVariable(DeclTy *ClassDec, DeclTy **Ivar,
-                                      unsigned numIvars,
-                                       tok::ObjCKeywordKind *visibility);
+  virtual void ObjcAddVisibilityToIvars(DeclTy *ClassDec, DeclTy **Ivar,
+                                       unsigned numIvars,
+                                        tok::ObjCKeywordKind *visibility);
 private:
   // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
   // functions and arrays to their respective pointers (C99 6.3.2.1). 
index 05ec2040ff65edb3056d2807b65bd4a3a14accee..6e2f431a56f71721ea1953c918769fae22fe0ea0 100644 (file)
@@ -877,9 +877,9 @@ Sema::DeclTy *Sema::ObjcStartClassInterface(SourceLocation AtInterfaceLoc,
   return IDecl;
 }
 
-void Sema::ObjcAddInstanceVariable(DeclTy *ClassDecl, DeclTy **Ivar,
-                                  unsigned numIvars,
-                                   tok::ObjCKeywordKind *visibility) {
+void Sema::ObjcAddVisibilityToIvars(DeclTy *ClassDecl, DeclTy **Ivar,
+                                   unsigned numIvars,
+                                    tok::ObjCKeywordKind *visibility) {
   assert((ClassDecl && numIvars) && "missing class or instance variable");
   ObjcInterfaceDecl *OInterface = dyn_cast<ObjcInterfaceDecl>(
                                     static_cast<Decl *>(ClassDecl));
@@ -1217,6 +1217,12 @@ void Sema::ParseRecordBody(SourceLocation RecLoc, DeclTy *RecDecl,
   // Okay, we successfully defined 'Record'.
   if (Record)
     Record->defineBody(&RecFields[0], RecFields.size());
+  else {
+    ObjcIvarDecl **ClsFields = 
+                    reinterpret_cast<ObjcIvarDecl**>(&RecFields[0]);
+    cast<ObjcInterfaceDecl>(static_cast<Decl*>(RecDecl))->
+      ObjcAddInstanceVariablesToClass(ClsFields, RecFields.size());
+  }
 }
 
 void Sema::ObjcAddMethodsToClass(DeclTy *ClassDecl, 
index 06a6d796fb833472bd8969f78cc630c942e9c126..a7d7e5fae4dad959240a194c7ac5b4058d018e84 100644 (file)
                08FB7793FE84155DC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
                        projectDirPath = "";
index 2431597e825671ddf3b8236d82b08e1bcfeb8b19..46ffb6c7a2de60119e8f4a356b00f4231753cb34 100644 (file)
@@ -23,6 +23,7 @@ class IdentifierInfo;
 class Expr;
 class Stmt;
 class FunctionDecl;
+class ObjcIvarDecl;
 class ObjcMethodDecl;
 class AttributeList;
 
@@ -536,7 +537,7 @@ public:
 
 class ObjcInterfaceDecl : public TypeDecl {
   /// Ivars/NumIvars - This is a new[]'d array of pointers to Decls.
-  FieldDecl **Ivars;   // Null if not defined.
+  ObjcIvarDecl **Ivars;   // Null if not defined.
   int NumIvars;   // -1 if not defined.
   
   /// instance methods
@@ -554,7 +555,8 @@ public:
       InsMethods(0), NumInsMethods(-1), ClsMethods(0), NumClsMethods(-1),
       isForwardDecl(FD) { }
      
-  void addInstanceVariable(FieldDecl ivar);
+  void ObjcAddInstanceVariablesToClass(ObjcIvarDecl **ivars, 
+                                      unsigned numIvars);
 
   void ObjcAddMethods(ObjcMethodDecl **insMethods, unsigned numInsMembers,
                       ObjcMethodDecl **clsMethods, unsigned numClsMembers);
index ffb147f9b6ebcd7d0ca37f014e6992785e1414db..770187a930d6125bffa226efd479b80d33e91790 100644 (file)
@@ -449,9 +449,9 @@ public:
                     AttributeList *AttrList) {
     return 0;
   }
-  virtual void ObjcAddInstanceVariable(DeclTy *ClassDec, DeclTy **Ivars, 
-                                      unsigned numIvars, 
-                                       tok::ObjCKeywordKind *visibility) {
+  virtual void ObjcAddVisibilityToIvars(DeclTy *ClassDec, DeclTy **Ivars, 
+                                       unsigned numIvars, 
+                                        tok::ObjCKeywordKind *visibility) {
     return;
   }
   virtual void ObjcAddMethodsToClass(DeclTy *ClassDecl,