diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-03-29 16:17:41 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-03-30 15:04:17 +0200 |
commit | 97da5b5fe02b7fb7f0fdc4607c7759ccc8057d84 (patch) | |
tree | 538079472bfb69708b559129b5c9e8ff75e384f4 | |
parent | 8a3bf4e2969b2f668ce06e996a8d601f834702bd (diff) |
QV4CompilerScanFunctions: Silence code checker warning
The AST is constructed in such a way that having exportAll set always
implies that a fromClause exists.
Also, clean up exportAll: We do not need a separate member to track it.
Its value is fully determined by the presence of fromClause and
exportsClause. Thus, replace it with a function.
Change-Id: Ib7db2bbaf326ecc36a7f4a2986a7c1fb54db6cd5
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/qml/compiler/qv4compilerscanfunctions.cpp | 4 | ||||
-rw-r--r-- | src/qml/parser/qqmljsast_p.h | 7 | ||||
-rw-r--r-- | tests/auto/shared/qqmljsastdumper.cpp | 2 |
3 files changed, 9 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index ebc9a86a16..a942b3d2c9 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -181,7 +181,9 @@ bool ScanFunctions::visit(ExportDeclaration *declaration) QString localNameForDefaultExport = QStringLiteral("*default*"); - if (declaration->exportAll) { + if (declaration->exportsAll()) { + Q_ASSERT_X(declaration->fromClause, "ScanFunctions", + "ExportDeclaration with exportAll always have a fromClause"); Compiler::ExportEntry entry; entry.moduleRequest = declaration->fromClause->moduleSpecifier.toString(); entry.importName = QStringLiteral("*"); diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index cb6d5fa3ee..6836579209 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -2957,7 +2957,6 @@ public: ExportDeclaration(FromClause *fromClause) : fromClause(fromClause) { - exportAll = true; kind = K; } @@ -2980,6 +2979,11 @@ public: kind = K; } + bool exportsAll() const + { + return fromClause && !exportClause; + } + void accept0(BaseVisitor *visitor) override; SourceLocation firstSourceLocation() const override @@ -2989,7 +2993,6 @@ public: // attributes SourceLocation exportToken; - bool exportAll = false; ExportClause *exportClause = nullptr; FromClause *fromClause = nullptr; Node *variableStatementOrDeclaration = nullptr; diff --git a/tests/auto/shared/qqmljsastdumper.cpp b/tests/auto/shared/qqmljsastdumper.cpp index 3ffb7519e3..9d4d186655 100644 --- a/tests/auto/shared/qqmljsastdumper.cpp +++ b/tests/auto/shared/qqmljsastdumper.cpp @@ -1030,7 +1030,7 @@ void AstDumper::endVisit(AST::ExportClause *) { stop("ExportClause"); } bool AstDumper::visit(AST::ExportDeclaration *el) { start(QLatin1String("ExportDeclaration exportToken=%1 exportAll=%2 exportDefault=%3") - .arg(loc(el->exportToken), boolStr(el->exportAll), boolStr(el->exportDefault))); + .arg(loc(el->exportToken), boolStr(el->exportsAll()), boolStr(el->exportDefault))); return true; } void AstDumper::endVisit(AST::ExportDeclaration *) { stop("ExportDeclaration"); } |