From ce895f066579f71d87c3b46361e291ad7734e88e Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 25 Feb 2020 15:09:12 +0100 Subject: QDoc: Fix handling of -F option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even though it was documented to use -F to pass framework paths to QDoc (macOS), that was not working and instead passing "-I-Fthe_path_that_was_specified" to Clang. [ChangeLog][qdoc] Fixed "-F" option on macOS Task-number: QTBUG-82252 Change-Id: Ib85e3affad5487e428a8eccf0c239b437c75b759 Reviewed-by: Cristian Adam Reviewed-by: Topi Reiniƶ --- src/qdoc/clangcodeparser.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 5e04c344e..f39d69354 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -1050,25 +1050,29 @@ void ClangCodeParser::initializeParser(const Config &config) printParsingErrors_ = 1; version_ = config.getString(CONFIG_VERSION); const auto args = config.getStringList(CONFIG_INCLUDEPATHS); - QStringList squeezedArgs; + QSet seen; + includePaths_.clear(); + // Remove empty paths and duplicates and add -I and canonicalize if necessary for (const auto &p : args) { - if (p.startsWith(QLatin1String("-I"))) - squeezedArgs << p.mid(2).trimmed(); - else - squeezedArgs << p; + QByteArray option; + QString rawpath; + if (p.startsWith(QLatin1String("-I")) || p.startsWith(QLatin1String("-F"))) { + rawpath = p.mid(2).trimmed(); + option = p.left(2).toUtf8(); + } else { + rawpath = p; + option = "-I"; + } + if (rawpath.isEmpty() || seen.contains(rawpath)) + continue; + seen.insert(rawpath); + QByteArray path(rawpath.toUtf8()); + QFileInfo fi(QDir::current(), rawpath); + if (fi.exists()) + path = fi.canonicalFilePath().toUtf8(); + path.prepend(option); + includePaths_.append(path); } - // Remove empty paths and duplicates - squeezedArgs.removeAll({}); - squeezedArgs.removeDuplicates(); - includePaths_.resize(squeezedArgs.size()); - std::transform(squeezedArgs.begin(), squeezedArgs.end(), includePaths_.begin(), - [](const QString &s) { - QByteArray path(s.toUtf8()); - QFileInfo fi(QDir::current(), s); - if (fi.exists()) - path = fi.canonicalFilePath().toUtf8(); - return path.prepend("-I"); - }); CppCodeParser::initializeParser(config); pchFileDir_.reset(nullptr); allHeaders_.clear(); -- cgit v1.2.3