remove pointless return value from QMakeParser::read()

it always returned true nowadays.

an obvious followup effect is that the return value of parsedProBlock()
doesn't need to be null-checked any more as well.

Change-Id: I782785cab9b721a78a342a010921a73e642ebe7f
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Oswald Buddenhagen 2015-02-02 18:52:24 +01:00
parent 924659b22f
commit 030c3a6197
5 changed files with 31 additions and 40 deletions

View File

@ -1202,7 +1202,6 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
VisitReturn ret = ReturnFalse; VisitReturn ret = ReturnFalse;
ProFile *pro = m_parser->parsedProBlock(args.join(statics.field_sep), ProFile *pro = m_parser->parsedProBlock(args.join(statics.field_sep),
m_current.pro->fileName(), m_current.line); m_current.pro->fileName(), m_current.line);
if (pro) {
if (m_cumulative || pro->isOk()) { if (m_cumulative || pro->isOk()) {
m_locationStack.push(m_current); m_locationStack.push(m_current);
visitProBlock(pro, pro->tokPtr()); visitProBlock(pro, pro->tokPtr());
@ -1210,7 +1209,6 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
m_current = m_locationStack.pop(); m_current = m_locationStack.pop();
} }
pro->deref(); pro->deref();
}
return ret; return ret;
} }
case T_IF: { case T_IF: {

View File

@ -1303,7 +1303,7 @@ void QMakeEvaluator::setupProject()
void QMakeEvaluator::evaluateCommand(const QString &cmds, const QString &where) void QMakeEvaluator::evaluateCommand(const QString &cmds, const QString &where)
{ {
if (!cmds.isEmpty()) { if (!cmds.isEmpty()) {
if (ProFile *pro = m_parser->parsedProBlock(cmds, where, -1)) { ProFile *pro = m_parser->parsedProBlock(cmds, where, -1);
if (pro->isOk()) { if (pro->isOk()) {
m_locationStack.push(m_current); m_locationStack.push(m_current);
visitProBlock(pro, pro->tokPtr()); visitProBlock(pro, pro->tokPtr());
@ -1311,7 +1311,6 @@ void QMakeEvaluator::evaluateCommand(const QString &cmds, const QString &where)
} }
pro->deref(); pro->deref();
} }
}
} }
void QMakeEvaluator::applyExtraConfigs() void QMakeEvaluator::applyExtraConfigs()
@ -1790,14 +1789,12 @@ bool QMakeEvaluator::evaluateConditional(const QString &cond, const QString &whe
{ {
bool ret = false; bool ret = false;
ProFile *pro = m_parser->parsedProBlock(cond, where, line, QMakeParser::TestGrammar); ProFile *pro = m_parser->parsedProBlock(cond, where, line, QMakeParser::TestGrammar);
if (pro) {
if (pro->isOk()) { if (pro->isOk()) {
m_locationStack.push(m_current); m_locationStack.push(m_current);
ret = visitProBlock(pro, pro->tokPtr()) == ReturnTrue; ret = visitProBlock(pro, pro->tokPtr()) == ReturnTrue;
m_current = m_locationStack.pop(); m_current = m_locationStack.pop();
} }
pro->deref(); pro->deref();
}
return ret; return ret;
} }

View File

@ -209,10 +209,7 @@ ProFile *QMakeParser::parsedProBlock(
const QString &contents, const QString &name, int line, SubGrammar grammar) const QString &contents, const QString &name, int line, SubGrammar grammar)
{ {
ProFile *pro = new ProFile(name); ProFile *pro = new ProFile(name);
if (!read(pro, contents, line, grammar)) { read(pro, contents, line, grammar);
delete pro;
pro = 0;
}
return pro; return pro;
} }
@ -232,7 +229,8 @@ bool QMakeParser::read(ProFile *pro, ParseFlags flags)
fL1S("Cannot read %1: %2").arg(pro->fileName(), errStr)); fL1S("Cannot read %1: %2").arg(pro->fileName(), errStr));
return false; return false;
} }
return read(pro, content, 1, FullGrammar); read(pro, content, 1, FullGrammar);
return true;
} }
void QMakeParser::putTok(ushort *&tokPtr, ushort tok) void QMakeParser::putTok(ushort *&tokPtr, ushort tok)
@ -272,7 +270,7 @@ void QMakeParser::finalizeHashStr(ushort *buf, uint len)
buf[-2] = (ushort)(hash >> 16); buf[-2] = (ushort)(hash >> 16);
} }
bool QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar grammar) void QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar grammar)
{ {
m_proFile = pro; m_proFile = pro;
m_lineNo = line; m_lineNo = line;
@ -845,7 +843,6 @@ bool QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar gra
leaveScope(tokPtr); leaveScope(tokPtr);
tokBuff.resize(tokPtr - (ushort *)tokBuff.constData()); // Reserved capacity stays tokBuff.resize(tokPtr - (ushort *)tokBuff.constData()); // Reserved capacity stays
*pro->itemsRef() = tokBuff; *pro->itemsRef() = tokBuff;
return true;
#undef FLUSH_VALUE_LIST #undef FLUSH_VALUE_LIST
#undef FLUSH_LITERAL #undef FLUSH_LITERAL

View File

@ -130,7 +130,7 @@ private:
}; };
bool read(ProFile *pro, ParseFlags flags); bool read(ProFile *pro, ParseFlags flags);
bool read(ProFile *pro, const QString &content, int line, SubGrammar grammar); void read(ProFile *pro, const QString &content, int line, SubGrammar grammar);
ALWAYS_INLINE void putTok(ushort *&tokPtr, ushort tok); ALWAYS_INLINE void putTok(ushort *&tokPtr, ushort tok);
ALWAYS_INLINE void putBlockLen(ushort *&tokPtr, uint len); ALWAYS_INLINE void putBlockLen(ushort *&tokPtr, uint len);

View File

@ -124,7 +124,7 @@ QStringList QMakeProject::expand(const ProKey &func, const QList<ProStringList>
ProString QMakeProject::expand(const QString &expr, const QString &where, int line) ProString QMakeProject::expand(const QString &expr, const QString &where, int line)
{ {
ProString ret; ProString ret;
if (ProFile *pro = m_parser->parsedProBlock(expr, where, line, QMakeParser::ValueGrammar)) { ProFile *pro = m_parser->parsedProBlock(expr, where, line, QMakeParser::ValueGrammar);
if (pro->isOk()) { if (pro->isOk()) {
m_current.pro = pro; m_current.pro = pro;
m_current.line = 0; m_current.line = 0;
@ -134,7 +134,6 @@ ProString QMakeProject::expand(const QString &expr, const QString &where, int li
ret = result.at(0); ret = result.at(0);
} }
pro->deref(); pro->deref();
}
return ret; return ret;
} }