Constify some getters in RedeclarableTemplateDecl

llvm-svn: 173272
This commit is contained in:
Dmitri Gribenko 2013-01-23 16:52:57 +00:00
parent 32aab2216d
commit b53f37c978
2 changed files with 14 additions and 14 deletions

View File

@ -576,14 +576,14 @@ protected:
/// \brief Pointer to the common data shared by all declarations of this /// \brief Pointer to the common data shared by all declarations of this
/// template. /// template.
CommonBase *Common; mutable CommonBase *Common;
/// \brief Retrieves the "common" pointer shared by all (re-)declarations of /// \brief Retrieves the "common" pointer shared by all (re-)declarations of
/// the same template. Calling this routine may implicitly allocate memory /// the same template. Calling this routine may implicitly allocate memory
/// for the common pointer. /// for the common pointer.
CommonBase *getCommonPtr(); CommonBase *getCommonPtr() const;
virtual CommonBase *newCommon(ASTContext &C) = 0; virtual CommonBase *newCommon(ASTContext &C) const = 0;
// Construct a template decl with name, parameters, and templated element. // Construct a template decl with name, parameters, and templated element.
RedeclarableTemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, RedeclarableTemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
@ -618,7 +618,7 @@ public:
/// template<> template<typename T> /// template<> template<typename T>
/// struct X<int>::Inner { /* ... */ }; /// struct X<int>::Inner { /* ... */ };
/// \endcode /// \endcode
bool isMemberSpecialization() { bool isMemberSpecialization() const {
return getCommonPtr()->InstantiatedFromMember.getInt(); return getCommonPtr()->InstantiatedFromMember.getInt();
} }
@ -665,7 +665,7 @@ public:
/// template<typename U> /// template<typename U>
/// void X<T>::f(T, U); /// void X<T>::f(T, U);
/// \endcode /// \endcode
RedeclarableTemplateDecl *getInstantiatedFromMemberTemplate() { RedeclarableTemplateDecl *getInstantiatedFromMemberTemplate() const {
return getCommonPtr()->InstantiatedFromMember.getPointer(); return getCommonPtr()->InstantiatedFromMember.getPointer();
} }
@ -729,7 +729,7 @@ protected:
TemplateParameterList *Params, NamedDecl *Decl) TemplateParameterList *Params, NamedDecl *Decl)
: RedeclarableTemplateDecl(FunctionTemplate, DC, L, Name, Params, Decl) { } : RedeclarableTemplateDecl(FunctionTemplate, DC, L, Name, Params, Decl) { }
CommonBase *newCommon(ASTContext &C); CommonBase *newCommon(ASTContext &C) const;
Common *getCommonPtr() { Common *getCommonPtr() {
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr()); return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
@ -1798,7 +1798,7 @@ protected:
: RedeclarableTemplateDecl(ClassTemplate, 0, SourceLocation(), : RedeclarableTemplateDecl(ClassTemplate, 0, SourceLocation(),
DeclarationName(), 0, 0) { } DeclarationName(), 0, 0) { }
CommonBase *newCommon(ASTContext &C); CommonBase *newCommon(ASTContext &C) const;
Common *getCommonPtr() { Common *getCommonPtr() {
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr()); return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
@ -2063,7 +2063,7 @@ protected:
TemplateParameterList *Params, NamedDecl *Decl) TemplateParameterList *Params, NamedDecl *Decl)
: RedeclarableTemplateDecl(TypeAliasTemplate, DC, L, Name, Params, Decl) { } : RedeclarableTemplateDecl(TypeAliasTemplate, DC, L, Name, Params, Decl) { }
CommonBase *newCommon(ASTContext &C); CommonBase *newCommon(ASTContext &C) const;
Common *getCommonPtr() { Common *getCommonPtr() {
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr()); return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());

View File

@ -128,12 +128,12 @@ static void AdoptTemplateParameterList(TemplateParameterList *Params,
// RedeclarableTemplateDecl Implementation // RedeclarableTemplateDecl Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
RedeclarableTemplateDecl::CommonBase *RedeclarableTemplateDecl::getCommonPtr() { RedeclarableTemplateDecl::CommonBase *RedeclarableTemplateDecl::getCommonPtr() const {
if (!Common) { if (!Common) {
// Walk the previous-declaration chain until we either find a declaration // Walk the previous-declaration chain until we either find a declaration
// with a common pointer or we run out of previous declarations. // with a common pointer or we run out of previous declarations.
SmallVector<RedeclarableTemplateDecl *, 2> PrevDecls; SmallVector<const RedeclarableTemplateDecl *, 2> PrevDecls;
for (RedeclarableTemplateDecl *Prev = getPreviousDecl(); Prev; for (const RedeclarableTemplateDecl *Prev = getPreviousDecl(); Prev;
Prev = Prev->getPreviousDecl()) { Prev = Prev->getPreviousDecl()) {
if (Prev->Common) { if (Prev->Common) {
Common = Prev->Common; Common = Prev->Common;
@ -241,7 +241,7 @@ FunctionTemplateDecl *FunctionTemplateDecl::CreateDeserialized(ASTContext &C,
} }
RedeclarableTemplateDecl::CommonBase * RedeclarableTemplateDecl::CommonBase *
FunctionTemplateDecl::newCommon(ASTContext &C) { FunctionTemplateDecl::newCommon(ASTContext &C) const {
Common *CommonPtr = new (C) Common; Common *CommonPtr = new (C) Common;
C.AddDeallocation(DeallocateCommon, CommonPtr); C.AddDeallocation(DeallocateCommon, CommonPtr);
return CommonPtr; return CommonPtr;
@ -328,7 +328,7 @@ ClassTemplateDecl::getPartialSpecializations() {
} }
RedeclarableTemplateDecl::CommonBase * RedeclarableTemplateDecl::CommonBase *
ClassTemplateDecl::newCommon(ASTContext &C) { ClassTemplateDecl::newCommon(ASTContext &C) const {
Common *CommonPtr = new (C) Common; Common *CommonPtr = new (C) Common;
C.AddDeallocation(DeallocateCommon, CommonPtr); C.AddDeallocation(DeallocateCommon, CommonPtr);
return CommonPtr; return CommonPtr;
@ -919,7 +919,7 @@ void TypeAliasTemplateDecl::DeallocateCommon(void *Ptr) {
static_cast<Common *>(Ptr)->~Common(); static_cast<Common *>(Ptr)->~Common();
} }
RedeclarableTemplateDecl::CommonBase * RedeclarableTemplateDecl::CommonBase *
TypeAliasTemplateDecl::newCommon(ASTContext &C) { TypeAliasTemplateDecl::newCommon(ASTContext &C) const {
Common *CommonPtr = new (C) Common; Common *CommonPtr = new (C) Common;
C.AddDeallocation(DeallocateCommon, CommonPtr); C.AddDeallocation(DeallocateCommon, CommonPtr);
return CommonPtr; return CommonPtr;