forked from qt-creator/qt-creator
make messages from dynamic code tell a useful location
"(eval)" does not exactly help to find the error source. Change-Id: Iecd03e6a4909ca6d7eab846844ca4415ebfa3429 Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -40,8 +40,10 @@ using namespace QtSupport;
|
|||||||
|
|
||||||
static QString format(const QString &fileName, int lineNo, const QString &msg)
|
static QString format(const QString &fileName, int lineNo, const QString &msg)
|
||||||
{
|
{
|
||||||
if (lineNo)
|
if (lineNo > 0)
|
||||||
return QString::fromLatin1("%1(%2): %3").arg(fileName, QString::number(lineNo), msg);
|
return QString::fromLatin1("%1(%2): %3").arg(fileName, QString::number(lineNo), msg);
|
||||||
|
else if (lineNo)
|
||||||
|
return QString::fromLatin1("%1: %3").arg(fileName, msg);
|
||||||
else
|
else
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@@ -1160,8 +1160,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
|
|||||||
#endif
|
#endif
|
||||||
case T_EVAL: {
|
case T_EVAL: {
|
||||||
VisitReturn ret = ReturnFalse;
|
VisitReturn ret = ReturnFalse;
|
||||||
ProFile *pro = m_parser->parsedProBlock(fL1S("(eval)"),
|
ProFile *pro = m_parser->parsedProBlock(args.join(statics.field_sep),
|
||||||
args.join(statics.field_sep));
|
m_current.pro->fileName(), m_current.line);
|
||||||
if (pro) {
|
if (pro) {
|
||||||
if (m_cumulative || pro->isOk()) {
|
if (m_cumulative || pro->isOk()) {
|
||||||
m_locationStack.push(m_current);
|
m_locationStack.push(m_current);
|
||||||
@@ -1192,7 +1192,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
|
|||||||
evalError(fL1S("if(condition) requires one argument."));
|
evalError(fL1S("if(condition) requires one argument."));
|
||||||
return ReturnFalse;
|
return ReturnFalse;
|
||||||
}
|
}
|
||||||
return returnBool(evaluateConditional(args.at(0).toQString(), fL1S("(if)")));
|
return returnBool(evaluateConditional(args.at(0).toQString(),
|
||||||
|
m_current.pro->fileName(), m_current.line));
|
||||||
}
|
}
|
||||||
case T_CONFIG: {
|
case T_CONFIG: {
|
||||||
if (args.count() < 1 || args.count() > 2) {
|
if (args.count() < 1 || args.count() > 2) {
|
||||||
|
@@ -1200,7 +1200,7 @@ void QMakeEvaluator::setupProject()
|
|||||||
void QMakeEvaluator::visitCmdLine(const QString &cmds)
|
void QMakeEvaluator::visitCmdLine(const QString &cmds)
|
||||||
{
|
{
|
||||||
if (!cmds.isEmpty()) {
|
if (!cmds.isEmpty()) {
|
||||||
if (ProFile *pro = m_parser->parsedProBlock(fL1S("(command line)"), cmds)) {
|
if (ProFile *pro = m_parser->parsedProBlock(cmds, fL1S("(command line)"), -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());
|
||||||
@@ -1591,10 +1591,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBoolFunction(
|
|||||||
return ReturnFalse;
|
return ReturnFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QMakeEvaluator::evaluateConditional(const QString &cond, const QString &context)
|
bool QMakeEvaluator::evaluateConditional(const QString &cond, const QString &where, int line)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
ProFile *pro = m_parser->parsedProBlock(context, cond, QMakeParser::TestGrammar);
|
ProFile *pro = m_parser->parsedProBlock(cond, where, line, QMakeParser::TestGrammar);
|
||||||
if (pro) {
|
if (pro) {
|
||||||
if (pro->isOk()) {
|
if (pro->isOk()) {
|
||||||
m_locationStack.push(m_current);
|
m_locationStack.push(m_current);
|
||||||
@@ -1611,7 +1611,7 @@ void QMakeEvaluator::checkRequirements(const ProStringList &deps)
|
|||||||
{
|
{
|
||||||
ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS"));
|
ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS"));
|
||||||
foreach (const ProString &dep, deps)
|
foreach (const ProString &dep, deps)
|
||||||
if (!evaluateConditional(dep.toQString(), fL1S("(requires)")))
|
if (!evaluateConditional(dep.toQString(), m_current.pro->fileName(), m_current.line))
|
||||||
failed << dep;
|
failed << dep;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -172,7 +172,7 @@ public:
|
|||||||
ProStringList evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr);
|
ProStringList evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr);
|
||||||
VisitReturn evaluateConditionalFunction(const ProKey &function, const ushort *&tokPtr);
|
VisitReturn evaluateConditionalFunction(const ProKey &function, const ushort *&tokPtr);
|
||||||
|
|
||||||
bool evaluateConditional(const QString &cond, const QString &context);
|
bool evaluateConditional(const QString &cond, const QString &where, int line = -1);
|
||||||
#ifdef PROEVALUATOR_FULL
|
#ifdef PROEVALUATOR_FULL
|
||||||
void checkRequirements(const ProStringList &deps);
|
void checkRequirements(const ProStringList &deps);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -194,10 +194,11 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, bool cache)
|
|||||||
return pro;
|
return pro;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProFile *QMakeParser::parsedProBlock(const QString &name, const QString &contents, SubGrammar grammar)
|
ProFile *QMakeParser::parsedProBlock(
|
||||||
|
const QString &contents, const QString &name, int line, SubGrammar grammar)
|
||||||
{
|
{
|
||||||
ProFile *pro = new ProFile(name);
|
ProFile *pro = new ProFile(name);
|
||||||
if (!read(pro, contents, grammar)) {
|
if (!read(pro, contents, line, grammar)) {
|
||||||
delete pro;
|
delete pro;
|
||||||
pro = 0;
|
pro = 0;
|
||||||
}
|
}
|
||||||
@@ -224,7 +225,7 @@ bool QMakeParser::read(ProFile *pro)
|
|||||||
QString content(QString::fromLocal8Bit(bcont));
|
QString content(QString::fromLocal8Bit(bcont));
|
||||||
bcont.clear();
|
bcont.clear();
|
||||||
file.close();
|
file.close();
|
||||||
return read(pro, content, FullGrammar);
|
return read(pro, content, 1, FullGrammar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMakeParser::putTok(ushort *&tokPtr, ushort tok)
|
void QMakeParser::putTok(ushort *&tokPtr, ushort tok)
|
||||||
@@ -264,10 +265,10 @@ 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, SubGrammar grammar)
|
bool QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar grammar)
|
||||||
{
|
{
|
||||||
m_proFile = pro;
|
m_proFile = pro;
|
||||||
m_lineNo = 1;
|
m_lineNo = line;
|
||||||
|
|
||||||
// Final precompiled token stream buffer
|
// Final precompiled token stream buffer
|
||||||
QString tokBuff;
|
QString tokBuff;
|
||||||
|
@@ -79,7 +79,7 @@ public:
|
|||||||
enum SubGrammar { FullGrammar, TestGrammar };
|
enum SubGrammar { FullGrammar, TestGrammar };
|
||||||
// fileName is expected to be absolute and cleanPath()ed.
|
// fileName is expected to be absolute and cleanPath()ed.
|
||||||
ProFile *parsedProFile(const QString &fileName, bool cache = false);
|
ProFile *parsedProFile(const QString &fileName, bool cache = false);
|
||||||
ProFile *parsedProBlock(const QString &name, const QString &contents,
|
ProFile *parsedProBlock(const QString &contents, const QString &name, int line = 0,
|
||||||
SubGrammar grammar = FullGrammar);
|
SubGrammar grammar = FullGrammar);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -109,7 +109,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool read(ProFile *pro);
|
bool read(ProFile *pro);
|
||||||
bool read(ProFile *pro, const QString &content, SubGrammar grammar);
|
bool 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);
|
||||||
|
@@ -39,8 +39,10 @@
|
|||||||
|
|
||||||
static void print(const QString &fileName, int lineNo, const QString &msg)
|
static void print(const QString &fileName, int lineNo, const QString &msg)
|
||||||
{
|
{
|
||||||
if (lineNo)
|
if (lineNo > 0)
|
||||||
qWarning("%s(%d): %s", qPrintable(fileName), lineNo, qPrintable(msg));
|
qWarning("%s(%d): %s", qPrintable(fileName), lineNo, qPrintable(msg));
|
||||||
|
else if (lineNo)
|
||||||
|
qWarning("%s: %s", qPrintable(fileName), qPrintable(msg));
|
||||||
else
|
else
|
||||||
qWarning("%s", qPrintable(msg));
|
qWarning("%s", qPrintable(msg));
|
||||||
}
|
}
|
||||||
|
@@ -47,8 +47,10 @@ static void print(const QString &fileName, int lineNo, int type, const QString &
|
|||||||
{
|
{
|
||||||
QString pfx = ((type & QMakeHandler::CategoryMask) == QMakeHandler::WarningMessage)
|
QString pfx = ((type & QMakeHandler::CategoryMask) == QMakeHandler::WarningMessage)
|
||||||
? QString::fromLatin1("WARNING: ") : QString();
|
? QString::fromLatin1("WARNING: ") : QString();
|
||||||
if (lineNo)
|
if (lineNo > 0)
|
||||||
qWarning("%s%s:%d: %s", qPrintable(pfx), qPrintable(fileName), lineNo, qPrintable(msg));
|
qWarning("%s%s:%d: %s", qPrintable(pfx), qPrintable(fileName), lineNo, qPrintable(msg));
|
||||||
|
else if (lineNo)
|
||||||
|
qWarning("%s%s: %s", qPrintable(pfx), qPrintable(fileName), qPrintable(msg));
|
||||||
else
|
else
|
||||||
qWarning("%s%s", qPrintable(pfx), qPrintable(msg));
|
qWarning("%s%s", qPrintable(pfx), qPrintable(msg));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user