]> granicus.if.org Git - clang/commitdiff
Since integral template arguments can't have dependent types we don't need an extra...
authorAnders Carlsson <andersca@mac.com>
Tue, 16 Jun 2009 23:08:29 +0000 (23:08 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 16 Jun 2009 23:08:29 +0000 (23:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73580 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateDeduction.cpp

index 33a7c66842f6452881febca0ff1f23af449e9969..c9b6e13d4a41b1f1146e2e96b1b6a3e50459d39c 100644 (file)
@@ -53,9 +53,15 @@ DeduceNonTypeTemplateArgument(ASTContext &Context,
          "Cannot deduce non-type template argument with depth > 0");
   
   if (Deduced[NTTP->getIndex()].isNull()) {
-    Deduced[NTTP->getIndex()] = TemplateArgument(SourceLocation(), 
-                                                 llvm::APSInt(Value),
-                                                 NTTP->getType());
+    QualType T = NTTP->getType();
+    
+    // FIXME: Make sure we didn't overflow our data type!
+    unsigned AllowedBits = Context.getTypeSize(T);
+    if (Value.getBitWidth() != AllowedBits)
+      Value.extOrTrunc(AllowedBits);
+    Value.setIsSigned(T->isSignedIntegerType());
+
+    Deduced[NTTP->getIndex()] = TemplateArgument(SourceLocation(), Value, T);
     return Sema::TDK_Success;
   }
   
@@ -672,35 +678,6 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
                                          /*FlattenArgs=*/true);
   Info.reset(DeducedArgumentList);
 
-  // Now that we have all of the deduced template arguments, take
-  // another pass through them to convert any integral template
-  // arguments to the appropriate type.
-  for (unsigned I = 0, N = Deduced.size(); I != N; ++I) {
-    TemplateArgument &Arg = Deduced[I];    
-    if (Arg.getKind() == TemplateArgument::Integral) {
-      const NonTypeTemplateParmDecl *Parm 
-        = cast<NonTypeTemplateParmDecl>(Partial->getTemplateParameters()
-                                          ->getParam(I));
-      QualType T = InstantiateType(Parm->getType(), *DeducedArgumentList,
-                                   Parm->getLocation(), Parm->getDeclName());
-      if (T.isNull()) {
-        Info.Param = const_cast<NonTypeTemplateParmDecl*>(Parm);
-        Info.FirstArg = TemplateArgument(Parm->getLocation(), Parm->getType());
-        return TDK_SubstitutionFailure;
-      }
-      
-      // FIXME: Make sure we didn't overflow our data type!
-      llvm::APSInt &Value = *Arg.getAsIntegral();
-      unsigned AllowedBits = Context.getTypeSize(T);
-      if (Value.getBitWidth() != AllowedBits)
-        Value.extOrTrunc(AllowedBits);
-      Value.setIsSigned(T->isSignedIntegerType());
-      Arg.setIntegralType(T);
-    }
-
-    (*DeducedArgumentList)[I] = Arg;
-  }
-
   // Substitute the deduced template arguments into the template
   // arguments of the class template partial specialization, and
   // verify that the instantiated template arguments are both valid