summaryrefslogtreecommitdiffstats
path: root/qmake/library
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-08-09 12:17:11 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-10-27 17:53:54 +0000
commit3f723ff9a90087fad5e9be4afd5a8eee69ee694a (patch)
treef39e4b420f5141ac6e2987d3817b7a0cb625d09c /qmake/library
parente59d39c6fd96bff7466cf655f4b67e83edf50d6e (diff)
execute some loops even in cumulative mode
we execute foreach loops now. this is (mostly) safe nowadays, because a previous change added precautions against exponential value list growth, so it's unlikely that two nested loops would keep the cpu busy for a day as before. we continue to exclude forever loops and loops with excessive integer counts. Task-number: QTBUG-8550 Change-Id: Iaa116086986cc7fd5023834753f791dd205102e5 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> (cherry picked from qttools/dd4d594c787a62fa8aa12695c5d115c71b59bacd) Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'qmake/library')
-rw-r--r--qmake/library/qmakeevaluator.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp
index cfb95b946c..a1c2b5fcea 100644
--- a/qmake/library/qmakeevaluator.cpp
+++ b/qmake/library/qmakeevaluator.cpp
@@ -575,13 +575,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
okey = true, or_op = false; // force next evaluation
break;
case TokForLoop:
- if (m_cumulative) { // This is a no-win situation, so just pretend it's no loop
- skipHashStr(tokPtr);
- uint exprLen = getBlockLen(tokPtr);
- tokPtr += exprLen;
- blockLen = getBlockLen(tokPtr);
- ret = visitProBlock(tokPtr);
- } else if (okey != or_op) {
+ if (m_cumulative || okey != or_op) {
const ProKey &variable = pro->getHashStr(tokPtr);
uint exprLen = getBlockLen(tokPtr);
const ushort *exprPtr = tokPtr;
@@ -751,6 +745,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop(
ProStringList list = values(it_list.toKey());
if (list.isEmpty()) {
if (it_list == statics.strforever) {
+ if (m_cumulative) {
+ // The termination conditions wouldn't be evaluated, so we must skip it.
+ traceMsg("skipping forever loop in cumulative mode");
+ return ReturnFalse;
+ }
infinite = true;
} else {
const QString &itl = it_list.toQString(m_tmp1);
@@ -761,6 +760,12 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop(
if (ok) {
int end = itl.mid(dotdot+2).toInt(&ok);
if (ok) {
+ if (m_cumulative && qAbs(end - start) > 100) {
+ // Such a loop is unlikely to contribute something useful to the
+ // file collection, and may cause considerable delay.
+ traceMsg("skipping excessive loop in cumulative mode");
+ return ReturnFalse;
+ }
if (start < end) {
for (int i = start; i <= end; i++)
list << ProString(QString::number(i));