From 0215459c37cb0461cc85b8fc462fafb6ec7ae1dc Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 17 Feb 2011 17:10:20 +0000 Subject: [PATCH] Devirtualize RedeclarableTemplateDecl::newCommon(). llvm-svn: 125750 --- clang/include/clang/AST/DeclTemplate.h | 7 +++++-- clang/lib/AST/DeclTemplate.cpp | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 774258711ca6..b3277547e3d9 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -561,7 +561,7 @@ protected: /// for the common pointer. CommonBase *getCommonPtr(); - virtual CommonBase *newCommon(ASTContext &C) = 0; + CommonBase *newCommon(ASTContext &C); // Construct a template decl with name, parameters, and templated element. RedeclarableTemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, @@ -773,7 +773,8 @@ protected: } friend class FunctionDecl; - + friend class RedeclarableTemplateDecl; + /// \brief Retrieve the set of function template specializations of this /// function template. llvm::FoldingSet &getSpecializations() { @@ -1731,6 +1732,8 @@ protected: return static_cast(RedeclarableTemplateDecl::getCommonPtr()); } + friend class RedeclarableTemplateDecl; + public: /// Get the underlying class declarations of the template. CXXRecordDecl *getTemplatedDecl() const { diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index a73deeab3a61..2005ff62f644 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -112,6 +112,14 @@ RedeclarableTemplateDecl::CommonBase *RedeclarableTemplateDecl::getCommonPtr() { } +RedeclarableTemplateDecl::CommonBase * +RedeclarableTemplateDecl::newCommon(ASTContext &C) { + if (FunctionTemplateDecl *FunTmpl = dyn_cast(this)) + return FunTmpl->newCommon(C); + + return cast(this)->newCommon(C); +} + RedeclarableTemplateDecl *RedeclarableTemplateDecl::getCanonicalDeclImpl() { RedeclarableTemplateDecl *Tmpl = this; while (Tmpl->getPreviousDeclaration())