CMake support: avoid infinite loop on foreach(RANGE) that never runs.
authorNicolás Alvarez <nicolas.alvarez@gmail.com>
Fri, 8 Oct 2010 19:07:11 +0000 (16:07 -0300)
committerNicolás Alvarez <nicolas.alvarez@gmail.com>
Fri, 8 Oct 2010 19:07:11 +0000 (16:07 -0300)
commitbbf4cac3d0c2927dfbfd94413ff9255b537897eb
tree55348bacea6c1ab7f04913c52e28025b56b68d53
parente80c58237889e60629c33f5f3b68a2dfa703aeff
CMake support: avoid infinite loop on foreach(RANGE) that never runs.

foreach(i RANGE 10 1) never runs because start > end. The project visitor
was returning an incorrect 'lines' value when handling those, making walk()
jump *backwards* to near beginning of file, instead of forwards to the
matching endforeach. This would probably cause an infinite loop, since it
would process the same loop again.

This commit makes the project visitor handle empty RANGE loops the same as
empty normal foreach loops, skipping to the matching endforeach. It also
adds a new test for this problem.

BUG:253513
projectmanagers/cmake/parser/cmakeprojectvisitor.cpp
projectmanagers/cmake/tests/cmake_cmakeprojectvisitor_test.cpp
projectmanagers/cmake/tests/cmake_cmakeprojectvisitor_test.h