[cfe-commits] r101758 - /cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

David Chisnall csdavec at swan.ac.uk
Sun Apr 18 17:45:34 PDT 2010


Author: theraven
Date: Sun Apr 18 19:45:34 2010
New Revision: 101758

URL: http://llvm.org/viewvc/llvm-project?rev=101758&view=rev
Log:
Fix emitting ivar metadata for synthesized ivars and some 64-bit fixes. (GNU runtime)


Modified:
    cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=101758&r1=101757&r2=101758&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Sun Apr 18 19:45:34 2010
@@ -1290,16 +1290,21 @@
   if (CGM.getContext().getLangOptions().ObjCNonFragileABI) {
     instanceSize = 0 - (instanceSize - superInstanceSize);
   }
-  for (ObjCInterfaceDecl::ivar_iterator iter = ClassDecl->ivar_begin(),
-      endIter = ClassDecl->ivar_end() ; iter != endIter ; iter++) {
+
+  // Collect declared and synthesized ivars.
+  llvm::SmallVector<ObjCIvarDecl*, 16> OIvars;
+  CGM.getContext().ShallowCollectObjCIvars(ClassDecl, OIvars);
+
+  for (unsigned i = 0, e = OIvars.size(); i != e; ++i) {
+      ObjCIvarDecl *IVD = OIvars[i];
       // Store the name
-      IvarNames.push_back(MakeConstantString((*iter)->getNameAsString()));
+      IvarNames.push_back(MakeConstantString(IVD->getNameAsString()));
       // Get the type encoding for this ivar
       std::string TypeStr;
-      Context.getObjCEncodingForType((*iter)->getType(), TypeStr);
+      Context.getObjCEncodingForType(IVD->getType(), TypeStr);
       IvarTypes.push_back(MakeConstantString(TypeStr));
       // Get the offset
-      uint64_t BaseOffset = ComputeIvarBaseOffset(CGM, ClassDecl, *iter);
+      uint64_t BaseOffset = ComputeIvarBaseOffset(CGM, ClassDecl, IVD);
       uint64_t Offset = BaseOffset;
       if (CGM.getContext().getLangOptions().ObjCNonFragileABI) {
         Offset = BaseOffset - superInstanceSize;
@@ -1310,7 +1315,7 @@
           false, llvm::GlobalValue::ExternalLinkage,
           llvm::ConstantInt::get(IntTy, BaseOffset),
           "__objc_ivar_offset_value_" + ClassName +"." +
-          (*iter)->getNameAsString()));
+          IVD->getNameAsString()));
   }
   llvm::Constant *IvarOffsetArrayInit =
       llvm::ConstantArray::get(llvm::ArrayType::get(PtrToIntTy,
@@ -1659,10 +1664,9 @@
     CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
   Params.push_back(IdTy);
   Params.push_back(SelectorTy);
-  // FIXME: Using LongTy for ptrdiff_t is probably broken on Win64
-  Params.push_back(LongTy);
+  Params.push_back(IntTy);
   Params.push_back(BoolTy);
-  // void objc_getProperty (id, SEL, ptrdiff_t, bool)
+  // void objc_getProperty (id, SEL, int, bool)
   const llvm::FunctionType *FTy =
     llvm::FunctionType::get(IdTy, Params, false);
   return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy,
@@ -1675,12 +1679,11 @@
     CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
   Params.push_back(IdTy);
   Params.push_back(SelectorTy);
-  // FIXME: Using LongTy for ptrdiff_t is probably broken on Win64
-  Params.push_back(LongTy);
+  Params.push_back(IntTy);
   Params.push_back(IdTy);
   Params.push_back(BoolTy);
   Params.push_back(BoolTy);
-  // void objc_setProperty (id, SEL, ptrdiff_t, id, bool, bool)
+  // void objc_setProperty (id, SEL, int, id, bool, bool)
   const llvm::FunctionType *FTy =
     llvm::FunctionType::get(llvm::Type::getVoidTy(VMContext), Params, false);
   return cast<llvm::Function>(CGM.CreateRuntimeFunction(FTy,





More information about the cfe-commits mailing list