]> granicus.if.org Git - clang/commitdiff
[Sema] Fold array into for-range loop. No functional change intended.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 16 May 2015 16:16:31 +0000 (16:16 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 16 May 2015 16:16:31 +0000 (16:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237525 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp

index 0c6eac1e95aed28fb00a456cdaf485c8cb175572..57a4689c6d7226c6f645b0b847ea6fe7d853896f 100644 (file)
@@ -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;
   }
 }