diff options
author | Jordy Rose <jediknil@belkadan.com> | 2011-07-22 02:08:32 +0000 |
---|---|---|
committer | Jordy Rose <jediknil@belkadan.com> | 2011-07-22 02:08:32 +0000 |
commit | a91768e56977920cbe9723c8f3f5371e3d37d379 (patch) | |
tree | 2ac709e8609e081306827eed45149fa419de0eeb /clang/lib/AST/ASTContext.cpp | |
parent | dff8de77a611f93712df6bcfb54c2e0bed599f02 (diff) | |
download | bcm5719-llvm-a91768e56977920cbe9723c8f3f5371e3d37d379.tar.gz bcm5719-llvm-a91768e56977920cbe9723c8f3f5371e3d37d379.zip |
Add a const overload for ObjCInterfaceDecl::all_declared_ivar_begin.
This was previously not-const only because it has to lazily construct a chain
of ivars the first time it is called (and after the chain is invalidated).
In practice, all the clients were just const_casting their const Decls;
all those now-unnecessary const_casts have been removed.
llvm-svn: 135741
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 9f3be94a958..99a51cf7df3 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1063,19 +1063,6 @@ unsigned ASTContext::getPreferredTypeAlign(const Type *T) const { return ABIAlign; } -/// ShallowCollectObjCIvars - -/// Collect all ivars, including those synthesized, in the current class. -/// -void ASTContext::ShallowCollectObjCIvars(const ObjCInterfaceDecl *OI, - llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars) const { - // FIXME. This need be removed but there are two many places which - // assume const-ness of ObjCInterfaceDecl - ObjCInterfaceDecl *IDecl = const_cast<ObjCInterfaceDecl *>(OI); - for (ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv; - Iv= Iv->getNextIvar()) - Ivars.push_back(Iv); -} - /// DeepCollectObjCIvars - /// This routine first collects all declared, but not synthesized, ivars in /// super class and then collects all ivars, including those synthesized for @@ -1084,7 +1071,7 @@ void ASTContext::ShallowCollectObjCIvars(const ObjCInterfaceDecl *OI, /// void ASTContext::DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, - llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars) const { + SmallVectorImpl<const ObjCIvarDecl*> &Ivars) const { if (const ObjCInterfaceDecl *SuperClass = OI->getSuperClass()) DeepCollectObjCIvars(SuperClass, false, Ivars); if (!leafClass) { @@ -1094,7 +1081,7 @@ void ASTContext::DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, } else { ObjCInterfaceDecl *IDecl = const_cast<ObjCInterfaceDecl *>(OI); - for (ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv; + for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv; Iv= Iv->getNextIvar()) Ivars.push_back(Iv); } @@ -4487,10 +4474,10 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, const IdentifierInfo *II = OI->getIdentifier(); S += II->getName(); S += '='; - llvm::SmallVector<ObjCIvarDecl*, 32> Ivars; + SmallVector<const ObjCIvarDecl*, 32> Ivars; DeepCollectObjCIvars(OI, true, Ivars); for (unsigned i = 0, e = Ivars.size(); i != e; ++i) { - FieldDecl *Field = cast<FieldDecl>(Ivars[i]); + const FieldDecl *Field = cast<FieldDecl>(Ivars[i]); if (Field->isBitField()) getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field); else |