From 713af3ea43c838a3015d00b924cad69191333977 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 5 Apr 2019 11:45:26 +0200 Subject: qdoc: Turn off clang errors in PCH build without include paths When the build system can't pass qdoc the include paths to qdoc, qdoc tries to guess reasonable include paths. There has been one case running qdoc on macOS for the QtPlatformHeaders module, where qdoc must try to guess the include paths. The guessed paths are not sufficient, and clang prints a large number of errors caused by missing stuff. This change tells clang not to report errors during the PCH build if qdoc had to guess the include paths. qdoc reports in its log that it guessed the include paths and that it turned off the clang error reporting. Change-Id: I91a4242dcc7d3017d511d969621cc3d673c47963 Reviewed-by: Paul Wicking --- src/qdoc/clangcodeparser.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/qdoc/clangcodeparser.cpp') diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index b8774b4a7..5bda5296b 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -1148,10 +1148,22 @@ static QVector includePathsFromHeaders(const QHash } /*! - Load the include paths into \a moreArgs. + Load the include paths into \a moreArgs and return false. + If no include paths were provided, try to guess reasonable + include paths but return true, so the clang diagnostics + can be turned off during PCH creation. + + The use case for returning true is the QtPlatformHeaders + module when running qdoc on macOS. For some reason, the + include paths are not passed to qdoc, so it guesses them. + This results in clang reporting a large number of errors + during the PCH build. The errors are useles, except that + it probably means the build system isn't working correctly + for QtPlatformHeaders when running qdoc. */ -void ClangCodeParser::getMoreArgs() +bool ClangCodeParser::getMoreArgs() { + bool guessedIncludePaths = false; if (includePaths_.isEmpty()) { Location::logToStdErrAlways("No include paths passed to qdoc"); Location::logToStdErrAlways("Guess reasonable include paths:"); @@ -1160,6 +1172,7 @@ void ClangCodeParser::getMoreArgs() of reasonable places to look for include files and use that list instead. */ + guessedIncludePaths = true; auto forest = qdb_->searchOrder(); QByteArray version = qdb_->version().toUtf8(); @@ -1190,6 +1203,7 @@ void ClangCodeParser::getMoreArgs() moreArgs_[i] = fi.canonicalFilePath().toLatin1(); } } + return guessedIncludePaths; } /*! @@ -1306,7 +1320,8 @@ void ClangCodeParser::buildPCH() void ClangCodeParser::precompileHeaders() { getDefaultArgs(); - getMoreArgs(); + if (getMoreArgs()) + printParsingErrors_ = 0; for (const auto &p : qAsConst(moreArgs_)) args_.push_back(p.constData()); -- cgit v1.2.1