[cfe-commits] r41961 - in /cfe/trunk: 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

Fariborz Jahanian fjahanian at apple.com
Fri Sep 14 14:08:28 PDT 2007


Author: fjahanian
Date: Fri Sep 14 16:08:27 2007
New Revision: 41961

URL: http://llvm.org/viewvc/llvm-project?rev=41961&view=rev
Log:
Patch to store ivars into interface class object.


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

Modified: cfe/trunk/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=41961&r1=41960&r2=41961&view=diff

==============================================================================
--- cfe/trunk/AST/Decl.cpp (original)
+++ cfe/trunk/AST/Decl.cpp Fri Sep 14 16:08:27 2007
@@ -186,6 +186,18 @@
   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.
 ///

Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=41961&r1=41960&r2=41961&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Fri Sep 14 16:08:27 2007
@@ -659,7 +659,7 @@
     }
   }
   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());

Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=41961&r1=41960&r2=41961&view=diff

==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Fri Sep 14 16:08:27 2007
@@ -369,9 +369,9 @@
  	     	    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). 

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=41961&r1=41960&r2=41961&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Fri Sep 14 16:08:27 2007
@@ -877,9 +877,9 @@
   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 @@
   // 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, 

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=41961&r1=41960&r2=41961&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Fri Sep 14 16:08:27 2007
@@ -675,6 +675,7 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
 			projectDirPath = "";

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=41961&r1=41960&r2=41961&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Sep 14 16:08:27 2007
@@ -23,6 +23,7 @@
 class Expr;
 class Stmt;
 class FunctionDecl;
+class ObjcIvarDecl;
 class ObjcMethodDecl;
 class AttributeList;
 
@@ -536,7 +537,7 @@
 
 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 @@
       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);

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=41961&r1=41960&r2=41961&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Fri Sep 14 16:08:27 2007
@@ -449,9 +449,9 @@
                     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,





More information about the cfe-commits mailing list