From 044915b2c18708c3f7f99e6c76a09441302764f4 Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@nokia.com> Date: Fri, 20 May 2011 11:57:30 +0200 Subject: [PATCH] Clang: Improve parser Change-Id: Ic28973ddc81968075aa6e0ac31c02612589f8024 Reviewed-on: http://codereview.qt.nokia.com/33 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com> --- src/plugins/projectexplorer/clangparser.cpp | 30 +++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/plugins/projectexplorer/clangparser.cpp b/src/plugins/projectexplorer/clangparser.cpp index 18af1852bb2..b0b1b395682 100644 --- a/src/plugins/projectexplorer/clangparser.cpp +++ b/src/plugins/projectexplorer/clangparser.cpp @@ -45,9 +45,9 @@ namespace { } 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_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")); @@ -66,13 +66,13 @@ void ClangParser::stdError(const QString &line) if (m_commandRegExp.indexIn(lne) > -1) { m_codeSnippet.clear(); newTask(Task::Error, - m_commandRegExp.cap(3), + m_commandRegExp.cap(4), QString(), /* filename */ -1, /* line */ Constants::TASK_CATEGORY_COMPILE); - if (m_commandRegExp.cap(2) == QLatin1String("warning")) + if (m_commandRegExp.cap(3) == QLatin1String("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; return; } @@ -94,13 +94,13 @@ void ClangParser::stdError(const QString &line) if (!ok) lineNo = m_messageRegExp.cap(5).toInt(&ok); newTask(Task::Error, - m_messageRegExp.cap(7), + m_messageRegExp.cap(8), m_messageRegExp.cap(1), /* filename */ lineNo, Constants::TASK_CATEGORY_COMPILE); - if (m_messageRegExp.cap(6) == "warning") + if (m_messageRegExp.cap(7) == "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; return; } @@ -233,6 +233,20 @@ void ProjectExplorerPlugin::testClangOutputParser_data() QLatin1String("..\\..\\..\\QtSDK1.1\\Desktop\\Qt\\4.7.3\\mingw\\include/QtCore/qglobal.h"), 1289, Constants::TASK_CATEGORY_COMPILE)) << 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() -- GitLab