make QMakeParser take a QStringRef as input

the only place where this actually saves a deep copy is the evaluation
of if(), but as a side effect the parser is now able to deal with not
null-terminated strings, which is kinda nice as well.

Change-Id: Ib6d08617aa79d2f9eaecd4906d4d548f34bf377d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
(cherry picked from qtbase/ad17a35853fe21a93fc34f7b2d9262c5ac992b29)
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
Oswald Buddenhagen
2016-05-13 15:32:50 +02:00
parent 50b87b3a8d
commit b7706cdfeb
7 changed files with 33 additions and 29 deletions

View File

@@ -1288,7 +1288,7 @@ void QMakeEvaluator::setupProject()
void QMakeEvaluator::evaluateCommand(const QString &cmds, const QString &where)
{
if (!cmds.isEmpty()) {
ProFile *pro = m_parser->parsedProBlock(cmds, where, -1);
ProFile *pro = m_parser->parsedProBlock(QStringRef(&cmds), where, -1);
if (pro->isOk()) {
m_locationStack.push(m_current);
visitProBlock(pro, pro->tokPtr());
@@ -1780,7 +1780,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateExpandFunction(
}
QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional(
const QString &cond, const QString &where, int line)
const QStringRef &cond, const QString &where, int line)
{
VisitReturn ret = ReturnFalse;
ProFile *pro = m_parser->parsedProBlock(cond, where, line, QMakeParser::TestGrammar);
@@ -1798,7 +1798,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::checkRequirements(const ProStringLis
{
ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS"));
for (const ProString &dep : deps) {
VisitReturn vr = evaluateConditional(dep.toQString(), m_current.pro->fileName(), m_current.line);
VisitReturn vr = evaluateConditional(dep.toQStringRef(), m_current.pro->fileName(), m_current.line);
if (vr == ReturnError)
return ReturnError;
if (vr != ReturnTrue)