[cfe-commits] r80037 - in /cfe/trunk/lib/Sema: Sema.h SemaExpr.cpp SemaTemplate.cpp SemaTemplateDeduction.cpp SemaTemplateInstantiate.cpp SemaTemplateInstantiateDecl.cpp

John McCall rjmccall at apple.com
Tue Aug 25 15:02:44 PDT 2009


Author: rjmccall
Date: Tue Aug 25 17:02:44 2009
New Revision: 80037

URL: http://llvm.org/viewvc/llvm-project?rev=80037&view=rev
Log:
Clarify the difference between substitution and instantiation by renaming
functions that don't instantiate definitions.


Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=80037&r1=80036&r2=80037&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Aug 25 17:02:44 2009
@@ -2858,22 +2858,20 @@
 
   void PerformPendingImplicitInstantiations();
   
-  QualType InstantiateType(QualType T, const TemplateArgumentList &TemplateArgs,
-                           SourceLocation Loc, DeclarationName Entity);
+  QualType SubstType(QualType T, const TemplateArgumentList &TemplateArgs,
+                     SourceLocation Loc, DeclarationName Entity);
   
-  OwningExprResult InstantiateExpr(Expr *E, 
-                                   const TemplateArgumentList &TemplateArgs);
+  OwningExprResult SubstExpr(Expr *E, const TemplateArgumentList &TemplateArgs);
 
-  OwningStmtResult InstantiateStmt(Stmt *S, 
-                                   const TemplateArgumentList &TemplateArgs);
+  OwningStmtResult SubstStmt(Stmt *S, const TemplateArgumentList &TemplateArgs);
 
-  Decl *InstantiateDecl(Decl *D, DeclContext *Owner,
-                        const TemplateArgumentList &TemplateArgs);
+  Decl *SubstDecl(Decl *D, DeclContext *Owner,
+                  const TemplateArgumentList &TemplateArgs);
 
   bool 
-  InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
-                            CXXRecordDecl *Pattern,
-                            const TemplateArgumentList &TemplateArgs);
+  SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
+                      CXXRecordDecl *Pattern,
+                      const TemplateArgumentList &TemplateArgs);
 
   bool
   InstantiateTemplatePattern(SourceLocation PointOfInstantiation,
@@ -2900,25 +2898,25 @@
                            ClassTemplateSpecializationDecl *ClassTemplateSpec);
 
   NestedNameSpecifier *
-  InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS,
-                                 SourceRange Range,
-                                 const TemplateArgumentList &TemplateArgs);
+  SubstNestedNameSpecifier(NestedNameSpecifier *NNS,
+                           SourceRange Range,
+                           const TemplateArgumentList &TemplateArgs);
 
   TemplateName
-  InstantiateTemplateName(TemplateName Name, SourceLocation Loc,
-                          const TemplateArgumentList &TemplateArgs);
-  TemplateArgument Instantiate(TemplateArgument Arg,
-                               const TemplateArgumentList &TemplateArgs);
+  SubstTemplateName(TemplateName Name, SourceLocation Loc,
+                    const TemplateArgumentList &TemplateArgs);
+  TemplateArgument Subst(TemplateArgument Arg,
+                         const TemplateArgumentList &TemplateArgs);
 
   void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
                                      FunctionDecl *Function,
                                      bool Recursive = false);
   void InstantiateStaticDataMemberDefinition(
-                                          SourceLocation PointOfInstantiation,
-                                             VarDecl *Var,
-                                             bool Recursive = false);
+                                     SourceLocation PointOfInstantiation,
+                                     VarDecl *Var,
+                                     bool Recursive = false);
 
-  NamedDecl *InstantiateCurrentDeclRef(NamedDecl *D);
+  NamedDecl *FindInstantiatedDecl(NamedDecl *D);
     
   // Objective-C declarations.
   virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 25 17:02:44 2009
@@ -2452,7 +2452,7 @@
                                  ArgList.getFlatArgumentList(),
                                  ArgList.flat_size());
 
