From ce5605ecf76d8cde6372138f830bb144d174ced9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 30 Mar 2008 23:25:33 +0000 Subject: some cleanups on top of David's patch. There are still two remaining open issues I've communicated to him: 1) self can be assigned to, and his patch didn't handle it correctly. 2) CollectObjCIvarTypes is N^2 (because each subclass reprocesses all parent class ivars) and flattens classes. If A derives from B, and both have an int, I'd expect to get { {i32}, i32}, not { i32, i32}. David, please review. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48970 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenTypes.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'lib/CodeGen/CodeGenTypes.cpp') diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index afa20e4110..a16543eebe 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -148,16 +148,14 @@ void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) { /// Objective-C object, in the order that they appear. Used to create LLVM /// structures corresponding to Objective-C objects. void CodeGenTypes::CollectObjCIvarTypes(ObjCInterfaceDecl *ObjCClass, - std::vector &IvarTypes) { + std::vector &IvarTypes) { ObjCInterfaceDecl *SuperClass = ObjCClass->getSuperClass(); - if(SuperClass) { + if (SuperClass) CollectObjCIvarTypes(SuperClass, IvarTypes); - } - for(ObjCInterfaceDecl::ivar_iterator ivar=ObjCClass->ivar_begin() ; - ivar != ObjCClass->ivar_end() ; - ivar++) { - IvarTypes.push_back(ConvertType((*ivar)->getType())); - ObjCIvarInfo[*ivar] = IvarTypes.size() - 1; + for (ObjCInterfaceDecl::ivar_iterator I = ObjCClass->ivar_begin(), + E = ObjCClass->ivar_end(); I != E; ++I) { + IvarTypes.push_back(ConvertType((*I)->getType())); + ObjCIvarInfo[*I] = IvarTypes.size() - 1; } } @@ -420,8 +418,7 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) { /// getLLVMFieldNo - Return llvm::StructType element number /// that corresponds to the field FD. unsigned CodeGenTypes::getLLVMFieldNo(const FieldDecl *FD) { - llvm::DenseMap::iterator - I = FieldInfo.find(FD); + llvm::DenseMap::iterator I = FieldInfo.find(FD); assert (I != FieldInfo.end() && "Unable to find field info"); return I->second; } @@ -429,7 +426,7 @@ unsigned CodeGenTypes::getLLVMFieldNo(const FieldDecl *FD) { unsigned CodeGenTypes::getLLVMFieldNo(const ObjCIvarDecl *OID) { llvm::DenseMap::iterator I = ObjCIvarInfo.find(OID); - assert (I != ObjCIvarInfo.end() && "Unable to find field info"); + assert(I != ObjCIvarInfo.end() && "Unable to find field info"); return I->second; } -- cgit v1.2.3-18-g5258