[cfe-commits] r67684 - /cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Douglas Gregor dgregor at apple.com
Wed Mar 25 08:04:21 PDT 2009


Author: dgregor
Date: Wed Mar 25 10:04:13 2009
New Revision: 67684

URL: http://llvm.org/viewvc/llvm-project?rev=67684&view=rev
Log:
Minor refactoring to eliminate an extra switch during template instantiation

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=67684&r1=67683&r2=67684&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Mar 25 10:04:13 2009
@@ -43,11 +43,12 @@
     Decl *VisitFieldDecl(FieldDecl *D);
     Decl *VisitStaticAssertDecl(StaticAssertDecl *D);
     Decl *VisitEnumDecl(EnumDecl *D);
+    Decl *VisitEnumConstantDecl(EnumConstantDecl *D);
     Decl *VisitCXXMethodDecl(CXXMethodDecl *D);
     Decl *VisitCXXConstructorDecl(CXXConstructorDecl *D);
     Decl *VisitCXXDestructorDecl(CXXDestructorDecl *D);
     Decl *VisitCXXConversionDecl(CXXConversionDecl *D);
-    Decl *VisitParmVarDecl(ParmVarDecl *D);
+    ParmVarDecl *VisitParmVarDecl(ParmVarDecl *D);
     Decl *VisitOriginalParmVarDecl(OriginalParmVarDecl *D);
 
     // Base case. FIXME: Remove once we can instantiate everything.
@@ -203,6 +204,11 @@
   return Enum;
 }
 
+Decl *TemplateDeclInstantiator::VisitEnumConstantDecl(EnumConstantDecl *D) {
+  assert(false && "EnumConstantDecls can only occur within EnumDecls.");
+  return 0;
+}
+
 Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D) {
   // Only handle actual methods; we'll deal with constructors,
   // destructors, etc. separately.
@@ -351,7 +357,7 @@
   return Conversion;  
 }
 
-Decl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
+ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
   QualType OrigT = SemaRef.InstantiateType(D->getOriginalType(), TemplateArgs,
                                            NumTemplateArgs, D->getLocation(),
                                            D->getDeclName());
@@ -425,7 +431,7 @@
   for (FunctionDecl::param_iterator P = D->param_begin(), 
                                  PEnd = D->param_end();
        P != PEnd; ++P) {
-    if (ParmVarDecl *PInst = (ParmVarDecl *)ParamInstantiator.Visit(*P)) {
+    if (ParmVarDecl *PInst = ParamInstantiator.VisitParmVarDecl(*P)) {
       if (PInst->getType()->isVoidType()) {
         SemaRef.Diag(PInst->getLocation(), diag::err_param_with_void_type);
         PInst->setInvalidDecl();





More information about the cfe-commits mailing list