[PATCH] D80536: [clang-tidy][modernize-loop-convert] Make loop var type human readable

Zinovy Nis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 09:54:23 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6271b96bef47: [clang-tidy][modernize-loop-convert] Make loop var type human readable (authored by zinovy.nis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80536

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h


Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
@@ -40,13 +40,14 @@
 };
 
 struct T {
+  typedef int value_type;
   struct iterator {
-    int& operator*();
-    const int& operator*()const;
+    value_type &operator*();
+    const value_type &operator*() const;
     iterator& operator ++();
     bool operator!=(const iterator &other);
-    void insert(int);
-    int X;
+    void insert(value_type);
+    value_type X;
   };
   iterator begin();
   iterator end();
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -621,6 +621,7 @@
   QualType Type = Context->getAutoDeductType();
   if (!Descriptor.ElemType.isNull() && Descriptor.ElemType->isFundamentalType())
     Type = Descriptor.ElemType.getUnqualifiedType();
+  Type = Type.getDesugaredType(*Context);
 
   // If the new variable name is from the aliased variable, then the reference
   // type for the new variable should only be used if the aliased variable was


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80536.268513.patch
Type: text/x-patch
Size: 1434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200604/e8b004b5/attachment.bin>


More information about the cfe-commits mailing list