From 5d5dbb17540f2ba79381e628e1e4e7ae70c4b0ea Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 20 Apr 2009 00:37:55 +0000 Subject: [PATCH] Remove non-const form of lookupFieldDeclForIvar. llvm-svn: 69563 --- clang/include/clang/AST/DeclObjC.h | 6 +----- clang/lib/AST/DeclObjC.cpp | 7 ++++--- clang/lib/CodeGen/CGObjC.cpp | 2 +- clang/lib/CodeGen/CGObjCGNU.cpp | 6 ++++-- clang/lib/CodeGen/CGObjCMac.cpp | 3 ++- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 2f360b6db5b1..119b3c890a30 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -428,13 +428,9 @@ public: void setIVarList(ObjCIvarDecl * const *List, unsigned Num, ASTContext &C) { IVars.set(List, Num, C); } - FieldDecl *lookupFieldDeclForIvar(ASTContext &Context, - const ObjCIvarDecl *ivar); const FieldDecl *lookupFieldDeclForIvar(ASTContext &Ctx, - const ObjCIvarDecl *IV) const { - return const_cast(this)->lookupFieldDeclForIvar(Ctx,IV); - } + const ObjCIvarDecl *IV) const; bool isForwardDecl() const { return ForwardDecl; } void setForwardDecl(bool val) { ForwardDecl = val; } diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 4bc7cd461cbc..4a3c4d4f30e9 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -375,11 +375,12 @@ ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const { return 0; } -/// lookupFieldDeclForIvar - looks up a field decl' in the laid out +/// lookupFieldDeclForIvar - looks up a field decl in the laid out /// storage which matches this 'ivar'. /// -FieldDecl *ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context, - const ObjCIvarDecl *IVar) { +const FieldDecl * +ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context, + const ObjCIvarDecl *IVar) const { const RecordDecl *RecordForDecl = Context.addRecordToClass(this); assert(RecordForDecl && "lookupFieldDeclForIvar no storage for class"); DeclContext::lookup_const_result Lookup = diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 2ac4f9c7dfd3..e22efa162adf 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -195,7 +195,7 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP, Types.ConvertType(PD->getType()))); EmitReturnOfRValue(RV, PD->getType()); } else { - FieldDecl *Field = + const FieldDecl *Field = IMP->getClassInterface()->lookupFieldDeclForIvar(getContext(), Ivar); LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, Field, 0); diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index f7936fda5541..2bbb15f01744 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -764,7 +764,8 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) { Context.getObjCEncodingForType((*iter)->getType(), TypeStr); IvarTypes.push_back(CGM.GetAddrOfConstantCString(TypeStr)); // Get the offset - FieldDecl *Field = ClassDecl->lookupFieldDeclForIvar(Context, (*iter)); + const FieldDecl *Field = + ClassDecl->lookupFieldDeclForIvar(Context, (*iter)); int offset = (int)Layout->getElementOffset(CGM.getTypes().getLLVMFieldNo(Field)); IvarOffsets.push_back( @@ -1105,7 +1106,8 @@ llvm::Value *CGObjCGNU::EmitIvarOffset(CodeGen::CodeGenFunction &CGF, CGM.getContext().getObjCInterfaceType(Interface)); const llvm::StructLayout *Layout = CGM.getTargetData().getStructLayout(cast(InterfaceLTy)); - FieldDecl *Field = Interface->lookupFieldDeclForIvar(CGM.getContext(), Ivar); + const FieldDecl *Field = + Interface->lookupFieldDeclForIvar(CGM.getContext(), Ivar); uint64_t Offset = Layout->getElementOffset(CGM.getTypes().getLLVMFieldNo(Field)); diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index e04f723b1d78..e92796b5ba8d 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -2400,7 +2400,8 @@ llvm::Value *CGObjCMac::EmitIvarOffset(CodeGen::CodeGenFunction &CGF, ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar) { const llvm::StructLayout *Layout = GetInterfaceDeclStructLayout(Interface); - FieldDecl *Field = Interface->lookupFieldDeclForIvar(CGM.getContext(), Ivar); + const FieldDecl *Field = + Interface->lookupFieldDeclForIvar(CGM.getContext(), Ivar); uint64_t Offset = GetIvarBaseOffset(Layout, Field); return llvm::ConstantInt::get( CGM.getTypes().ConvertType(CGM.getContext().LongTy),