Skip to content
Snippets Groups Projects
Commit 044915b2 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Clang: Improve parser

Change-Id: Ic28973ddc81968075aa6e0ac31c02612589f8024
Reviewed-on: http://codereview.qt.nokia.com/33


Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent c31bc05e
No related branches found
No related tags found
No related merge requests found
...@@ -45,9 +45,9 @@ namespace { ...@@ -45,9 +45,9 @@ namespace {
} }
ClangParser::ClangParser() : ClangParser::ClangParser() :
m_commandRegExp(QLatin1String("^clang(\\+\\+)?: (warning|error|note): (.*)$")), m_commandRegExp(QLatin1String("^clang(\\+\\+)?: +(fatal +)?(warning|error|note): (.*)$")),
m_inLineRegExp(QLatin1String("^In (.*) included from (.*):(\\d+):$")), m_inLineRegExp(QLatin1String("^In (.*) included from (.*):(\\d+):$")),
m_messageRegExp(QLatin1String("^") + QLatin1String(FILE_PATTERN) + QLatin1String("(:(\\d+):\\d+|\\((\\d+)\\) ): +(error|warning|note): (.*)$")) m_messageRegExp(QLatin1String("^") + QLatin1String(FILE_PATTERN) + QLatin1String("(:(\\d+):\\d+|\\((\\d+)\\) *): +(fatal +)?(error|warning|note): (.*)$"))
{ {
setObjectName(QLatin1String("ClangParser")); setObjectName(QLatin1String("ClangParser"));
...@@ -66,13 +66,13 @@ void ClangParser::stdError(const QString &line) ...@@ -66,13 +66,13 @@ void ClangParser::stdError(const QString &line)
if (m_commandRegExp.indexIn(lne) > -1) { if (m_commandRegExp.indexIn(lne) > -1) {
m_codeSnippet.clear(); m_codeSnippet.clear();
newTask(Task::Error, newTask(Task::Error,
m_commandRegExp.cap(3), m_commandRegExp.cap(4),
QString(), /* filename */ QString(), /* filename */
-1, /* line */ -1, /* line */
Constants::TASK_CATEGORY_COMPILE); Constants::TASK_CATEGORY_COMPILE);
if (m_commandRegExp.cap(2) == QLatin1String("warning")) if (m_commandRegExp.cap(3) == QLatin1String("warning"))
m_currentTask.type = Task::Warning; m_currentTask.type = Task::Warning;
else if (m_commandRegExp.cap(2) == QLatin1String("note")) else if (m_commandRegExp.cap(3) == QLatin1String("note"))
m_currentTask.type = Task::Unknown; m_currentTask.type = Task::Unknown;
return; return;
} }
...@@ -94,13 +94,13 @@ void ClangParser::stdError(const QString &line) ...@@ -94,13 +94,13 @@ void ClangParser::stdError(const QString &line)
if (!ok) if (!ok)
lineNo = m_messageRegExp.cap(5).toInt(&ok); lineNo = m_messageRegExp.cap(5).toInt(&ok);
newTask(Task::Error, newTask(Task::Error,
m_messageRegExp.cap(7), m_messageRegExp.cap(8),
m_messageRegExp.cap(1), /* filename */ m_messageRegExp.cap(1), /* filename */
lineNo, lineNo,
Constants::TASK_CATEGORY_COMPILE); Constants::TASK_CATEGORY_COMPILE);
if (m_messageRegExp.cap(6) == "warning") if (m_messageRegExp.cap(7) == "warning")
m_currentTask.type = Task::Warning; m_currentTask.type = Task::Warning;
else if (m_messageRegExp.cap(6) == "note") else if (m_messageRegExp.cap(7) == "note")
m_currentTask.type = Task::Unknown; m_currentTask.type = Task::Unknown;
return; return;
} }
...@@ -233,6 +233,20 @@ void ProjectExplorerPlugin::testClangOutputParser_data() ...@@ -233,6 +233,20 @@ void ProjectExplorerPlugin::testClangOutputParser_data()
QLatin1String("..\\..\\..\\QtSDK1.1\\Desktop\\Qt\\4.7.3\\mingw\\include/QtCore/qglobal.h"), 1289, QLatin1String("..\\..\\..\\QtSDK1.1\\Desktop\\Qt\\4.7.3\\mingw\\include/QtCore/qglobal.h"), 1289,
Constants::TASK_CATEGORY_COMPILE)) Constants::TASK_CATEGORY_COMPILE))
<< QString(); << QString();
QTest::newRow("fatal error")
<< QString::fromLatin1("/usr/include/c++/4.6/utility:68:10: fatal error: 'bits/c++config.h' file not found\n"
"#include <bits/c++config.h>\n"
" ^")
<< OutputParserTester::STDERR
<< QString() << QString::fromLatin1("#include <bits/c++config.h>\n")
<< (QList<ProjectExplorer::Task>()
<< Task(Task::Error,
QLatin1String("'bits/c++config.h' file not found\n"
"#include <bits/c++config.h>\n"
" ^"),
QLatin1String("/usr/include/c++/4.6/utility"), 68,
Constants::TASK_CATEGORY_COMPILE))
<< QString();
} }
void ProjectExplorerPlugin::testClangOutputParser() void ProjectExplorerPlugin::testClangOutputParser()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment