summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-08-22 11:19:54 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-09-03 17:56:24 +0200
commit00e9be42463d012d6288ad03bed9ee37e179c35f (patch)
tree541c9b8cf3b280c2b18ef1980a1b635386819ba7
parent26e9f25a3ee260b95be7e08e0236698c50053290 (diff)
downloadqt-creator-00e9be42463d012d6288ad03bed9ee37e179c35f.tar.gz
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>
-rw-r--r--src/plugins/qtsupport/profilereader.cpp4
-rw-r--r--src/shared/proparser/qmakebuiltins.cpp7
-rw-r--r--src/shared/proparser/qmakeevaluator.cpp8
-rw-r--r--src/shared/proparser/qmakeevaluator.h2
-rw-r--r--src/shared/proparser/qmakeparser.cpp11
-rw-r--r--src/shared/proparser/qmakeparser.h4
-rw-r--r--tests/auto/profilewriter/tst_profilewriter.cpp4
-rw-r--r--tests/manual/proparser/main.cpp4
8 files changed, 26 insertions, 18 deletions
diff --git a/src/plugins/qtsupport/profilereader.cpp b/src/plugins/qtsupport/profilereader.cpp
index b2508b28c9..0612e4f4e3 100644
--- a/src/plugins/qtsupport/profilereader.cpp
+++ b/src/plugins/qtsupport/profilereader.cpp
@@ -40,8 +40,10 @@ using namespace QtSupport;
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);
+ else if (lineNo)
+ return QString::fromLatin1("%1: %3").arg(fileName, msg);
else
return msg;
}
diff --git a/src/shared/proparser/qmakebuiltins.cpp b/src/shared/proparser/qmakebuiltins.cpp
index b8db3577aa..d5d1ce0141 100644
--- a/src/shared/proparser/qmakebuiltins.cpp
+++ b/src/shared/proparser/qmakebuiltins.cpp
@@ -1160,8 +1160,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
#endif
case T_EVAL: {
VisitReturn ret = ReturnFalse;
- ProFile *pro = m_parser->parsedProBlock(fL1S("(eval)"),
- args.join(statics.field_sep));
+ ProFile *pro = m_parser->parsedProBlock(args.join(statics.field_sep),
+ m_current.pro->fileName(), m_current.line);
if (pro) {
if (m_cumulative || pro->isOk()) {
m_locationStack.push(m_current);
@@ -1192,7 +1192,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction(
evalError(fL1S("if(condition) requires one argument."));
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: {
if (args.count() < 1 || args.count() > 2) {
diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp
index 81c2c23a87..2313d77b5b 100644
--- a/src/shared/proparser/qmakeevaluator.cpp
+++ b/src/shared/proparser/qmakeevaluator.cpp
@@ -1200,7 +1200,7 @@ void QMakeEvaluator::setupProject()
void QMakeEvaluator::visitCmdLine(const QString &cmds)
{
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()) {
m_locationStack.push(m_current);
visitProBlock(pro, pro->tokPtr());
@@ -1591,10 +1591,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBoolFunction(
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;
- ProFile *pro = m_parser->parsedProBlock(context, cond, QMakeParser::TestGrammar);
+ ProFile *pro = m_parser->parsedProBlock(cond, where, line, QMakeParser::TestGrammar);
if (pro) {
if (pro->isOk()) {
m_locationStack.push(m_current);
@@ -1611,7 +1611,7 @@ void QMakeEvaluator::checkRequirements(const ProStringList &deps)
{
ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS"));
foreach (const ProString &dep, deps)
- if (!evaluateConditional(dep.toQString(), fL1S("(requires)")))
+ if (!evaluateConditional(dep.toQString(), m_current.pro->fileName(), m_current.line))
failed << dep;
}
#endif
diff --git a/src/shared/proparser/qmakeevaluator.h b/src/shared/proparser/qmakeevaluator.h
index e08a1f525d..41820de805 100644
--- a/src/shared/proparser/qmakeevaluator.h
+++ b/src/shared/proparser/qmakeevaluator.h
@@ -172,7 +172,7 @@ public:
ProStringList evaluateExpandFunction(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
void checkRequirements(const ProStringList &deps);
#endif
diff --git a/src/shared/proparser/qmakeparser.cpp b/src/shared/proparser/qmakeparser.cpp
index 055cb3e7e9..4bd3432279 100644
--- a/src/shared/proparser/qmakeparser.cpp
+++ b/src/shared/proparser/qmakeparser.cpp
@@ -194,10 +194,11 @@ ProFile *QMakeParser::parsedProFile(const QString &fileName, bool cache)
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);
- if (!read(pro, contents, grammar)) {
+ if (!read(pro, contents, line, grammar)) {
delete pro;
pro = 0;
}
@@ -224,7 +225,7 @@ bool QMakeParser::read(ProFile *pro)
QString content(QString::fromLocal8Bit(bcont));
bcont.clear();
file.close();
- return read(pro, content, FullGrammar);
+ return read(pro, content, 1, FullGrammar);
}
void QMakeParser::putTok(ushort *&tokPtr, ushort tok)
@@ -264,10 +265,10 @@ void QMakeParser::finalizeHashStr(ushort *buf, uint len)
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_lineNo = 1;
+ m_lineNo = line;
// Final precompiled token stream buffer
QString tokBuff;
diff --git a/src/shared/proparser/qmakeparser.h b/src/shared/proparser/qmakeparser.h
index 824c78106b..32b11f5e28 100644
--- a/src/shared/proparser/qmakeparser.h
+++ b/src/shared/proparser/qmakeparser.h
@@ -79,7 +79,7 @@ public:
enum SubGrammar { FullGrammar, TestGrammar };
// fileName is expected to be absolute and cleanPath()ed.
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);
private:
@@ -109,7 +109,7 @@ private:
};
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 putBlockLen(ushort *&tokPtr, uint len);
diff --git a/tests/auto/profilewriter/tst_profilewriter.cpp b/tests/auto/profilewriter/tst_profilewriter.cpp
index e063b77efd..23c37c0da9 100644
--- a/tests/auto/profilewriter/tst_profilewriter.cpp
+++ b/tests/auto/profilewriter/tst_profilewriter.cpp
@@ -39,8 +39,10 @@
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));
+ else if (lineNo)
+ qWarning("%s: %s", qPrintable(fileName), qPrintable(msg));
else
qWarning("%s", qPrintable(msg));
}
diff --git a/tests/manual/proparser/main.cpp b/tests/manual/proparser/main.cpp
index fe73366f03..1fbb4b2eb5 100644
--- a/tests/manual/proparser/main.cpp
+++ b/tests/manual/proparser/main.cpp
@@ -47,8 +47,10 @@ static void print(const QString &fileName, int lineNo, int type, const QString &
{
QString pfx = ((type & QMakeHandler::CategoryMask) == QMakeHandler::WarningMessage)
? QString::fromLatin1("WARNING: ") : QString();
- if (lineNo)
+ if (lineNo > 0)
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
qWarning("%s%s", qPrintable(pfx), qPrintable(msg));
}