[clang-tools-extra] 6271b96 - [clang-tidy][modernize-loop-convert] Make loop var type human readable

Zinovy Nis via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 09:52:11 PDT 2020


Author: Zinovy Nis
Date: 2020-06-04T19:51:45+03:00
New Revision: 6271b96bef479882cf43397941a4c95aa9f47403

URL: https://github.com/llvm/llvm-project/commit/6271b96bef479882cf43397941a4c95aa9f47403
DIFF: https://github.com/llvm/llvm-project/commit/6271b96bef479882cf43397941a4c95aa9f47403.diff

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

Differential Revision: https://reviews.llvm.org/D80536

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index aa914ef7bbf5..be3a7141a5cc 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -621,6 +621,7 @@ void LoopConvertCheck::doConversion(
   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

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h b/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
index 02d440c21a52..22b70f082d7b 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
+++ b/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
@@ -40,13 +40,14 @@ struct S {
 };
 
 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();


        


More information about the cfe-commits mailing list