From: Douglas Gregor Date: Thu, 17 Feb 2011 17:10:20 +0000 (+0000) Subject: Devirtualize RedeclarableTemplateDecl::newCommon(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e6f2a8d70c3027e99c354edd9d31a37c102f30a;p=clang Devirtualize RedeclarableTemplateDecl::newCommon(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125750 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 774258711c..b3277547e3 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/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/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp index a73deeab3a..2005ff62f6 100644 --- a/lib/AST/DeclTemplate.cpp +++ b/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())