From 432ff5e205f28f5e8a05ca5a043e05f4a9f20d2c Mon Sep 17 00:00:00 2001 From: Angel Garcia Gomez Date: Tue, 3 Nov 2015 16:38:31 +0000 Subject: Handle correctly containers that are data members in modernize-loop-convert. Summary: I recently found that the variable naming wasn't working as expected with containers that are data members. The new index always received the name "Elem" (or equivalent) regardless of the container's name. The check was assuming that the container's declaration was a VarDecl, which cannot be converted to a FieldDecl (a data member), and then it could never retrieve its name. This also fixes some cases where the check failed to find the container at all (so it didn't do any fix) because of the same reason. Reviewers: klimek Subscribers: cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D14289 llvm-svn: 251943 --- clang-tools-extra/test/clang-tidy/modernize-loop-convert-const.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang-tools-extra/test/clang-tidy/modernize-loop-convert-const.cpp') diff --git a/clang-tools-extra/test/clang-tidy/modernize-loop-convert-const.cpp b/clang-tools-extra/test/clang-tidy/modernize-loop-convert-const.cpp index 7aec28454fa..2f64627c8de 100644 --- a/clang-tools-extra/test/clang-tidy/modernize-loop-convert-const.cpp +++ b/clang-tools-extra/test/clang-tidy/modernize-loop-convert-const.cpp @@ -341,7 +341,7 @@ class TestInsideConstFunction { copyArg(Ints[I]); } // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop - // CHECK-FIXES: for (int Elem : Ints) + // CHECK-FIXES: for (int Int : Ints) for (int I = 0; I < N; ++I) { Array[I].constMember(0); -- cgit v1.2.3