-      OwningExprResult Result = InstantiateExpr(UninstExpr, ArgList);
+      OwningExprResult Result = SubstExpr(UninstExpr, ArgList);
       if (Result.isInvalid()) 
         return ExprError();
       

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Aug 25 17:02:44 2009
@@ -1234,9 +1234,9 @@
 
           TemplateArgumentList TemplateArgs(Context, Converted,
                                             /*TakeArgs=*/false);
-          ArgType = InstantiateType(ArgType, TemplateArgs,
-                                    TTP->getDefaultArgumentLoc(),
-                                    TTP->getDeclName());
+          ArgType = SubstType(ArgType, TemplateArgs,
+                              TTP->getDefaultArgumentLoc(),
+                              TTP->getDeclName());
         }
 
         if (ArgType.isNull())
@@ -1256,8 +1256,8 @@
         TemplateArgumentList TemplateArgs(Context, Converted,
                                           /*TakeArgs=*/false);
 
-        Sema::OwningExprResult E = InstantiateExpr(NTTP->getDefaultArgument(), 
-                                                   TemplateArgs);
+        Sema::OwningExprResult E = SubstExpr(NTTP->getDefaultArgument(), 
+                                             TemplateArgs);
         if (E.isInvalid())
           return true;
         
@@ -1269,7 +1269,7 @@
         if (!TempParm->hasDefaultArgument())
           break;
 
-        // FIXME: Instantiate default argument
+        // FIXME: Subst default argument
         Arg = TemplateArgument(TempParm->getDefaultArgument());
       }
     } else {
@@ -1296,11 +1296,11 @@
                  = dyn_cast<NonTypeTemplateParmDecl>(*Param)) {
       // Check non-type template parameters.
 
-      // Instantiate the type of the non-type template parameter with
-      // the template arguments we've seen thus far.
+      // Do substitution on the type of the non-type template parameter
+      // with the template arguments we've seen thus far.
       QualType NTTPType = NTTP->getType();
       if (NTTPType->isDependentType()) {
-        // Instantiate the type of the non-type template parameter.
+        // Do substitution on the type of the non-type template parameter.
         InstantiatingTemplate Inst(*this, TemplateLoc, 
                                    Template, Converted.getFlatArguments(),
                                    Converted.flatSize(),
@@ -1308,9 +1308,9 @@
 
         TemplateArgumentList TemplateArgs(Context, Converted,
                                           /*TakeArgs=*/false);
-        NTTPType = InstantiateType(NTTPType, TemplateArgs,
-                                   NTTP->getLocation(),
-                                   NTTP->getDeclName());
+        NTTPType = SubstType(NTTPType, TemplateArgs,
+                             NTTP->getLocation(),
+                             NTTP->getDeclName());
         // If that worked, check the non-type template parameter type
         // for validity.
         if (!NTTPType.isNull())
@@ -2931,7 +2931,7 @@
                                     getTemplateInstantiationArgs(Record),
                                     /*ExplicitInstantiation=*/true))
       return true;
-  } else // Instantiate all of the members of class.
+  } else // Instantiate all of the members of the class.
     InstantiateClassMembers(TemplateLoc, Record, 
                             getTemplateInstantiationArgs(Record));
 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Aug 25 17:02:44 2009
