Currently using nested Q_FOREACH loops produces warnings about
shadowing local variables (if enabled). For example, this code:
QList<int> aList;
QList<int> bList;
foreach (int a, aList) {
Q_UNUSED(a);
foreach (int b, bList)
Q_UNUSED(b);
}
produces the following warning with MSVC:
warning C4456: declaration of '_container_' hides previous local
declaration
This is due to using variable _container_ as loop variable for both
loops.
This patch appends current line number to the name of the loop
variables so that most of the uses of Q_FOREACH will not result
in shadowing.
The patch originally by Benoit Regrain.
Fixes: QTBUG-79081
Pick-to: 5.15 6.2
Change-Id: I55235e917e920171b138c8b3239a95dfe2ac7988
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>