From 863178beafc1ab903f1425d56a3e591f4c29cb4e Mon Sep 17 00:00:00 2001
From: Edward Welbourne <edward.welbourne@qt.io>
Date: Fri, 2 Mar 2018 17:46:26 +0100
Subject: [PATCH] Revert the heinous sysinc hack qdoc needed for clang 3.9
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commits c95cba39a68bea4dc4c3c003e768412f0640e24f and
65d817345faf34cf9e5cc4f203b276de906fd84a.  Apparently clang is now
smart enough to handle its system include paths itself; and trying to
"help" was causing problems.  It was, in any case, a heinous hack.

Task-number: QTBUG-66746
Change-Id: I485c6acddfd89f91a4b719f2e2e049ff76a61ce9
Reviewed-by: Martin Smith <martin.smith@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
---
 src/qdoc/main.cpp | 32 +-------------------------------
 src/qdoc/qdoc.pro |  3 ---
 2 files changed, 1 insertion(+), 34 deletions(-)

diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp
index 5232d3a24..a328b7af1 100644
--- a/src/qdoc/main.cpp
+++ b/src/qdoc/main.cpp
@@ -26,16 +26,6 @@
 **
 ****************************************************************************/
 
-#ifdef HEINOUS_SYSINC_HACK // There must be no #include before this !
-#define setlocale locale_file_name_for_clang_qdoc() { \
-        static char data[] = __FILE__;           \
-        return data;                             \
-    }                                            \
-    extern char *setlocale
-#include <locale.h>
-#undef setlocale
-#endif // HEINOUS_SYSINC_HACK
-
 #include <qglobal.h>
 #include <qhashfunctions.h>
 #include <stdlib.h>
@@ -665,22 +655,6 @@ QDocCommandLineParser::QDocCommandLineParser()
     addOption(frameworkOption);
 }
 
-#ifdef HEINOUS_SYSINC_HACK
-/*!
-  Return the system include directory used when compiling this file.
- */
-static QByteArray getSystemIncludePath()
-{
-    const char *raw = locale_file_name_for_clang_qdoc();
-    const char *slash = strrchr(raw, '/');
-    if (slash == NULL)
-        slash = strrchr(raw, '\\');
-    if (slash == NULL)
-        return QByteArray();
-    return QByteArray(raw, slash - raw);
-}
-#endif // HEINOUS_SYSINC_HACK
-
 void QDocCommandLineParser::process(const QCoreApplication &app)
 {
     QCommandLineParser::process(app);
@@ -730,11 +704,7 @@ void QDocCommandLineParser::process(const QCoreApplication &app)
     const auto paths = values(includePathOption);
     for (const auto &i : paths)
         includesPaths << "-I" << currentDir.absoluteFilePath(i);
-    auto paths2 = values(includePathSystemOption);
-#ifdef HEINOUS_SYSINC_HACK
-    if (paths2.isEmpty())
-        paths2 << QString(getSystemIncludePath());
-#endif // HEINOUS_SYSINC_HACK
+    const auto paths2 = values(includePathSystemOption);
     for (const auto &i : paths2)
         includesPaths << "-isystem" << currentDir.absoluteFilePath(i);
     const auto paths3 = values(frameworkOption);
diff --git a/src/qdoc/qdoc.pro b/src/qdoc/qdoc.pro
index 38fa8b550..e3b431aa9 100644
--- a/src/qdoc/qdoc.pro
+++ b/src/qdoc/qdoc.pro
@@ -26,9 +26,6 @@ INCLUDEPATH += $$QT_SOURCE_TREE/src/tools/qdoc \
 # Increase the stack size on MSVC to 4M to avoid a stack overflow
 win32-icc*|win32-msvc*:{
     QMAKE_LFLAGS += /STACK:4194304
-} else {
-    # (MSVC objects to defining a function in the locale.h dllimport context)
-    DEFINES += HEINOUS_SYSINC_HACK
 }
 
 HEADERS += atom.h \
-- 
GitLab