r175159 - Remove const_casts by making spec_begin()/spec_end() const
Dmitri Gribenko
gribozavr at gmail.com
Thu Feb 14 05:20:36 PST 2013
Author: gribozavr
Date: Thu Feb 14 07:20:36 2013
New Revision: 175159
URL: http://llvm.org/viewvc/llvm-project?rev=175159&view=rev
Log:
Remove const_casts by making spec_begin()/spec_end() const
Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=175159&r1=175158&r2=175159&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu Feb 14 07:20:36 2013
@@ -552,7 +552,7 @@ protected:
};
template <typename EntryType>
- SpecIterator<EntryType>
+ static SpecIterator<EntryType>
makeSpecIterator(llvm::FoldingSetVector<EntryType> &Specs, bool isEnd) {
return SpecIterator<EntryType>(isEnd ? Specs.end() : Specs.begin());
}
@@ -731,7 +731,7 @@ protected:
CommonBase *newCommon(ASTContext &C) const;
- Common *getCommonPtr() {
+ Common *getCommonPtr() const {
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
}
@@ -740,7 +740,7 @@ protected:
/// \brief Retrieve the set of function template specializations of this
/// function template.
llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
- getSpecializations() {
+ getSpecializations() const {
return getCommonPtr()->Specializations;
}
@@ -798,11 +798,11 @@ public:
typedef SpecIterator<FunctionTemplateSpecializationInfo> spec_iterator;
- spec_iterator spec_begin() {
+ spec_iterator spec_begin() const {
return makeSpecIterator(getSpecializations(), false);
}
- spec_iterator spec_end() {
+ spec_iterator spec_end() const {
return makeSpecIterator(getSpecializations(), true);
}
@@ -1778,10 +1778,11 @@ protected:
};
/// \brief Load any lazily-loaded specializations from the external source.
- void LoadLazySpecializations();
+ void LoadLazySpecializations() const;
/// \brief Retrieve the set of specializations of this class template.
- llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &getSpecializations();
+ llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
+ getSpecializations() const;
/// \brief Retrieve the set of partial specializations of this class
/// template.
@@ -1798,7 +1799,7 @@ protected:
CommonBase *newCommon(ASTContext &C) const;
- Common *getCommonPtr() {
+ Common *getCommonPtr() const {
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
}
@@ -1923,11 +1924,11 @@ public:
typedef SpecIterator<ClassTemplateSpecializationDecl> spec_iterator;
- spec_iterator spec_begin() {
+ spec_iterator spec_begin() const {
return makeSpecIterator(getSpecializations(), false);
}
- spec_iterator spec_end() {
+ spec_iterator spec_end() const {
return makeSpecIterator(getSpecializations(), true);
}
Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=175159&r1=175158&r2=175159&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Feb 14 07:20:36 2013
@@ -935,9 +935,9 @@ void ASTDumper::VisitFunctionTemplateDec
dumpName(D);
dumpTemplateParameters(D->getTemplateParameters());
dumpDecl(D->getTemplatedDecl());
- for (FunctionTemplateDecl::spec_iterator
- I = const_cast<FunctionTemplateDecl*>(D)->spec_begin(),
- E = const_cast<FunctionTemplateDecl*>(D)->spec_end(); I != E; ++I) {
+ for (FunctionTemplateDecl::spec_iterator I = D->spec_begin(),
+ E = D->spec_end();
+ I != E; ++I) {
FunctionTemplateDecl::spec_iterator Next = I;
++Next;
if (Next == E)
@@ -960,10 +960,8 @@ void ASTDumper::VisitClassTemplateDecl(c
dumpName(D);
dumpTemplateParameters(D->getTemplateParameters());
- ClassTemplateDecl::spec_iterator I =
- const_cast<ClassTemplateDecl*>(D)->spec_begin();
- ClassTemplateDecl::spec_iterator E =
- const_cast<ClassTemplateDecl*>(D)->spec_end();
+ ClassTemplateDecl::spec_iterator I = D->spec_begin();
+ ClassTemplateDecl::spec_iterator E = D->spec_end();
if (I == E)
lastChild();
dumpDecl(D->getTemplatedDecl());
Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=175159&r1=175158&r2=175159&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Feb 14 07:20:36 2013
@@ -304,7 +304,7 @@ ClassTemplateDecl *ClassTemplateDecl::Cr
return new (Mem) ClassTemplateDecl(EmptyShell());
}
-void ClassTemplateDecl::LoadLazySpecializations() {
+void ClassTemplateDecl::LoadLazySpecializations() const {
Common *CommonPtr = getCommonPtr();
if (CommonPtr->LazySpecializations) {
ASTContext &Context = getASTContext();
@@ -316,7 +316,7 @@ void ClassTemplateDecl::LoadLazySpeciali
}
llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
-ClassTemplateDecl::getSpecializations() {
+ClassTemplateDecl::getSpecializations() const {
LoadLazySpecializations();
return getCommonPtr()->Specializations;
}
More information about the cfe-commits
mailing list