[cfe-commits] r125750 - in /cfe/trunk: include/clang/AST/DeclTemplate.h lib/AST/DeclTemplate.cpp

Douglas Gregor dgregor at apple.com
Thu Feb 17 09:10:20 PST 2011


Author: dgregor
Date: Thu Feb 17 11:10:20 2011
New Revision: 125750

URL: http://llvm.org/viewvc/llvm-project?rev=125750&view=rev
Log:
Devirtualize RedeclarableTemplateDecl::newCommon().

Modified:
    cfe/trunk/include/clang/AST/DeclTemplate.h
    cfe/trunk/lib/AST/DeclTemplate.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=125750&r1=125749&r2=125750&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu Feb 17 11:10:20 2011
@@ -561,7 +561,7 @@
   /// 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 @@
   }
 
   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 @@
     return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
   }
 
+  friend class RedeclarableTemplateDecl;
+
 public:
   /// Get the underlying class declarations of the template.
   CXXRecordDecl *getTemplatedDecl() const {

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=125750&r1=125749&r2=125750&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Feb 17 11:10:20 2011
@@ -112,6 +112,14 @@
 }
 
 
+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())





More information about the cfe-commits mailing list