From 8c50d797fe7f5728ce7beeb98caef970b70a9d1c Mon Sep 17 00:00:00 2001
From: Benjamin Kramer <benny.kra@googlemail.com>
Date: Sat, 16 May 2015 16:16:31 +0000
Subject: [PATCH] [Sema] Fold array into for-range loop. No functional change
 intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237525 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Sema/SemaType.cpp | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 0c6eac1e95a..57a4689c6d7 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -688,30 +688,28 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state,
   state.setCurrentChunkIndex(declarator.getNumTypeObjects());
 }
 
-void diagnoseAndRemoveTypeQualifiers(Sema &S, const DeclSpec &DS,
-                                     unsigned &TypeQuals, QualType TypeSoFar,
-                                     unsigned RemoveTQs, unsigned DiagID) {
+static void diagnoseAndRemoveTypeQualifiers(Sema &S, const DeclSpec &DS,
+                                            unsigned &TypeQuals,
+                                            QualType TypeSoFar,
+                                            unsigned RemoveTQs,
+                                            unsigned DiagID) {
   // If this occurs outside a template instantiation, warn the user about
   // it; they probably didn't mean to specify a redundant qualifier.
   typedef std::pair<DeclSpec::TQ, SourceLocation> QualLoc;
-  QualLoc Quals[] = {
-    QualLoc(DeclSpec::TQ_const, DS.getConstSpecLoc()),
-    QualLoc(DeclSpec::TQ_volatile, DS.getVolatileSpecLoc()),
-    QualLoc(DeclSpec::TQ_atomic, DS.getAtomicSpecLoc())
-  };
-
-  for (unsigned I = 0, N = llvm::array_lengthof(Quals); I != N; ++I) {
-    if (!(RemoveTQs & Quals[I].first))
+  for (QualLoc Qual : {QualLoc(DeclSpec::TQ_const, DS.getConstSpecLoc()),
+                       QualLoc(DeclSpec::TQ_volatile, DS.getVolatileSpecLoc()),
+                       QualLoc(DeclSpec::TQ_atomic, DS.getAtomicSpecLoc())}) {
+    if (!(RemoveTQs & Qual.first))
       continue;
 
     if (S.ActiveTemplateInstantiations.empty()) {
-      if (TypeQuals & Quals[I].first)
-        S.Diag(Quals[I].second, DiagID)
-          << DeclSpec::getSpecifierName(Quals[I].first) << TypeSoFar
-          << FixItHint::CreateRemoval(Quals[I].second);
+      if (TypeQuals & Qual.first)
+        S.Diag(Qual.second, DiagID)
+          << DeclSpec::getSpecifierName(Qual.first) << TypeSoFar
+          << FixItHint::CreateRemoval(Qual.second);
     }
 
-    TypeQuals &= ~Quals[I].first;
+    TypeQuals &= ~Qual.first;
   }
 }
 
-- 
GitLab