From 879f71c2a35ab3f7f6286e88396455adca7ba847 Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Wed, 31 Mar 2010 15:41:16 +0200
Subject: [PATCH] Fix some false positives in the build issues

 * "In blah method " messages are informative, not errors.
 * Be more picky about file names: Stops errors from ranlib, rm,
   etc. being reported as build issues.
---
 src/plugins/projectexplorer/gccparser.cpp | 38 ++++++++++++++++++++---
 src/plugins/projectexplorer/gccparser.h   |  1 +
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/src/plugins/projectexplorer/gccparser.cpp b/src/plugins/projectexplorer/gccparser.cpp
index 24999e3cf42..ea2f2e359e8 100644
--- a/src/plugins/projectexplorer/gccparser.cpp
+++ b/src/plugins/projectexplorer/gccparser.cpp
@@ -35,7 +35,7 @@ using namespace ProjectExplorer;
 
 namespace {
     // opt. drive letter + filename: (2 brackets)
-    const char * const FILE_PATTERN("^(([a-zA-Z]:)?[^:]*):");
+    const char * const FILE_PATTERN("^(([A-Za-z]:)?[^:]+\\.[^:]+):");
     // line no. or elf segment + offset: (1 bracket)
     const char * const POSITION_PATTERN("(\\d+|\\(\\.[a-zA-Z0-9]*.0x[a-fA-F0-9]+\\)):");
 }
@@ -51,9 +51,11 @@ GccParser::GccParser()
     m_regExpLinker.setPattern(QString::fromLatin1(FILE_PATTERN) + '(' + QLatin1String(POSITION_PATTERN) + ")?\\s(.+)$");
     m_regExpLinker.setMinimal(true);
 
-    // m_regExpGccNames.setPattern("^([a-z0-9]+-[a-z0-9]+-[a-z0-9]+-)(gcc|g\\+\\+)(-[0-9\\.]+)?:");
-    m_regExpGccNames.setPattern("^(gcc|g\\+\\+):\\s");
+    m_regExpGccNames.setPattern("^([a-z0-9]+-[a-z0-9]+-[a-z0-9]+-)?(gcc|g\\+\\+)(-[0-9\\.]+)?: ");
     m_regExpGccNames.setMinimal(true);
+
+    m_regExpInFunction.setPattern("^In (static |member )*function ");
+    m_regExpInFunction.setMinimal(true);
 }
 
 void GccParser::stdError(const QString &line)
@@ -123,8 +125,7 @@ void GccParser::stdError(const QString &line)
                   m_regExpLinker.cap(1) /* filename */,
                   lineno,
                   Constants::TASK_CATEGORY_COMPILE);
-        if (description.startsWith(QLatin1String("In function ")) ||
-            description.startsWith(QLatin1String("In member function ")))
+        if (m_regExpInFunction.indexIn(description) > -1)
             task.type = Task::Unknown;
 
         emit addTask(task);
@@ -385,6 +386,33 @@ void ProjectExplorerPlugin::testGccOutputParsers_data()
                          QString::fromLatin1("/home/dev/creator/share/qtcreator/gdbmacros/gdbmacros.cpp"), 1079,
                          Constants::TASK_CATEGORY_COMPILE))
             << QString();
+    QTest::newRow("static member function")
+            << QString::fromLatin1("/Qt/4.6.2-Symbian/s60sdk/epoc32/include/stdapis/stlport/stl/_tree.c: In static member function 'static std::_Rb_tree_node_base* std::_Rb_global<_Dummy>::_Rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*&, std::_Rb_tree_node_base*&, std::_Rb_tree_node_base*&)':\n"
+                                   "/Qt/4.6.2-Symbian/s60sdk/epoc32/include/stdapis/stlport/stl/_tree.c:194: warning: suggest explicit braces to avoid ambiguous 'else'")
+            << OutputParserTester::STDERR
+            << QString() << QString()
+            << ( QList<ProjectExplorer::Task>()
+                 << Task(Task::Unknown,
+                         QLatin1String("In static member function 'static std::_Rb_tree_node_base* std::_Rb_global<_Dummy>::_Rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*&, std::_Rb_tree_node_base*&, std::_Rb_tree_node_base*&)':"),
+                         QString::fromLatin1("/Qt/4.6.2-Symbian/s60sdk/epoc32/include/stdapis/stlport/stl/_tree.c"), -1,
+                         Constants::TASK_CATEGORY_COMPILE)
+                 << Task(Task::Warning,
+                         QLatin1String("suggest explicit braces to avoid ambiguous 'else'"),
+                         QString::fromLatin1("/Qt/4.6.2-Symbian/s60sdk/epoc32/include/stdapis/stlport/stl/_tree.c"), 194,
+                         Constants::TASK_CATEGORY_COMPILE))
+            << QString();
+    QTest::newRow("rm false positive")
+            << QString::fromLatin1("rm: cannot remove `release/moc_mainwindow.cpp': No such file or directory")
+            << OutputParserTester::STDERR
+            << QString() << QString("rm: cannot remove `release/moc_mainwindow.cpp': No such file or directory")
+            << QList<ProjectExplorer::Task>()
+            << QString();
+    QTest::newRow("ranlib false positive")
+            << QString::fromLatin1("ranlib: file: libSupport.a(HashTable.o) has no symbols")
+            << OutputParserTester::STDERR
+            << QString() << QString("ranlib: file: libSupport.a(HashTable.o) has no symbols")
+            << QList<ProjectExplorer::Task>()
+            << QString();
 }
 
 void ProjectExplorerPlugin::testGccOutputParsers()
diff --git a/src/plugins/projectexplorer/gccparser.h b/src/plugins/projectexplorer/gccparser.h
index 0db880e3b7c..ecae3d6d95b 100644
--- a/src/plugins/projectexplorer/gccparser.h
+++ b/src/plugins/projectexplorer/gccparser.h
@@ -49,6 +49,7 @@ private:
     QRegExp m_regExpIncluded;
     QRegExp m_regExpLinker;
     QRegExp m_regExpGccNames;
+    QRegExp m_regExpInFunction;
 };
 
 } // namespace ProjectExplorer
-- 
GitLab