Allow the use of default template arguments when forming a class
template specialization (e.g., std::vector<int> would now be
well-formed, since it relies on a default argument for the Allocator
template parameter). 

This is much less interesting than one might expect, since (1) we're
not actually using the default arguments for anything important, such
as naming an actual Decl, and (2) we'll often need to instantiate the
default arguments to check their well-formedness. The real fun will
come later.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64310 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp
index b297dd2..dccb8df 100644
--- a/lib/AST/DeclTemplate.cpp
+++ b/lib/AST/DeclTemplate.cpp
@@ -44,6 +44,26 @@
                                          NumParams, RAngleLoc);
 }
 
+unsigned TemplateParameterList::getMinRequiredArguments() const {
+  unsigned NumRequiredArgs = size();
+  iterator Param = const_cast<TemplateParameterList *>(this)->end(), 
+      ParamBegin = const_cast<TemplateParameterList *>(this)->begin();
+  while (Param != ParamBegin) {
+    --Param;
+    if (!(isa<TemplateTypeParmDecl>(*Param) && 
+          cast<TemplateTypeParmDecl>(*Param)->hasDefaultArgument()) &&
+        !(isa<NonTypeTemplateParmDecl>(*Param) &&
+          cast<NonTypeTemplateParmDecl>(*Param)->hasDefaultArgument()) &&
+        !(isa<TemplateTemplateParmDecl>(*Param) &&
+          cast<TemplateTemplateParmDecl>(*Param)->hasDefaultArgument()))
+      break;
+        
+    --NumRequiredArgs;
+  }
+
+  return NumRequiredArgs;
+}
+
 //===----------------------------------------------------------------------===//
 // TemplateDecl Implementation
 //===----------------------------------------------------------------------===//