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

Jun Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 29 08:00:40 PDT 2022


junaire updated this revision to Diff 418882.
junaire added a comment.

Simplify code a little bit.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122657/new/

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,11 +302,11 @@
   // 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 (const auto &PrevArg : PrevArgs) {
     // TODO: Handle ak_declcontext case.
-    if (PrevArgs[i].first == DiagnosticsEngine::ak_qualtype) {
-      void *Ptr = (void*)PrevArgs[i].second;
-      QualType PrevTy(QualType::getFromOpaquePtr(Ptr));
+    if (PrevArg.first == DiagnosticsEngine::ak_qualtype) {
+      QualType PrevTy(
+          QualType::getFromOpaquePtr(reinterpret_cast<void *>(PrevArg.second)));
       if (PrevTy == Ty) {
         Repeated = true;
         break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122657.418882.patch
Type: text/x-patch
Size: 1406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220329/8444216d/attachment-0001.bin>


More information about the cfe-commits mailing list