summaryrefslogtreecommitdiff
path: root/src/qmlcompiler
Commit message (Collapse)AuthorAgeFilesLines
...
* QmlCompiler: Don't crash on CallWithSpreadUlf Hermann2022-11-222-0/+9
| | | | | | | | | | | | | When preparing for such a call, the byte code loads an "empty" constant. This has to be represented in the type system so that we don't hit the assert at the end of the instruction. Pick-to: 6.4 6.2 Task-number: QTBUG-108441 Change-Id: I66220bfae3d3a4b8e9600d84d4cfc43ac858b77e Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Avoid read from uninitialized variableUlf Hermann2022-11-161-1/+1
| | | | | Change-Id: I70294a09748f845e4efa11d2fb2655f0dc39ecce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tooling: silence -Wmissing-variable-declarationsTim Blechmann2022-11-161-3/+6
| | | | | | | | | silence clang's -Wmissing-variable-declarations Pick-to: 6.4 Change-Id: I40189c219bfeaeba103a56a08e489b019e2905bd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tooling: silence -Wextra-semi-stmtTim Blechmann2022-11-161-3/+3
| | | | | | | | silence clang's -Wextra-semi-stmt Pick-to: 6.4 Change-Id: I5dee9ec46b44076f0fc0590399131b1b267e1ad2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltyperegistrar: add IsConstant for method parametersSami Shalayel2022-11-114-17/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mark method parameters with IsConstant instead of including "const " in the typename, which makes type resolution in the qml compilers impossible. This also avoids a crash in qmltc happening when qmltc sees a signal defined in C++ that has a const parameter. When qmltyperegistrar writes out the types in the qmltypes, check if it starts with a const, remove it and add instead IsConstant: true. The name returned by MOC is normalized so no need to check for "volatile const" or "const volatile" (its always the latter) and no need to filter out for extra whitespace. Once the const is read by the qmltypes reader, propagate the const-information around using a newly introduced enum called QQmlJSMetaMethod::PConstness that can currently be Const or NonConst. Also add the isConstant property to the Parameter.qml in the tooling module. Add a test to see if the IsConstant information is written into the qmltypes. This is also required for QTBUG-107625. Fixes: QTBUG-108147 Task-number: QTBUG-107625 Change-Id: I13bda0a27fe83867f259b751468788128fec82ed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Ignore InitializeDeadTemporalZone instructionUlf Hermann2022-11-112-2/+3
| | | | | | | | | We don't discern between empty and undefined values in the compiler. Fixes: QTBUG-104192 Change-Id: Ida06386433ef9e8f9a7cba4bec99ba8e77edc324 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow lists as arguments to methodsUlf Hermann2022-11-1011-158/+191
| | | | | | | | | | | | | | | | | | | Since lists are allowed as property types, you should be able to pass them as arguments to methods, too. For now we only handle QML-defined methods, implemented by adding JavaScript functions to your QML elements. The usual type coercion rules apply if you pass JavaScript arrays to such methods. That is, it usually works. We now resolve properties with the "list" flag to their actual types (QQmlListProperty or QList) already when populating the QQmlJSScope, and store the list types as members of QQmlJSScope rather than as a special map in QQmlJSTypeResolver. This allows us to do the same to lists passed as arguments and simplifies some of the type analysis. Fixes: QTBUG-107171 Change-Id: Idf71ccdc1d59f472c17084a36b5d7879c4d959c0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace CallElement with separate instructionsUlf Hermann2022-11-075-22/+0
| | | | | | | | | | We need to do the subscript lookup before generating the arguments since the arguments may change the array. Fixes: QTBUG-106708 Change-Id: Ia3a0dd34c6ed8d39e86ad20911a632d691826322 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Enforce consistency of ContextualTypesUlf Hermann2022-11-029-112/+183
| | | | | | | | | | | | | | | An instance of ContextualTypes can only either hold QML types or internal types. We always need an integer and an array type, though. Previously, "int" was always added to the used types when it was looked up for potentially resolving enums. This prevented the builtins from being reported as unused import. Since we pass "int" as a separate member now, prevent the builtins from being recorded as import location in the first place. Task-number: QTBUG-107171 Change-Id: I288b6e070c2039d4ac85073886c9929a2eed3998 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: support inline components from different qml filesSami Shalayel2022-10-313-5/+46
| | | | | | | | | | | | | | | | | | | | | | | | Make qmltc aware that inline components can be shared between files such that it does not complain about not finding them. Typical usage are `MyOtherFile.MyInlineComponent {}` and `ModuleName.MyOtherFile.MyInlineComponent {}` for an an inline component called MyInlineComponent defined in MyOtherFile.qml, maybe also in a module called ModuleName. Make QQmlJSScope::findType() aware that inline components exists (and potentially that they might also appear in namespaced types). They can also be "imported" or reexported from basetypes and/or deeply nested in some children scopes. Also make it public so that qqmljsimportvisitor can use it when processing property types. Added some tests testing both notations (with and without the qualifed module name). Also add a test to see if there is no confusion between the enums and the inline components (due to their very similar notations). Fixes: QTBUG-106592 Change-Id: I8f2d4790729902ffa664fd0eb1b7c3279af8ddca Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Warn about duplicated signal/property namesSemih Yavuz2022-10-223-0/+16
| | | | | | | | | | | | | Qmllint does not warn about duplicated property and signal names while qmlengine complains about them. Introduce a new logging category for the duplicated names and log duplicated property/signals. This change breaks one of tst_qmljsscope testcase as it expects no logging within that case, edit it. Fixes: QTBUG-106579 Change-Id: I7732e08778a25e1eb2ba980ae395564b98c665a5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlJSMetaPropertyBinding: enable -Wswitch in literalType()Marc Mutz2022-10-201-2/+7
| | | | | | | | | | | | Don't use a default label, explicitly list the unhandled enum values, so we get a compiler warning-turned-error when we forget to handle a newly-added entry. Once we do this, the comment around Q_UNREACHABLE_RETURN() no longer makes sense, so remove it. Change-Id: I085871d2e57a88f6cc6250b3137203a0281b119e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port to new Q_UNREACHABLE_RETURN()Marc Mutz2022-10-204-14/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator to convert sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(), newly added to qtbase. const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule(stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)); a.k.a qt-use-unreachable-return. subStmt() and nextStmt() are non-standard matchers. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Add a separate flag for the "pragma Strict" checkUlf Hermann2022-10-202-3/+17
| | | | | | | | | | | | | We want to trigger the qFatal() when running qmlcachegen or qmlsc, but we don't want to trigger it in qmllint, even if we are using the same QtMsgType for the severity of the messages. In turn, demote qmlCompiler messages to QtWarningMsg in qmlcachegen. Pick-to: 6.4 Task-number: QTBUG-107168 Change-Id: Ib660df41742b2d426241eb29ac4c91f4933c5ba1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSUtils: make a local array const, not constexprMarc Mutz2022-10-181-1/+1
| | | | | | | | | | | | | | | | | | | While QLatin1String is constexpr, and so one can create a constexpr array of QLatin1String, there's really no point in doing so, because if, indeed, the compiler creates a static lifetime object out of this, it'll do nothing but create relocations, and one set per template argument(!) at that. By just making the array const, we allow the compiler to optimize this into a bunch of lea and movi. Also unbreaks the build with /Zc:lambda on MSVC. Amends ca68b0cde7a3b9bad468dfae1935d5886f461499. Change-Id: I9317c08df380cfe323efe5c09ffa7e688d6a6ffc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add option to enforce function signaturesUlf Hermann2022-10-144-3/+31
| | | | | | | | | | | | | | | | | | | | | By default, the QML engine does not enforce signatures given as type annotations to functions. By passing different types than the function declares, you can get different behavior between the interpreter/JIT and the AOT-compiled code. In addition, in interpreted or JIT'ed mode, we pass all non-primitive value types as references. This means, if you modify them within the called function, the modifications are propagated back to the place where the value was loaded from. Enforcing the signature prevents all of this, at a run time cost. Since we have to coerce all arguments to the desired types, the function call overhead grows. This change introduces a pragma "FunctionSignatureBehavior" which you can set to "Ignored" or "Enforced" to choose one way or the other as universal way of handling type annotations. Fixes: QTBUG-106819 Change-Id: I50e9b2bd6702907da44974cd9e05b48a96bb609e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmlcompiler: refactor ContextualTypes to know its contextSami Shalayel2022-10-149-95/+166
| | | | | | | | | | | | | | | | | | | | | | The code in qmlcompiler working on ContextualTypes is very confusing as it handles internal types (c++ and synthetic jsrootgen type names) and qml types at the same places. Furthermore, some methods like qqmljsscope::findType() have different behaviors when running in different contexts, e.g. in the internal type context it needs to lookup namespaced c++ enums (e.g. QQmlComponent::Status) while in the qml type context it needs to lookup inline components (qmlFileName.MyInlineComponent). Changed ContextualTypes to be a struct with the types QHash and an enum with the context (QML or INTERNAL), Drive-by change: amend the iterations over types.keys() to use an iterator instead of allocating a temporary QList as types is not that small (may contain around 400 items just for the builtins). Fixes: QTBUG-107191 Change-Id: Ib463ec873019ea1e6844c522a090030e9a44d53f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: early return from array bindingsSemih Yavuz2022-10-141-1/+6
| | | | | | | | | | | | | | List in qml should not include an object whose scope types is attached or grouped. In case an attached or grouped type is a member of a list, they don't have a separate scope, but only one scope is created per name. This causes a crash as creating bindings for array members since it is not known if any of the child scope is omitted or not. To prevent this, simply early return if any of the child scopes include an object definition that is attached object or group type. Fixes: QTBUG-107250 Change-Id: I08fdfb43d766569c4dfefc50135f98f74d25bad2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Track the statement indices together with line numbersUlf Hermann2022-10-131-4/+4
| | | | | | | | | | We will need the statement indices when tracking value type references. New value type references shall only be written back in the same statement they were created in. Task-number: QTBUG-99766 Change-Id: I83f908df034e7da8ba46ccacaa29bd9d78020d20 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Qml: Analyze qsTranslate at compile timeUlf Hermann2022-10-133-7/+16
| | | | | | | | | | We generate translation bindings for all the other translation functions already. We can just as well generate a translation binding for this one, too. Fixes: QTBUG-107536 Change-Id: I851f03c26510b6d450aa78f5d7a1f0142d3a81aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Properly check contained type for enumsUlf Hermann2022-10-121-1/+1
| | | | | | | | | | | | | | | In case of an enum the actual contained type is the one the enum dictates. This brings registerContains() in line with containedType() and makes it possible to match previously discovered types on subsequent passes of the type propagator. Therefore, it avoids infinite loops where the same types would be tracked over and over. Pick-to: 6.4 Fixes: QTBUG-107176 Fixes: QTBUG-107542 Change-Id: I4b8d66b157d0ec0ece4ca345cb99a630b8898a1b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Introduce scoped property into qmltypes/enumEvgeniy A. Dushistov2022-10-113-3/+14
| | | | | | | | | | | QML runtime allows only for "C++ enum class" to use syntax like Enum.Variant, but qmllint accept such code without any warnings. This commit make possible to describe "scoped" property for enum, to distinguish between "C++ enum" and "C++ enum class". Task-number: QTBUG-107143 Change-Id: I00df2f70aa0fadba714793893d17a35ba8fa594d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Remove broken alias optimizationSami Shalayel2022-10-111-7/+11
| | | | | | | | | | | | | | | | | | | | Remove the recursive alias resolution mechanism. It tried to resolve aliases recursively but only knew the id's of the current component. This means that an alias pointing to a property defined in another component (e.g. a different qml file) was resolved using the id-to-scope map of the component containing the alias property. This leads to unresolved aliases at best and endless loops when the aliased property was itself an alias pointing to some property also existing in the original component (see QmltcTests/ComponentWithAlias{1..3}.qml for an example). Also added the reproducer in the qmltc tests. Fixes: QTBUG-107533 Fixes: QTBUG-107534 Change-Id: Idbf0cff3e45213bc7fbb4a98a9393c6754b00046 Pick-to: 6.4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmljsimportvisitor: rename m_currentInlineComponent to m_currentRootSami Shalayel2022-10-102-6/+6
| | | | | | | | | | | Small refactor to improve readability: rename qqmljsimportvisitor::m_currentInlineComponentName to m_currentRootName as it denotes the current inline component OR the document root. The previous naming implied wrongly that it was useless when outside an inline component. Change-Id: Ie3c9aa10182f0c9e50650cecaa3e3eb1e37e90eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: fix code generation for implicit componentsSami Shalayel2022-10-101-0/+3
| | | | | | | | | | | | | | | | | | | | Do not check if a type is implictly wrapped during visitation, as this information is only made available by QQmlJSImportVisitor after(!) the visit. Move this into the postvisit step of qmltc, and write some internal documentation so this error will hopefully not be done again by some qmltc contributor (e.g., me). Now that implicit components are correctly recognized as such, they can be compiled correctly and the c++-code generated by qmltc can again be compiled. Added also a test to see if all childrens of the repeater are correctly instantiated. Pick-to: 6.4 Fixes: QTBUG-107091 Change-Id: I8fce018b83316f8786ae5ca15e5af27c30bb1d37 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-078-17/+17
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-0718-66/+66
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Do not crash on version-mismatched property accessUlf Hermann2022-10-062-7/+16
| | | | | | | | | | | If we cannot access a property due to a version mismatch, that's not an unqualified access. Pick-to: 6.4 Fixes: QTBUG-107080 Change-Id: I1780b171928df437a2121601f1aac829dbe1e994 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: warn about enums declarations in inline componentsSami Shalayel2022-10-041-0/+4
| | | | | | | | | | | In QQmlJSImportVisitor, emit a warning when enum declarations are detected inside of inline components, as those cannot be used at all with the engine (neither inside nor outside of the inline component they were defined). Fixes: QTBUG-107063 Change-Id: I21329c35d5dd8940e047771416bba04858cb3921 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Use an enum to categorize functions and rename aotFunctionUlf Hermann2022-09-292-3/+3
| | | | | | | | We want to use the aotFunction member also for typed JavaScript functions. Change-Id: Iad6d12ebed3ad3069832484137ed8e4d9e7a7cf4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Do not crash on invalid ids, take 2Fabian Kosmale2022-09-261-0/+5
| | | | | | | | | | | scriptBinding->statement might be a block statement instead of an exrpession statement; that's invalid QML, but qmllint should still not crash. Pick-to: 6.4 Change-Id: I34b6a65e7fb1705215d18e0f14f1434317ff5326 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Don't crash on malformed icFabian Kosmale2022-09-261-2/+6
| | | | | | | | | | | | | qmllint assumed that between visit(UiInlineComponent) and endVisit, we would have encountered an obejct. That is however only true in valid QML files; in invalid files there might not be an object definition. Pick-to: 6.4 Fixes: QTBUG-106612 Change-Id: If353b42aec445258e9cbecbbd60fee00e25e17df Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Fix crash due to index out of rangeSemih Yavuz2022-09-221-19/+20
| | | | | | | | | | | | | Opening input files in binary mode may cause file to be parsed incorrectly. To prevent the crash, Check if element in container is within the range of valid elements before accessing it. Note that qmllint will ignore the comment directives and may not function correct in that case. QTBUG-106813 should solve this. Pick-to: 6.4 Fixes: QTBUG-106613 Change-Id: I1a5705474905a747fbcc4874c3ff2038f539f42f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: reject top level componentsSami Shalayel2022-09-193-2/+16
| | | | | | | | | | | | | | In qqmljsimportvisitor, print an error message and return false when a top level component is visited. Also, remove all the tests expecting qmltc to accept top level components and add a test to see that the error is correctly emitted for top level components. Fix qmllint tests using top level components. Fixes: QTBUG-106558 Task-number: QTBUG-106547 Change-Id: I101b42fc7499049fcebca18e7aeab57fa6705f81 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Gracefully handle and warn about invalid alias propertiesFabian Kosmale2022-09-151-1/+9
| | | | | | | | | | | | | qmllint used to crash when an alias did not have a proper target (e.g. missing target, or statement of the wrong kind). Detect that kind of error, and print a proper error message. Pick-to: 6.4 Fixes: QTBUG-106566 Change-Id: Id4edb37953762267bae0a3952b9c75e72ec0c47b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Unexport classes which are completely inlineFabian Kosmale2022-09-151-3/+3
| | | | | | | | | | Exporting them leads to MSVC putting the (exported) dtor into dlls, which causes a failure at link time. As the classes are private API, we can simply unexport them. Pick-to: 6.4 Change-Id: I2b5c6f8670265c69d23b7a0defba09cab5a885e1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add internal documentation for qqmljssscopeSami Shalayel2022-09-081-0/+5
| | | | | | | Describe what "composite" means in qqmljsscope. Change-Id: I8abfc4925274b5fd85d60bf24df29b82f2c3d292 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqmljsscope: track inline component namesSami Shalayel2022-09-084-6/+57
| | | | | | | | | | | | | | | | | | | | | This patch tracks inline component names to qqmljsscope, which will be useful in a later patch in qmltc to support inline components. Also adds a hashable type representing either the document root or the inline component name that will serve later in qmltcvisitor to separate types by inline components/document root. Implementation details: * Extend qqmljsscope + qqmljsimportvisitor ** keep track of inline component names in visitor and qqmljsscope ** types know (through their parent) if they are inside an inline component and their inline component name * added tests: ** see if QQmlJSScope can detect implicitly wrapped components inside of inline components Change-Id: I9b8b4eefe147f8f826820c3e9dabf3733b0f2d6f Task-Id: QTBUG-105946 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-09-071-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: Id89ed14990804a5024183e75382cc539d4293da1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix build-breaking warningsVolker Hilsheimer2022-09-011-15/+13
| | | | | | | | | | | | Qt's asKeyValueRange of associative containers cannot return references to key/value pairs, so Apple's clang warns when using ranged-for with references to elements. Use a structured binding instead as the loop variable, and delay some conversions of QSet<QString> to QStringList until the list is needed. Change-Id: I37aa101e6d9cd008cde0c2db790132dc051a249b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Disable qmllint's deferred property checkFabian Kosmale2022-08-311-1/+1
| | | | | | | | | | | This mirrors 9d22088d93440e38765b5891b5f2af15414476e1, which removed the warning from the engine. Pick-to: 6.4 Task-number: QTBUG-106069 Change-Id: Ib714bfbd251dcf30becd920c85ac65aceab43707 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Prevent lookup of value type where we need an object typeUlf Hermann2022-08-302-73/+69
| | | | | | | | | | | | | | | | | With a particular nefarious combination of Q_GADGET and inheritance from QObject you can make QmlCompiler believe a type is a value type even though it is actually an object type. We never want to touch such a thing. There was a safe guard against this when looking up the type from the scope, but by putting it in a type namespace you could circumvent it. Refactor the code to apply to both cases the same way. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-104556 Fixes: QTBUG-105608 Change-Id: I8a690e2b6f78fcaba0911a93504cde0d2c7dde0d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Avoid unnecessary copies in loopsUlf Hermann2022-08-292-13/+18
| | | | | | | | Coverity-Id: 397268 Coverity-Id: 397269 Change-Id: Iacbf6c8a57dbdee02e75f4faeed0a0f31d37500f Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Implement remaining operatorsUlf Hermann2022-08-296-151/+195
| | | | | | | | | | | | | Some of the math operators were still missing. Add them and test them all. Since the "runInterpreted()" test function takes too long now, split the qmlcppcodegen test in two: One that runs in compiled mode and one that runs in interpreted mode. Fixes: QTBUG-105188 Change-Id: I4b641d5e51b5a7e2a9254be40f257d7b249deb13 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: translation binding supportSami Shalayel2022-08-251-7/+5
| | | | | | | | | | | | | | | | | | | | | | | Implement and test support for translation bindings in qmltc: * qsTr() * QT_TR_NOOP() * qsTrId() * QT_TRID_NOOP() Not compiled by qmltc, but instead interpreted as script bindings: * combinations like qsTr(qsTr()) * qsTranslate() (as in qmlsc) * QT_TRANSLATE_NOOP() (as in qmlsc) Add the *.qm files directly to the resources as qt_add_translations() is not available from qtdeclarative (the cmake function lives in qttools that depends on qtdeclarative). Fixes: QTBUG-104637 Task-Id: QTBUG-105346 Change-Id: Ia9433c2bcef01f3486358d963059d9779c67708c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Add more informative warning for unknown object typesUlf Hermann2022-08-241-3/+13
| | | | | | | | | | | The most common mistakes leading there are missing qualifications in C++ and missing qt_extract_metatypes in CMake. Pick-to: 6.4 Fixes: QTBUG-105254 Change-Id: I285355d0cc5be34d5e018dc6e843e649f60df871 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Create Translation Bindings without CompiledData::BindingSami Shalayel2022-08-153-17/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To add translation bindings to qmltc, the methods used to create translation bindings need to be adapted to work without QV4::CompiledData::Binding as it is not available from qmltc. Instead, information already available from the QQmlJSScope should be used, along with a newly introduced helper class QQmlTranslation. Details: Add a QQmlTranslation class that represents a call to qsTr, qsTrId etc that knows how to translate itself (without needing any ExecutableCompilationUnit or Binding). It encapsulates the information needed to create a translation binding. ExecutableCompilationUnit::bindingValueAsString refactored so its functionality can be used without Binding. Instead, it uses only the translationId, see ExecutableCompilationUnit::translateFromId and ExecutableCompilationUnit::translateFrom. Refactored QQmlTranslationBinding to work with QQmlTranslation instead of CompiledData::Binding. Same for QQmlCppBinding::createTranslationBindingForBindable, QQmlTranslationPropertyBinding::create and QQmlCppBinding::createTranslationBindingForNonBindable. Changed TranslationBindingInformation to work without CompiledData::Binding, and also removed static unused QString ProxyTranslator::originStringFromInformation( const TranslationBindingInformation &translationBindingInformation) as I could not find out what this origin string is. Same for the translation debugging in qmldb_preview. Added QmltcCodeGenerator::generate_createTranslationBindingOnProperty. Added #if to avoid compilation error for standalone DOM compilation due to the new QQmlTranslation class. Task-number: QTBUG-105345 Change-Id: Iccd94d5cba4eaf63901233451fec48051c855c2a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint/importer: Fix hasSystemModule not being set properlyMaximilian Goldstein2022-08-111-1/+1
| | | | | | | | | Previously we didn't set this flag properly if there were multiple modules that were imported. Change-Id: I05d81bc82f69e038a82131e20c23fb9dd497e9cc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Add a uint type and properly integrate floatUlf Hermann2022-08-034-32/+63
| | | | | | | | | We will need uint for the URShift operation. And we can always cast float to double. Task-number: QTBUG-105188 Change-Id: If41c86c7ceb508324c2ebc6041c6e769ebc91c93 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Allow any conversion possible via QJSPrimitiveValueUlf Hermann2022-08-032-8/+35
| | | | | | | | | | | | All of those are legal in ECMAScript, and so we need to support them in script bindings. As we have stricter rules for literal bindings, add an extra method there to check for what QQmlPropertyValidator does. Pick-to: 6.4 Fixes: QTBUG-105252 Task-number: QTBUG-105188 Change-Id: I0621b2c3aa196414f669873e93670557284a8bca Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>