diff options
| author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-10-10 12:01:59 +0300 |
|---|---|---|
| committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-10-10 12:01:59 +0300 |
| commit | cf5106463bd3aeb78a6a51839673b0e4f008fd82 (patch) | |
| tree | b675d72375ae88453e1118c4e7be627f94fccd7c /src/linguist/lupdate/cpp.h | |
| parent | 786bdcbf8cdc7ba3d4e5a8c15e1ead03c5926967 (diff) | |
| parent | 6444be988641a3a96a49fb39f28af2c532397e65 (diff) | |
Merge tag 'v6.5.7-lts' into tqtc/lts-6.5-opensourcev6.5.7-lts-lgpl6.5
Qt 6.5.7-lts release
Conflicts solved:
dependencies.yaml
Change-Id: I17f2889bbcdd447aacb628177f1df4cad4b2cd16
Diffstat (limited to 'src/linguist/lupdate/cpp.h')
| -rw-r--r-- | src/linguist/lupdate/cpp.h | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/src/linguist/lupdate/cpp.h b/src/linguist/lupdate/cpp.h index ca3cd72f9..8f6497195 100644 --- a/src/linguist/lupdate/cpp.h +++ b/src/linguist/lupdate/cpp.h @@ -7,6 +7,7 @@ #include "lupdate.h" #include <QtCore/QSet> +#include <QtCore/QStack> #include <iostream> @@ -79,19 +80,63 @@ struct IncludeCycle { QSet<const ParseResults *> results; }; -typedef QHash<QString, IncludeCycle *> IncludeCycleHash; +struct CppParserState +{ + NamespaceList namespaces; + QStack<qsizetype> namespaceDepths; + NamespaceList functionContext; + QString functionContextUnresolved; + QString pendingContext; + + bool operator==(const CppParserState &other) const + { + return namespaces == other.namespaces + && namespaceDepths == other.namespaceDepths + && functionContext == other.functionContext + && functionContextUnresolved == other.functionContextUnresolved + && pendingContext == other.pendingContext; + } +}; + +size_t qHash(const CppParserState &s, size_t seed); + +struct ResultsCacheKey +{ + const QString cleanFile; + const CppParserState parserState; + + ResultsCacheKey(const QString &filePath) + : cleanFile(filePath) + { + } + + ResultsCacheKey(const QString &filePath, const CppParserState &state) + : cleanFile(filePath), + parserState(state) + { + } + + bool operator==(const ResultsCacheKey &other) const + { + return cleanFile == other.cleanFile + && parserState == other.parserState; + } +}; + +size_t qHash(const ResultsCacheKey &key, size_t seed); + +typedef QHash<ResultsCacheKey, IncludeCycle *> IncludeCycleHash; typedef QHash<QString, const Translator *> TranslatorHash; class CppFiles { - public: - static QSet<const ParseResults *> getResults(const QString &cleanFile); - static void setResults(const QString &cleanFile, const ParseResults *results); + static QSet<const ParseResults *> getResults(const ResultsCacheKey &key); + static void setResults(const ResultsCacheKey &key, const ParseResults *results); static const Translator *getTranslator(const QString &cleanFile); static void setTranslator(const QString &cleanFile, const Translator *results); static bool isBlacklisted(const QString &cleanFile); static void setBlacklisted(const QString &cleanFile); - static void addIncludeCycle(const QSet<QString> &fileNames); + static void addIncludeCycle(const QSet<QString> &fileNames, const CppParserState &parserState); private: static IncludeCycleHash &includeCycles(); |