@@ -967,8 +967,8 @@
   for (unsigned I = 0, N = PartialTemplateArgs.flat_size(); I != N; ++I) {
     Decl *Param = const_cast<Decl *>(
                     ClassTemplate->getTemplateParameters()->getParam(I));
-    TemplateArgument InstArg = Instantiate(PartialTemplateArgs[I],
-                                           *DeducedArgumentList);
+    TemplateArgument InstArg = Subst(PartialTemplateArgs[I],
+                                     *DeducedArgumentList);
     if (InstArg.isNull()) {
       Info.Param = makeTemplateParameter(Param);
       Info.FirstArg = PartialTemplateArgs[I];
@@ -1118,10 +1118,10 @@
                                 PEnd = Function->param_end();
        P != PEnd;
        ++P) {
-    QualType ParamType = InstantiateType((*P)->getType(), 
-                                         *ExplicitArgumentList, 
-                                         (*P)->getLocation(), 
-                                         (*P)->getDeclName());
+    QualType ParamType = SubstType((*P)->getType(), 
+                                   *ExplicitArgumentList, 
+                                   (*P)->getLocation(), 
+                                   (*P)->getDeclName());
     if (ParamType.isNull() || Trap.hasErrorOccurred())
       return TDK_SubstitutionFailure;
     
@@ -1136,10 +1136,10 @@
       = Function->getType()->getAsFunctionProtoType();
     assert(Proto && "Function template does not have a prototype?");
     
-    QualType ResultType = InstantiateType(Proto->getResultType(),
-                                          *ExplicitArgumentList,
-                                          Function->getTypeSpecStartLoc(),
-                                          Function->getDeclName());
+    QualType ResultType = SubstType(Proto->getResultType(),
+                                    *ExplicitArgumentList,
+                                    Function->getTypeSpecStartLoc(),
+                                    Function->getDeclName());
     if (ResultType.isNull() || Trap.hasErrorOccurred())
       return TDK_SubstitutionFailure;
     
@@ -1213,9 +1213,9 @@
   // Substitute the deduced template arguments into the function template 
   // declaration to produce the function template specialization.
   Specialization = cast_or_null<FunctionDecl>(
-                      InstantiateDecl(FunctionTemplate->getTemplatedDecl(),
-                                      FunctionTemplate->getDeclContext(),
-                                      *DeducedArgumentList));
+                      SubstDecl(FunctionTemplate->getTemplatedDecl(),
+                                FunctionTemplate->getDeclContext(),
+                                *DeducedArgumentList));
   if (!Specialization)
     return TDK_SubstitutionFailure;
   

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Tue Aug 25 17:02:44 2009
@@ -355,11 +355,11 @@
     return Template;
   }
   
-  return SemaRef.InstantiateCurrentDeclRef(cast_or_null<NamedDecl>(D));
+  return SemaRef.FindInstantiatedDecl(cast_or_null<NamedDecl>(D));
 }
 
 Decl *TemplateInstantiator::TransformDefinition(Decl *D) {
-  Decl *Inst = getSema().InstantiateDecl(D, getSema().CurContext, TemplateArgs);
+  Decl *Inst = getSema().SubstDecl(D, getSema().CurContext, TemplateArgs);
   if (!Inst)
     return 0;
   
@@ -441,7 +441,7 @@
                                                            false, false));
   }
   
-  NamedDecl *InstD = SemaRef.InstantiateCurrentDeclRef(D);
+  NamedDecl *InstD = SemaRef.FindInstantiatedDecl(D);
   if (!InstD)
     return SemaRef.ExprError();
   
@@ -485,7 +485,8 @@
                                                    T->getName());
 }
 
-/// \brief Instantiate the type T with a given set of template arguments.
+/// \brief Perform substitution on the type T with a given set of template
+/// arguments.
 ///
 /// This routine substitutes the given template arguments into the
 /// type T and produces the instantiated type.
@@ -511,9 +512,9 @@
 ///
 /// \returns If the instantiation succeeds, the instantiated
 /// type. Otherwise, produces diagnostics and returns a NULL type.
