diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2022-02-04 10:42:33 +0100 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2022-02-15 08:55:14 +0100 |
commit | 2a9e514c890a055f3cf6d2553a4b451786c1f487 (patch) | |
tree | 417d6fc10b064bd31452b7c93f92c81738f2e1be /tools/qmltc/main.cpp | |
parent | 8e6be1b570800584dc959d44818a640591640c28 (diff) |
Treat warnings as errors in qmltc
qmltc should really interpret most of qmlcompiler warnings as errors.
There could be exceptions but for now let's just reject any malicious
code (except for ControlsSanity since it is itself malicious)
Fixes: QTBUG-100052
Change-Id: Ib18741d0a46c4d0ddb40b53e34658804c0245018
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools/qmltc/main.cpp')
-rw-r--r-- | tools/qmltc/main.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tools/qmltc/main.cpp b/tools/qmltc/main.cpp index 0b8e30c670..7498622ee4 100644 --- a/tools/qmltc/main.cpp +++ b/tools/qmltc/main.cpp @@ -46,8 +46,18 @@ void setupLogger(QQmlJSLogger &logger) // prepare logger to work with compiler { - logger.setCategoryLevel(Log_Compiler, QtCriticalMsg); - logger.setCategoryIgnored(Log_Compiler, false); + const QSet<QQmlJSLoggerCategory> exceptions { + Log_ControlsSanity, // this category is just weird + Log_UnusedImport, // not critical + }; + + for (int i = 0; i <= static_cast<int>(QQmlJSLoggerCategory_Last); ++i) { + const auto c = static_cast<QQmlJSLoggerCategory>(i); + if (exceptions.contains(c)) + continue; + logger.setCategoryLevel(c, QtCriticalMsg); + logger.setCategoryIgnored(c, false); + } } int main(int argc, char **argv) @@ -192,7 +202,7 @@ int main(int argc, char **argv) Qmltc::TypeResolver typeResolver { &importer }; typeResolver.init(visitor, document.program); - if (logger.hasWarnings() || logger.hasErrors()) + if (logger.hasErrors()) return EXIT_FAILURE; QList<QQmlJS::DiagnosticMessage> warnings = importer.takeGlobalWarnings(); @@ -207,7 +217,7 @@ int main(int argc, char **argv) CodeGenerator generator(url, &logger, &document, &typeResolver); generator.generate(options); - if (logger.hasWarnings() || logger.hasErrors()) + if (logger.hasErrors()) return EXIT_FAILURE; return EXIT_SUCCESS; |