diff options
author | Chen Bin <chenbin@uniontech.com> | 2021-08-24 11:33:26 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-03 06:18:09 +0000 |
commit | 7ccc122d77165470af873dcb50331442f3d877c2 (patch) | |
tree | 098c132d3abce5a1b951c1d976ebda6bb239a3d9 | |
parent | 628ff9d48a54eae6d693c072151f40ea8f25603c (diff) |
Identify files with the same name in the project
If multiple subprojects of a subdirectory project have files with the
same name, QDoc will not recognize them properly. It replaces the
previous file path with the later identified file. And the contents of
the tmpHeader file in the clang_parseTranslationUnit2 function don't
contain all files of the same name.
Fixes: QTBUG-95981
Change-Id: Ic65f568ea89a6933c155a36f7f374627bff13555
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit 77af6b22041ac0f67803ef4fd1d5258a821cd8ff)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 14 | ||||
-rw-r--r-- | src/qdoc/clangcodeparser.h | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index f037e4ed8..4bd5a7fe8 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -399,7 +399,7 @@ static void setOverridesForFunction(FunctionNode *fn, CXCursor cursor) class ClangVisitor { public: - ClangVisitor(QDocDatabase *qdb, const QHash<QString, QString> &allHeaders) + ClangVisitor(QDocDatabase *qdb, const QMultiHash<QString, QString> &allHeaders) : qdb_(qdb), parent_(qdb->primaryTreeRoot()), allHeaders_(allHeaders) { } @@ -473,7 +473,7 @@ private: QDocDatabase *qdb_; Aggregate *parent_; bool m_friendDecl { false }; // true if currently visiting a friend declaration - const QHash<QString, QString> allHeaders_; + const QMultiHash<QString, QString> allHeaders_; QHash<CXFile, bool> isInterestingCache_; // doing a canonicalFilePath is slow, so keep a cache. /*! @@ -1200,7 +1200,13 @@ QStringList ClangCodeParser::sourceFileNameFilter() void ClangCodeParser::parseHeaderFile(const Location & /*location*/, const QString &filePath) { QFileInfo fi(filePath); - m_allHeaders.insert(fi.fileName(), fi.canonicalPath()); + const QString &fileName = fi.fileName(); + const QString &canonicalPath = fi.canonicalPath(); + + if (m_allHeaders.contains(fileName, canonicalPath)) + return; + + m_allHeaders.insert(fileName, canonicalPath); } static const char *defaultArgs_[] = { @@ -1238,7 +1244,7 @@ void ClangCodeParser::getDefaultArgs() m_args.push_back(p.constData()); } -static QList<QByteArray> includePathsFromHeaders(const QHash<QString, QString> &allHeaders) +static QList<QByteArray> includePathsFromHeaders(const QMultiHash<QString, QString> &allHeaders) { QList<QByteArray> result; for (auto it = allHeaders.cbegin(); it != allHeaders.cend(); ++it) { diff --git a/src/qdoc/clangcodeparser.h b/src/qdoc/clangcodeparser.h index 0aeb8a44e..cd1f34eeb 100644 --- a/src/qdoc/clangcodeparser.h +++ b/src/qdoc/clangcodeparser.h @@ -73,7 +73,7 @@ private: void printDiagnostics(const CXTranslationUnit &translationUnit) const; QString m_version {}; - QHash<QString, QString> m_allHeaders {}; // file name->path + QMultiHash<QString, QString> m_allHeaders {}; // file name->path QList<QByteArray> m_includePaths {}; QScopedPointer<QTemporaryDir> m_pchFileDir {}; QByteArray m_pchName {}; |