diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/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 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 --- 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 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();