]> granicus.if.org Git - clang/commitdiff
Devirtualize RedeclarableTemplateDecl::newCommon().
authorDouglas Gregor <dgregor@apple.com>
Thu, 17 Feb 2011 17:10:20 +0000 (17:10 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 17 Feb 2011 17:10:20 +0000 (17:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125750 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclTemplate.h
lib/AST/DeclTemplate.cpp

index 774258711ca6c8535722bc85d09fd1e33e4df9d2..b3277547e3d98bd913666a0817750149acd8eca8 100644 (file)
@@ -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<FunctionTemplateSpecializationInfo> &getSpecializations() {
@@ -1731,6 +1732,8 @@ protected:
     return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
   }
 
+  friend class RedeclarableTemplateDecl;
+
 public:
   /// Get the underlying class declarations of the template.
   CXXRecordDecl *getTemplatedDecl() const {
index a73deeab3a611b0936a9377af9d8bc8bd01763cb..2005ff62f6446cca8f2baab36dce3a205085e99a 100644 (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 *Tmpl = this;
   while (Tmpl->getPreviousDeclaration())