summaryrefslogtreecommitdiff
path: root/src/qdoc/clangcodeparser.cpp
diff options
context:
space:
mode:
authorChen Bin <chenbin@uniontech.com>2021-08-24 11:33:26 +0800
committerChen Bin <chenbin@uniontech.com>2021-09-03 05:49:51 +0000
commit77af6b22041ac0f67803ef4fd1d5258a821cd8ff (patch)
tree620d23c95e212cbd395ed055e1bb02ac5648f948 /src/qdoc/clangcodeparser.cpp
parentc2ae4614b36b638d6d2a181bd82fc34f64765639 (diff)
downloadqttools-77af6b22041ac0f67803ef4fd1d5258a821cd8ff.tar.gz
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 Pick-to: 6.2 Change-Id: Ic65f568ea89a6933c155a36f7f374627bff13555 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/clangcodeparser.cpp')
-rw-r--r--src/qdoc/clangcodeparser.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index 46c237114..b8feca108 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.
/*!
@@ -1208,7 +1208,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_[] = {
@@ -1246,7 +1252,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) {