diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2024-10-23 10:14:23 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2024-11-06 11:42:02 +0100 |
| commit | cb52469a03160531730e6b1a05892838f36ae899 (patch) | |
| tree | a5e7b6f2d2c8b835e066b6165012ca0a4f61537b | |
| parent | 012f827c2d9776c92b7ffd169f2f77e2a02dbd88 (diff) | |
aotstats: Keep track of files and modules with no functions or bindings
Before this change, the report presented to the user would be
completely silent about them. For the sake of consitency, register each
file before trying to compile it. This will then add an entry for empty
files and modules.
Task-number: QTBUG-124667
Change-Id: I502660b7a16a67a173763f9ea2b081cbcceb5658
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
(cherry picked from commit 4dab304aeb42d1237f3eba863eeb66ba2a18b2b0)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| -rw-r--r-- | src/qmlcompiler/qqmljscompilerstats.cpp | 17 | ||||
| -rw-r--r-- | src/qmlcompiler/qqmljscompilerstats_p.h | 8 | ||||
| -rw-r--r-- | tools/qmlcachegen/qmlcachegen.cpp | 1 |
3 files changed, 20 insertions, 6 deletions
diff --git a/src/qmlcompiler/qqmljscompilerstats.cpp b/src/qmlcompiler/qqmljscompilerstats.cpp index f5c2a828d3..f117aaf0cf 100644 --- a/src/qmlcompiler/qqmljscompilerstats.cpp +++ b/src/qmlcompiler/qqmljscompilerstats.cpp @@ -26,7 +26,7 @@ bool QQmlJS::AotStatsEntry::operator<(const AotStatsEntry &other) const return line < other.line; } -void AotStats::insert(AotStats other) +void AotStats::insert(const AotStats &other) { for (const auto &[moduleUri, moduleStats] : other.m_entries.asKeyValueRange()) { m_entries[moduleUri].insert(moduleStats); @@ -160,7 +160,13 @@ QJsonDocument AotStats::toJsonDocument() const return QJsonDocument(modulesArray); } -void AotStats::addEntry(const QString &moduleId, const QString &filepath, AotStatsEntry entry) +void AotStats::registerFile(const QString &moduleId, const QString &filepath) +{ + m_entries[moduleId][filepath] = {}; +} + +void AotStats::addEntry(const QString &moduleId, const QString &filepath, + const AotStatsEntry &entry) { m_entries[moduleId][filepath].append(entry); } @@ -177,7 +183,12 @@ bool AotStats::saveToDisk(const QString &filepath) const return true; } -void QQmlJSAotCompilerStats::addEntry(QString filepath, QQmlJS::AotStatsEntry entry) +void QQmlJSAotCompilerStats::registerFile(const QString &filepath) +{ + QQmlJSAotCompilerStats::instance()->registerFile(s_moduleId, filepath); +} + +void QQmlJSAotCompilerStats::addEntry(const QString &filepath, const QQmlJS::AotStatsEntry &entry) { auto *aotstats = QQmlJSAotCompilerStats::instance(); aotstats->addEntry(s_moduleId, filepath, entry); diff --git a/src/qmlcompiler/qqmljscompilerstats_p.h b/src/qmlcompiler/qqmljscompilerstats_p.h index de980c61d2..14cb9678a6 100644 --- a/src/qmlcompiler/qqmljscompilerstats_p.h +++ b/src/qmlcompiler/qqmljscompilerstats_p.h @@ -50,8 +50,9 @@ public: return m_entries; } - void addEntry(const QString &moduleId, const QString &filepath, AotStatsEntry entry); - void insert(AotStats other); + void registerFile(const QString &moduleId, const QString &filepath); + void addEntry(const QString &moduleId, const QString &filepath, const AotStatsEntry &entry); + void insert(const AotStats &other); static std::optional<QStringList> readAllLines(const QString &path); bool saveToDisk(const QString &filepath) const; @@ -78,7 +79,8 @@ public: static const QString &moduleId() { return s_moduleId; } static void setModuleId(QString moduleId) { s_moduleId = moduleId; } - static void addEntry(QString filepath, QQmlJS::AotStatsEntry entry); + static void registerFile(const QString &filepath); + static void addEntry(const QString &filepath, const QQmlJS::AotStatsEntry &entry); private: static std::unique_ptr<AotStats> s_instance; diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp index a17a362a24..bf48091ce8 100644 --- a/tools/qmlcachegen/qmlcachegen.cpp +++ b/tools/qmlcachegen/qmlcachegen.cpp @@ -280,6 +280,7 @@ int main(int argc, char **argv) if (parser.isSet(dumpAotStatsOption)) { QQmlJS::QQmlJSAotCompilerStats::setRecordAotStats(true); QQmlJS::QQmlJSAotCompilerStats::setModuleId(parser.value(moduleIdOption)); + QQmlJS::QQmlJSAotCompilerStats::registerFile(inputFile); } if (parser.isSet(validateBasicBlocksOption)) |
