Devirtualize RedeclarableTemplateDecl::newCommon().

llvm-svn: 125750
This commit is contained in:
Douglas Gregor 2011-02-17 17:10:20 +00:00
parent c6196aa481
commit 0215459c37
2 changed files with 13 additions and 2 deletions

View File

@ -561,7 +561,7 @@ protected:
/// for the common pointer. /// for the common pointer.
CommonBase *getCommonPtr(); CommonBase *getCommonPtr();
virtual CommonBase *newCommon(ASTContext &C) = 0; CommonBase *newCommon(ASTContext &C);
// 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,
@ -773,6 +773,7 @@ protected:
} }
friend class FunctionDecl; friend class FunctionDecl;
friend class RedeclarableTemplateDecl;
/// \brief Retrieve the set of function template specializations of this /// \brief Retrieve the set of function template specializations of this
/// function template. /// function template.
@ -1731,6 +1732,8 @@ protected:
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr()); return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
} }
friend class RedeclarableTemplateDecl;
public: public:
/// Get the underlying class declarations of the template. /// Get the underlying class declarations of the template.
CXXRecordDecl *getTemplatedDecl() const { CXXRecordDecl *getTemplatedDecl() const {

View File

@ -112,6 +112,14 @@ RedeclarableTemplateDecl::CommonBase *RedeclarableTemplateDecl::getCommonPtr() {
} }
RedeclarableTemplateDecl::CommonBase *
RedeclarableTemplateDecl::newCommon(ASTContext &C) {
if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(this))
return FunTmpl->newCommon(C);
return cast<ClassTemplateDecl>(this)->newCommon(C);
}
RedeclarableTemplateDecl *RedeclarableTemplateDecl::getCanonicalDeclImpl() { RedeclarableTemplateDecl *RedeclarableTemplateDecl::getCanonicalDeclImpl() {
RedeclarableTemplateDecl *Tmpl = this; RedeclarableTemplateDecl *Tmpl = this;
while (Tmpl->getPreviousDeclaration()) while (Tmpl->getPreviousDeclaration())