This patch converts  Sema::MatchTemplateParametersToScopeSpecifier to
ArrayRef.
Passes make test on x86_64-unknown-linux-gnu

Please review.

Thanks,
Robert
Index: include/clang/Sema/Sema.h
===================================================================
--- include/clang/Sema/Sema.h	(revision 186758)
+++ include/clang/Sema/Sema.h	(working copy)
@@ -4976,8 +4976,7 @@
   MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
                                           SourceLocation DeclLoc,
                                           const CXXScopeSpec &SS,
-                                          TemplateParameterList **ParamLists,
-                                          unsigned NumParamLists,
+                                   ArrayRef<TemplateParameterList *> ParamLists,
                                           bool IsFriend,
                                           bool &IsExplicitSpecialization,
                                           bool &Invalid);
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp	(revision 186758)
+++ lib/Sema/SemaDecl.cpp	(working copy)
@@ -4931,8 +4931,7 @@
                                   D.getDeclSpec().getLocStart(),
                                                   D.getIdentifierLoc(),
                                                   D.getCXXScopeSpec(),
-                                                  TemplateParamLists.data(),
-                                                  TemplateParamLists.size(),
+                                                  TemplateParamLists,
                                                   /*never a friend*/ false,
                                                   isExplicitSpecialization,
                                                   Invalid)) {
@@ -6152,8 +6151,7 @@
                                   D.getDeclSpec().getLocStart(),
                                   D.getIdentifierLoc(),
                                   D.getCXXScopeSpec(),
-                                  TemplateParamLists.data(),
-                                  TemplateParamLists.size(),
+                                  TemplateParamLists,
                                   isFriend,
                                   isExplicitSpecialization,
                                   Invalid)) {
@@ -9720,8 +9718,7 @@
       (SS.isNotEmpty() && TUK != TUK_Reference)) {
     if (TemplateParameterList *TemplateParams
           = MatchTemplateParametersToScopeSpecifier(KWLoc, NameLoc, SS,
-                                                TemplateParameterLists.data(),
-                                                TemplateParameterLists.size(),
+                                                    TemplateParameterLists,
                                                     TUK == TUK_Friend,
                                                     isExplicitSpecialization,
                                                     Invalid)) {
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp	(revision 186758)
+++ lib/Sema/SemaDeclCXX.cpp	(working copy)
@@ -10998,8 +10998,7 @@
 
   if (TemplateParameterList *TemplateParams
         = MatchTemplateParametersToScopeSpecifier(TagLoc, NameLoc, SS,
-                                                  TempParamLists.data(),
-                                                  TempParamLists.size(),
+                                                  TempParamLists,
                                                   /*friend*/ true,
                                                   isExplicitSpecialization,
                                                   Invalid)) {
Index: lib/Sema/SemaTemplate.cpp
===================================================================
--- lib/Sema/SemaTemplate.cpp	(revision 186758)
+++ lib/Sema/SemaTemplate.cpp	(working copy)
@@ -1605,8 +1605,7 @@
 Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
                                               SourceLocation DeclLoc,
                                               const CXXScopeSpec &SS,
-                                          TemplateParameterList **ParamLists,
-                                              unsigned NumParamLists,
+                                   ArrayRef<TemplateParameterList *> ParamLists,
                                               bool IsFriend,
                                               bool &IsExplicitSpecialization,
                                               bool &Invalid) {
@@ -1782,7 +1781,7 @@
     //   unspecialized, except that the declaration shall not explicitly 
     //   specialize a class member template if its en- closing class templates 
     //   are not explicitly specialized as well.
-    if (ParamIdx < NumParamLists) {
+    if (ParamIdx < ParamLists.size()) {
       if (ParamLists[ParamIdx]->size() == 0) {
         if (SawNonEmptyTemplateParameterList) {
           Diag(DeclLoc, diag::err_specialize_member_of_template)
@@ -1801,7 +1800,7 @@
       if (TypeIdx == NumTypes - 1)
         IsExplicitSpecialization = true;
       
-      if (ParamIdx < NumParamLists) {
+      if (ParamIdx < ParamLists.size()) {
         if (ParamLists[ParamIdx]->size() > 0) {
           // The header has template parameters when it shouldn't. Complain.
           Diag(ParamLists[ParamIdx]->getTemplateLoc(), 
@@ -1822,7 +1821,7 @@
       if (!IsFriend) {
         // We don't have a template header, but we should.
         SourceLocation ExpectedTemplateLoc;
-        if (NumParamLists > 0)
+        if (!ParamLists.empty())
           ExpectedTemplateLoc = ParamLists[0]->getTemplateLoc();
         else
           ExpectedTemplateLoc = DeclStartLoc;
@@ -1841,14 +1840,14 @@
       // assume that empty parameter lists are supposed to match this
       // template-id.
       if (IsFriend && T->isDependentType()) {
-        if (ParamIdx < NumParamLists &&
+        if (ParamIdx < ParamLists.size() &&
             DependsOnTemplateParameters(T, ParamLists[ParamIdx]))
           ExpectedTemplateParams = 0;
         else 
           continue;
       }
 
-      if (ParamIdx < NumParamLists) {
+      if (ParamIdx < ParamLists.size()) {
         // Check the template parameter list, if we can.        
         if (ExpectedTemplateParams &&
             !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
@@ -1876,14 +1875,14 @@
   // If there were at least as many template-ids as there were template
   // parameter lists, then there are no template parameter lists remaining for
   // the declaration itself.
-  if (ParamIdx >= NumParamLists)
+  if (ParamIdx >= ParamLists.size())
     return 0;
 
   // If there were too many template parameter lists, complain about that now.
-  if (ParamIdx < NumParamLists - 1) {
+  if (ParamIdx < ParamLists.size() - 1) {
     bool HasAnyExplicitSpecHeader = false;
     bool AllExplicitSpecHeaders = true;
-    for (unsigned I = ParamIdx; I != NumParamLists - 1; ++I) {
+    for (unsigned I = ParamIdx, E = ParamLists.size() - 1; I != E; ++I) {
       if (ParamLists[I]->size() == 0)
         HasAnyExplicitSpecHeader = true;
       else
@@ -1894,7 +1893,7 @@
          AllExplicitSpecHeaders? diag::warn_template_spec_extra_headers
                                : diag::err_template_spec_extra_headers)
       << SourceRange(ParamLists[ParamIdx]->getTemplateLoc(),
-                     ParamLists[NumParamLists - 2]->getRAngleLoc());
+                     ParamLists[ParamLists.size() - 2]->getRAngleLoc());
 
     // If there was a specialization somewhere, such that 'template<>' is
     // not required, and there were any 'template<>' headers, note where the
@@ -1918,7 +1917,7 @@
   //   unspecialized, except that the declaration shall not explicitly 
   //   specialize a class member template if its en- closing class templates 
   //   are not explicitly specialized as well.
-  if (ParamLists[NumParamLists - 1]->size() == 0 && 
+  if (ParamLists.back()->size() == 0 && 
       SawNonEmptyTemplateParameterList) {
     Diag(DeclLoc, diag::err_specialize_member_of_template)
       << ParamLists[ParamIdx]->getSourceRange();
@@ -1929,7 +1928,7 @@
   
   // Return the last template parameter list, which corresponds to the
   // entity being declared.
-  return ParamLists[NumParamLists - 1];
+  return ParamLists.back();
 }
 
 void Sema::NoteAllFoundTemplates(TemplateName Name) {
@@ -5250,8 +5249,7 @@
     = MatchTemplateParametersToScopeSpecifier(TemplateNameLoc, 
                                               TemplateNameLoc,
                                               SS,
-                                              TemplateParameterLists.data(),
-                                              TemplateParameterLists.size(),
+                                              TemplateParameterLists,
                                               TUK == TUK_Friend,
                                               isExplicitSpecialization,
                                               Invalid);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to