clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 28341)
authorMatthias Gehre <M.Gehre@gmx.de>
Wed, 20 Jul 2016 12:32:06 +0000 (12:32 +0000)
committerMatthias Gehre <M.Gehre@gmx.de>
Wed, 20 Jul 2016 12:32:06 +0000 (12:32 +0000)
commit056237a457dc3cdc88d0e282663400871f8e96dd
tree423b37dfcb53dfdd63968790007b5c54a88b6b37
parent5d8f071a0773635df1cc2d9b799198a350a732e2
clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 28341)

Summary:
Previoly, the added test failed with the fillowing fixit:

     char v[5];

-    for(size_t i = 0; i < 5; ++i)
+    for(char value : v)
     {
-        unsigned char value = v[i];
         if (value > 127)

i.e. the variable 'value' changes from unsigned char to signed char. And
thus the following 'if' does not work anymore.

With this commit, the fixit is changed to:
     char v[5];

-    for(size_t i = 0; i < 5; ++i)
+    for(unsigned char value : v)
     {
-        unsigned char value = v[i];
         if (value > 127)

Reviewers: alexfh, klimek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D22069

llvm-svn: 276111
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/test/clang-tidy/modernize-loop-convert-extra.cpp