qmake: replace QLinkedList with std::list

This is in preparation of deprecating QLinkedList.

There is but one substantial change: Instead of copying the linked list,
we move it now, and instead of copying items between these two lists, we
use std::list::splice(), which just relinks nodes. It is a bit surprising
that the comment on the ProValueMapStack suggests references into the
container must remain stable, and then some code changes addresses by
making copies of the elements.

This was probably a bug waiting to manifest itself.

Since nothing else in qmake is using QLinkedList now, remove qlinkedlist.o
from the qmake build.

Change-Id: I08a5b0661466bf50ad8f9f8abf58bc801aef4ddc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Marc Mutz 2019-05-02 18:51:57 +02:00
parent ac4cf6e2b2
commit 7cba2acd2c
5 changed files with 11 additions and 15 deletions

View File

@ -28,7 +28,7 @@ QOBJS = \
qmetatype.o qsystemerror.o qvariant.o \
quuid.o \
qarraydata.o qbitarray.o qbytearray.o qbytearraymatcher.o \
qcryptographichash.o qdatetime.o qhash.o qlinkedlist.o qlist.o \
qcryptographichash.o qdatetime.o qhash.o qlist.o \
qlocale.o qlocale_tools.o qmap.o qregexp.o qringbuffer.o \
qstringbuilder.o qstring_compat.o qstring.o qstringlist.o qversionnumber.o \
qvsnprintf.o qxmlstream.o qxmlutils.o \
@ -112,7 +112,6 @@ DEPEND_SRC = \
$(SOURCE_PATH)/src/corelib/tools/qcryptographichash.cpp \
$(SOURCE_PATH)/src/corelib/tools/qdatetime.cpp \
$(SOURCE_PATH)/src/corelib/tools/qhash.cpp \
$(SOURCE_PATH)/src/corelib/tools/qlinkedlist.cpp \
$(SOURCE_PATH)/src/corelib/tools/qlist.cpp \
$(SOURCE_PATH)/src/corelib/tools/qlocale.cpp \
$(SOURCE_PATH)/src/corelib/tools/qlocale_tools.cpp \
@ -442,9 +441,6 @@ qmap.o: $(SOURCE_PATH)/src/corelib/tools/qmap.cpp
qhash.o: $(SOURCE_PATH)/src/corelib/tools/qhash.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $<
qlinkedlist.o: $(SOURCE_PATH)/src/corelib/tools/qlinkedlist.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $<
qcryptographichash.o: $(SOURCE_PATH)/src/corelib/tools/qcryptographichash.cpp
$(CXX) -c -o $@ $(CXXFLAGS) $<

View File

@ -88,7 +88,6 @@ QTOBJS= \
qringbuffer.obj \
qdebug.obj \
qlist.obj \
qlinkedlist.obj \
qlocale.obj \
qlocale_tools.obj \
qlocale_win.obj \

View File

@ -601,14 +601,16 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock(
case TokBypassNesting:
blockLen = getBlockLen(tokPtr);
if ((m_cumulative || okey != or_op) && blockLen) {
ProValueMapStack savedValuemapStack = m_valuemapStack;
ProValueMapStack savedValuemapStack = std::move(m_valuemapStack);
m_valuemapStack.clear();
m_valuemapStack.append(savedValuemapStack.takeFirst());
m_valuemapStack.splice(m_valuemapStack.end(),
savedValuemapStack, savedValuemapStack.begin());
traceMsg("visiting nesting-bypassing block");
ret = visitProBlock(tokPtr);
traceMsg("visited nesting-bypassing block");
savedValuemapStack.prepend(m_valuemapStack.first());
m_valuemapStack = savedValuemapStack;
savedValuemapStack.splice(savedValuemapStack.begin(),
m_valuemapStack, m_valuemapStack.begin());
m_valuemapStack = std::move(savedValuemapStack);
} else {
traceMsg("skipped nesting-bypassing block");
ret = ReturnTrue;

View File

@ -38,7 +38,6 @@
#include "ioutils.h"
#include <qlist.h>
#include <qlinkedlist.h>
#include <qmap.h>
#include <qset.h>
#include <qstack.h>
@ -54,6 +53,8 @@
# include <qmutex.h>
#endif
#include <list>
QT_BEGIN_NAMESPACE
class QMakeGlobals;
@ -94,9 +95,9 @@ public:
#endif
};
// We use a QLinkedList based stack instead of a QVector based one (QStack), so that
// We use a list-based stack instead of a vector-based one, so that
// the addresses of value maps stay constant. The qmake generators rely on that.
class QMAKE_EXPORT ProValueMapStack : public QLinkedList<ProValueMap>
class QMAKE_EXPORT ProValueMapStack : public std::list<ProValueMap>
{
public:
inline void push(const ProValueMap &t) { push_back(t); }

View File

@ -136,7 +136,6 @@ SOURCES += \
qjsonparser.cpp \
qjsonvalue.cpp \
qlibraryinfo.cpp \
qlinkedlist.cpp \
qlist.cpp \
qlocale.cpp \
qlocale_tools.cpp \
@ -189,7 +188,6 @@ HEADERS += \
qjsonparser_p.h \
qjsonvalue.h \
qjsonwriter_p.h \
qlinkedlist.h \
qlist.h \
qlocale.h \
qlocale_tools_p.h \