[PATCH] D122657: [NFC] Use range based loop.

Jun Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 29 07:50:21 PDT 2022


junaire created this revision.
junaire added reviewers: v.g.vassilev, rsmith.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: Jun Zhang <jun at junz.org>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122657

Files:
  clang/lib/AST/ASTDiagnostic.cpp


Index: clang/lib/AST/ASTDiagnostic.cpp
===================================================================
--- clang/lib/AST/ASTDiagnostic.cpp
+++ clang/lib/AST/ASTDiagnostic.cpp
@@ -270,9 +270,9 @@
   std::string S = Ty.getAsString(Context.getPrintingPolicy());
   std::string CanS = CanTy.getAsString(Context.getPrintingPolicy());
 
-  for (unsigned I = 0, E = QualTypeVals.size(); I != E; ++I) {
+  for (const intptr_t &QualTypeVal : QualTypeVals) {
     QualType CompareTy =
-        QualType::getFromOpaquePtr(reinterpret_cast<void*>(QualTypeVals[I]));
+        QualType::getFromOpaquePtr(reinterpret_cast<void *>(QualTypeVal));
     if (CompareTy.isNull())
       continue;
     if (CompareTy == Ty)
@@ -302,10 +302,10 @@
   // Check to see if we already desugared this type in this
   // diagnostic.  If so, don't do it again.
   bool Repeated = false;
-  for (unsigned i = 0, e = PrevArgs.size(); i != e; ++i) {
+  for (auto &PrevArg : PrevArgs) {
     // TODO: Handle ak_declcontext case.
-    if (PrevArgs[i].first == DiagnosticsEngine::ak_qualtype) {
-      void *Ptr = (void*)PrevArgs[i].second;
+    if (PrevArg.first == DiagnosticsEngine::ak_qualtype) {
+      void *Ptr = (void *)PrevArg.second;
       QualType PrevTy(QualType::getFromOpaquePtr(Ptr));
       if (PrevTy == Ty) {
         Repeated = true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122657.418875.patch
Type: text/x-patch
Size: 1321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220329/12e4006d/attachment.bin>


More information about the cfe-commits mailing list