-QualType Sema::InstantiateType(QualType T, 
-                               const TemplateArgumentList &TemplateArgs,
-                               SourceLocation Loc, DeclarationName Entity) {
+QualType Sema::SubstType(QualType T, 
+                         const TemplateArgumentList &TemplateArgs,
+                         SourceLocation Loc, DeclarationName Entity) {
   assert(!ActiveTemplateInstantiations.empty() &&
          "Cannot perform an instantiation without some context on the "
          "instantiation stack");
@@ -526,16 +527,16 @@
   return Instantiator.TransformType(T);
 }
 
-/// \brief Instantiate the base class specifiers of the given class
-/// template specialization.
+/// \brief Perform substitution on the base class specifiers of the
+/// given class template specialization.
 ///
 /// Produces a diagnostic and returns true on error, returns false and
 /// attaches the instantiated base classes to the class template
 /// specialization if successful.
 bool 
-Sema::InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation,
-                                CXXRecordDecl *Pattern,
-                                const TemplateArgumentList &TemplateArgs) {
+Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
+                          CXXRecordDecl *Pattern,
+                          const TemplateArgumentList &TemplateArgs) {
   bool Invalid = false;
   llvm::SmallVector<CXXBaseSpecifier*, 4> InstantiatedBases;
   for (ClassTemplateSpecializationDecl::base_class_iterator 
@@ -546,10 +547,10 @@
       continue;
     }
 
-    QualType BaseType = InstantiateType(Base->getType(), 
-                                        TemplateArgs, 
-                                        Base->getSourceRange().getBegin(),
-                                        DeclarationName());
+    QualType BaseType = SubstType(Base->getType(), 
+                                  TemplateArgs, 
+                                  Base->getSourceRange().getBegin(),
+                                  DeclarationName());
     if (BaseType.isNull()) {
       Invalid = true;
       continue;
@@ -675,15 +676,15 @@
   // Start the definition of this instantiation.
   Instantiation->startDefinition();
 
-  // Instantiate the base class specifiers.
-  if (InstantiateBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
+  // Do substitution on the base class specifiers.
+  if (SubstBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
     Invalid = true;
 
   llvm::SmallVector<DeclPtrTy, 4> Fields;
   for (RecordDecl::decl_iterator Member = Pattern->decls_begin(),
          MemberEnd = Pattern->decls_end(); 
        Member != MemberEnd; ++Member) {
-    Decl *NewMember = InstantiateDecl(*Member, Instantiation, TemplateArgs);
+    Decl *NewMember = SubstDecl(*Member, Instantiation, TemplateArgs);
     if (NewMember) {
       if (NewMember->isInvalidDecl())
         Invalid = true;
@@ -813,13 +814,13 @@
   return Result;
 }
 
-/// \brief Instantiate the definitions of all of the member of the
-/// given class, which is an instantiation of a class template or a
-/// member class of a template.
+/// \brief Instantiates the definitions of all of the member
+/// of the given class, which is an instantiation of a class template
+/// or a member class of a template.
 void
 Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
-                              CXXRecordDecl *Instantiation,
-                              const TemplateArgumentList &TemplateArgs) {
+                        CXXRecordDecl *Instantiation,
+                        const TemplateArgumentList &TemplateArgs) {
   for (DeclContext::decl_iterator D = Instantiation->decls_begin(),
                                DEnd = Instantiation->decls_end();
        D != DEnd; ++D) {
@@ -860,7 +861,7 @@
 }
 
 Sema::OwningStmtResult 
-Sema::InstantiateStmt(Stmt *S, const TemplateArgumentList &TemplateArgs) {
+Sema::SubstStmt(Stmt *S, const TemplateArgumentList &TemplateArgs) {
   if (!S)
     return Owned(S);
 
@@ -871,7 +872,7 @@
 }
 
 Sema::OwningExprResult 
-Sema::InstantiateExpr(Expr *E, const TemplateArgumentList &TemplateArgs) {
+Sema::SubstExpr(Expr *E, const TemplateArgumentList &TemplateArgs) {
   if (!E)
     return Owned(E);
   
@@ -881,9 +882,9 @@
   return Instantiator.TransformExpr(E);
 }
 
-/// \brief Instantiate a nested-name-specifier.
+/// \brief Do template substitution on a nested-name-specifier.
 NestedNameSpecifier *
-Sema::InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS,
+Sema::SubstNestedNameSpecifier(NestedNameSpecifier *NNS,
                                      SourceRange Range,
                                      const TemplateArgumentList &TemplateArgs) {
   TemplateInstantiator Instantiator(*this, TemplateArgs, Range.getBegin(),
@@ -892,15 +893,15 @@
 }
 
 TemplateName
-Sema::InstantiateTemplateName(TemplateName Name, SourceLocation Loc,
-                              const TemplateArgumentList &TemplateArgs) {
+Sema::SubstTemplateName(TemplateName Name, SourceLocation Loc,
+                        const TemplateArgumentList &TemplateArgs) {
   TemplateInstantiator Instantiator(*this, TemplateArgs, Loc,
                                     DeclarationName());
   return Instantiator.TransformTemplateName(Name);
 }
 
-TemplateArgument Sema::Instantiate(TemplateArgument Arg, 
-                                   const TemplateArgumentList &TemplateArgs) {
+TemplateArgument Sema::Subst(TemplateArgument Arg, 
+                             const TemplateArgumentList &TemplateArgs) {
   TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
                                     DeclarationName());
   return Instantiator.TransformTemplateArgument(Arg);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Aug 25 17:02:44 2009
@@ -67,13 +67,13 @@
     }
 
     // Helper functions for instantiating methods.
-    QualType InstantiateFunctionType(FunctionDecl *D,
+    QualType SubstFunctionType(FunctionDecl *D,
                              llvm::SmallVectorImpl<ParmVarDecl *> &Params);
     bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl);
     bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl);
 
     TemplateParameterList *
-      InstantiateTemplateParams(TemplateParameterList *List);
+      SubstTemplateParams(TemplateParameterList *List);
   };
 }
 
@@ -93,8 +93,8 @@
   bool Invalid = false;
   QualType T = D->getUnderlyingType();
   if (T->isDependentType()) {
-    T = SemaRef.InstantiateType(T, TemplateArgs, 
-                                D->getLocation(), D->getDeclName());
+    T = SemaRef.SubstType(T, TemplateArgs, 
+                          D->getLocation(), D->getDeclName());
     if (T.isNull()) {
       Invalid = true;
       T = SemaRef.Context.IntTy;
@@ -114,10 +114,10 @@
 }
 
 Decl *TemplateDeclInstantiator::VisitVarDecl(VarDecl *D) {
-  // Instantiate the type of the declaration
-  QualType T = SemaRef.InstantiateType(D->getType(), TemplateArgs,
-                                       D->getTypeSpecStartLoc(),
-                                       D->getDeclName());
+  // Do substitution on the type of the declaration
+  QualType T = SemaRef.SubstType(D->getType(), TemplateArgs,
+                                 D->getTypeSpecStartLoc(),
+                                 D->getDeclName());
   if (T.isNull())
     return 0;
 
@@ -150,7 +150,7 @@
   
   if (D->getInit()) {
     OwningExprResult Init 
-      = SemaRef.InstantiateExpr(D->getInit(), TemplateArgs);
+      = SemaRef.SubstExpr(D->getInit(), TemplateArgs);
     if (Init.isInvalid())
       Var->setInvalidDecl();
     else
@@ -171,8 +171,8 @@
   bool Invalid = false;
   QualType T = D->getType();
   if (T->isDependentType())  {
-    T = SemaRef.InstantiateType(T, TemplateArgs,
-                                D->getLocation(), D->getDeclName());
+    T = SemaRef.SubstType(T, TemplateArgs,
+                          D->getLocation(), D->getDeclName());
     if (!T.isNull() && T->isFunctionType()) {
       // C++ [temp.arg.type]p3:
       //   If a declaration acquires a function type through a type
@@ -195,7 +195,7 @@
     EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
     
     OwningExprResult InstantiatedBitWidth
-      = SemaRef.InstantiateExpr(BitWidth, TemplateArgs);
+      = SemaRef.SubstExpr(BitWidth, TemplateArgs);
     if (InstantiatedBitWidth.isInvalid()) {
       Invalid = true;
       BitWidth = 0;
@@ -225,8 +225,8 @@
 Decl *TemplateDeclInstantiator::VisitFriendClassDecl(FriendClassDecl *D) {
   QualType T = D->getFriendType();
   if (T->isDependentType())  {
-    T = SemaRef.InstantiateType(T, TemplateArgs, D->getLocation(),
-                                DeclarationName());
+    T = SemaRef.SubstType(T, TemplateArgs, D->getLocation(),
+                          DeclarationName());
     assert(T.isNull() || getLangOptions().CPlusPlus0x || T->isRecordType());
   }
 
@@ -248,7 +248,7 @@
   EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
   
   OwningExprResult InstantiatedAssertExpr
-    = SemaRef.InstantiateExpr(AssertExpr, TemplateArgs);
+    = SemaRef.SubstExpr(AssertExpr, TemplateArgs);
   if (InstantiatedAssertExpr.isInvalid())
     return 0;
 
@@ -284,7 +284,7 @@
       EnterExpressionEvaluationContext Unevaluated(SemaRef, 
                                                    Action::Unevaluated);
       
-      Value = SemaRef.InstantiateExpr(UninstValue, TemplateArgs);
+      Value = SemaRef.SubstExpr(UninstValue, TemplateArgs);
     }
 
     // Drop the initial value and continue.
@@ -329,7 +329,7 @@
 
 Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   TemplateParameterList *TempParams = D->getTemplateParameters();
-  TemplateParameterList *InstParams = InstantiateTemplateParams(TempParams);
+  TemplateParameterList *InstParams = SubstTemplateParams(TempParams);
   if (!InstParams) return NULL;
 
   CXXRecordDecl *Pattern = D->getTemplatedDecl();
@@ -391,7 +391,7 @@
   Sema::LocalInstantiationScope Scope(SemaRef);
   
   llvm::SmallVector<ParmVarDecl *, 4> Params;
-  QualType T = InstantiateFunctionType(D, Params);
+  QualType T = SubstFunctionType(D, Params);
   if (T.isNull())
     return 0;
 
@@ -479,7 +479,7 @@
   Sema::LocalInstantiationScope Scope(SemaRef);
 
   llvm::SmallVector<ParmVarDecl *, 4> Params;
-  QualType T = InstantiateFunctionType(D, Params);
+  QualType T = SubstFunctionType(D, Params);
   if (T.isNull())
     return 0;
 
@@ -584,7 +584,7 @@
 }
 
 ParmVarDecl *TemplateDeclInstantiator::VisitParmVarDecl(ParmVarDecl *D) {
-  QualType OrigT = SemaRef.InstantiateType(D->getOriginalType(), TemplateArgs,
+  QualType OrigT = SemaRef.SubstType(D->getOriginalType(), TemplateArgs,
                                            D->getLocation(), D->getDeclName());
   if (OrigT.isNull())
     return 0;
@@ -640,9 +640,9 @@
   if (D->hasDefaultArgument()) {
     QualType DefaultPattern = D->getDefaultArgument();
     QualType DefaultInst
-      = SemaRef.InstantiateType(DefaultPattern, TemplateArgs,
-                                D->getDefaultArgumentLoc(),
-                                D->getDeclName());
+      = SemaRef.SubstType(DefaultPattern, TemplateArgs,
+                          D->getDefaultArgumentLoc(),
+                          D->getDeclName());
     
     Inst->setDefaultArgument(DefaultInst,
                              D->getDefaultArgumentLoc(),
@@ -652,8 +652,8 @@
   return Inst;
 }
 
-Decl *Sema::InstantiateDecl(Decl *D, DeclContext *Owner,
-                            const TemplateArgumentList &TemplateArgs) {
+Decl *Sema::SubstDecl(Decl *D, DeclContext *Owner,
+                      const TemplateArgumentList &TemplateArgs) {
   TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs);
   return Instantiator.Visit(D);
 }
@@ -665,7 +665,7 @@
 ///
 /// \returns NULL if there was an error
 TemplateParameterList *
-TemplateDeclInstantiator::InstantiateTemplateParams(TemplateParameterList *L) {
+TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) {
   // Get errors for all the parameters before bailing out.
   bool Invalid = false;
 
@@ -696,21 +696,21 @@
   return InstL;
 } 
 
-/// \brief Instantiates the type of the given function, including
-/// instantiating all of the function parameters.
+/// \brief Does substitution on the type of the given function, including
+/// all of the function parameters.
 ///
-/// \param D The function that we will be instantiated
+/// \param D The function whose type will be the basis of the substitution
 ///
 /// \param Params the instantiated parameter declarations
 
-/// \returns the instantiated function's type if successfull, a NULL
+/// \returns the instantiated function's type if successful, a NULL
 /// type if there was an error.
 QualType 
-TemplateDeclInstantiator::InstantiateFunctionType(FunctionDecl *D,
+TemplateDeclInstantiator::SubstFunctionType(FunctionDecl *D,
                               llvm::SmallVectorImpl<ParmVarDecl *> &Params) {
   bool InvalidDecl = false;
 
-  // Instantiate the function parameters
+  // Substitute all of the function's formal parameter types.
   TemplateDeclInstantiator ParamInstantiator(SemaRef, 0, TemplateArgs);
   llvm::SmallVector<QualType, 4> ParamTys;
   for (FunctionDecl::param_iterator P = D->param_begin(), 
@@ -742,8 +742,8 @@
   const FunctionProtoType *Proto = D->getType()->getAsFunctionProtoType();
   assert(Proto && "Missing prototype?");
   QualType ResultType 
-    = SemaRef.InstantiateType(Proto->getResultType(), TemplateArgs,
-                              D->getLocation(), D->getDeclName());
+    = SemaRef.SubstType(Proto->getResultType(), TemplateArgs,
+                        D->getLocation(), D->getDeclName());
   if (ResultType.isNull())
     return QualType();
 
@@ -881,7 +881,7 @@
 
   // Instantiate the function body.
   OwningStmtResult Body 
-    = InstantiateStmt(Pattern, getTemplateInstantiationArgs(Function));
+    = SubstStmt(Pattern, getTemplateInstantiationArgs(Function));
 
   ActOnFinishFunctionBody(DeclPtrTy::make(Function), move(Body), 
                           /*IsInstantiation=*/true);
@@ -982,7 +982,7 @@
   else 
     ActOnUninitializedDecl(DeclPtrTy::make(Var), false);
 #else
-  Var = cast_or_null<VarDecl>(InstantiateDecl(Def, Var->getDeclContext(),
+  Var = cast_or_null<VarDecl>(SubstDecl(Def, Var->getDeclContext(),
                                           getTemplateInstantiationArgs(Var)));
 #endif
   
@@ -1068,7 +1068,7 @@
 /// X<T>::<Kind>::KnownValue) to its instantiation
 /// (X<int>::<Kind>::KnownValue). InstantiateCurrentDeclRef() performs
 /// this mapping from within the instantiation of X<int>.
-NamedDecl * Sema::InstantiateCurrentDeclRef(NamedDecl *D) {
+NamedDecl * Sema::FindInstantiatedDecl(NamedDecl *D) {
   DeclContext *ParentDC = D->getDeclContext();
   if (isa<ParmVarDecl>(D) || ParentDC->isFunctionOrMethod()) {
     // D is a local of some kind. Look into the map of local
@@ -1077,7 +1077,7 @@
   }
 
   if (NamedDecl *ParentDecl = dyn_cast<NamedDecl>(ParentDC)) {
-    ParentDecl = InstantiateCurrentDeclRef(ParentDecl);
+    ParentDecl = FindInstantiatedDecl(ParentDecl);
     if (!ParentDecl)
       return 0;
 





More information about the cfe-commits mailing list