From 6271b96bef479882cf43397941a4c95aa9f47403 Mon Sep 17 00:00:00 2001 From: Zinovy Nis Date: Tue, 26 May 2020 09:06:59 +0300 Subject: [PATCH] [clang-tidy][modernize-loop-convert] Make loop var type human readable Differential Revision: https://reviews.llvm.org/D80536 --- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp | 1 + .../checkers/Inputs/modernize-loop-convert/structures.h | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp index aa914ef..be3a714 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 02d440c..22b70f0 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(); -- 2.7.4