OpenCoverage

qmlcachegen.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/tools/qmlcachegen/qmlcachegen.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4int filterResourceFile(const QString &input, const QString &output);-
5bool generateLoader(const QStringList &compiledFiles, const QString &output, const QStringList &resourceFileMappings, QString *errorString);-
6QString symbolNamespaceForPath(const QString &relativePath);-
7-
8QSet<QString> illegalNames;-
9-
10void setupIllegalNames()-
11{-
12-
13 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "Math")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Math" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
14 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "Array")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Array" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
15 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "String")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "String" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
16 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "Function")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Function" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
17 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "Boolean")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Boolean" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
18 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "Number")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Number" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
19 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "Date")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Date" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
20 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "RegExp")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "RegExp" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
21 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "Error")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Error" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
22 illegalNames.insert(([]() noexcept -> QString { enum { Size = sizeof(u"" "Object")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Object" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
23}
executed 12 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
12
24-
25struct Error-
26{-
27 QString message;-
28 void print();-
29 Error augment(const QString &contextErrorMessage) const;-
30};-
31-
32void Error::print()-
33{-
34 fprintf(-
35 stderr-
36 , "%s\n", QtPrivate::asString(message).toLocal8Bit().constData());-
37}
executed 2 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
2
38-
39Error Error::augment(const QString &contextErrorMessage) const-
40{-
41 Error augmented;-
42 augmented.message = contextErrorMessage + message;-
43 return
executed 4 times by 1 test: return augmented;
Executed by:
  • tst_qmlcachegen
augmented;
executed 4 times by 1 test: return augmented;
Executed by:
  • tst_qmlcachegen
4
44}-
45-
46QString diagnosticErrorMessage(const QString &fileName, const QQmlJS::DiagnosticMessage &m)-
47{-
48 QString message;-
49 message = fileName + QLatin1Char(':') + QString::number(m.loc.startLine) + QLatin1Char(':');-
50 if (m.loc.startColumn > 0
m.loc.startColumn > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
51 message += QString::number(m.loc.startColumn) + QLatin1Char(':');
never executed: message += QString::number(m.loc.startColumn) + QLatin1Char(':');
0
52-
53 if (m.isError()
m.isError()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
54 message += QLatin1String(" error: ");
never executed: message += QLatin1String(" error: ");
0
55 else-
56 message += QLatin1String(" warning: ");
never executed: message += QLatin1String(" warning: ");
0
57 message += m.message;-
58 return
never executed: return message;
message;
never executed: return message;
0
59}-
60-
61-
62static void annotateListElements(QmlIR::Document *document)-
63{-
64 QStringList listElementNames;-
65-
66 for (auto _container_ = QtPrivate::qMakeForeachContainer(document->imports); _container_.control
_container_.controlDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
; ++_container_.i, _container_.control ^= 1) for (const QV4::CompiledData::Import *import = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qmlcachegen
; _container_.control = 0) {
0-26
67 const QString uri = document->stringAt(import->uriIndex);-
68 if (uri != ([]() noexcept -> QString { enum { Size = sizeof(u"" "QtQml.Models")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QtQml.Models" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()) && uri != ([]() noexcept -> QString { enum { Size = sizeof(u"" "QtQuick")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QtQuick" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()))
12
69 continue;
executed 10 times by 1 test: continue;
Executed by:
  • tst_qmlcachegen
10
70-
71 QString listElementName = ([]() noexcept
dead code: QString listElementName = ([]() noexcept
-> QString { enum { Size = sizeof(u"" "ListElement")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "ListElement" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());
-
72 const QString qualifier = document->stringAt(import->qualifierIndex);-
73 if (!qualifier.isEmpty()
!qualifier.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
0-4
74 listElementName.prepend(QLatin1Char('.'));-
75 listElementName.prepend(qualifier);-
76 }
never executed: end of block
0
77 listElementNames.append(listElementName);-
78 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
4
79-
80 if (listElementNames.isEmpty()
listElementNames.isEmpty()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmlcachegen
)
4-8
81 return;
executed 8 times by 1 test: return;
Executed by:
  • tst_qmlcachegen
8
82-
83 for (auto _container_ = QtPrivate::qMakeForeachContainer(document->objects); _container_.control
_container_.controlDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEnever evaluated
&& _container_.i != _container_.e
_container_.i != _container_.eDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmlcachegen
; ++_container_.i, _container_.control ^= 1) for (QmlIR::Object *object = *_container_.i; _container_.control
_container_.controlDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
; _container_.control = 0) {
0-16
84 if (!listElementNames.contains(document->stringAt(object->inheritedTypeNameIndex))
!listElementNa...ypeNameIndex))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmlcachegen
)
4-8
85 continue;
executed 8 times by 1 test: continue;
Executed by:
  • tst_qmlcachegen
8
86 for (QmlIR::Binding *binding = object->firstBinding(); binding
bindingDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmlcachegen
; binding = binding->next) {
4
87 if (binding->type != QV4::CompiledData::Binding::Type_Script
binding->type ...g::Type_ScriptDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEnever evaluated
)
0-4
88 continue;
executed 4 times by 1 test: continue;
Executed by:
  • tst_qmlcachegen
4
89 binding->stringIndex = document->registerString(object->bindingAsString(document, binding->value.compiledScriptIndex));-
90 }
never executed: end of block
0
91 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
4
92}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
4
93-
94static bool checkArgumentsObjectUseInSignalHandlers(const QmlIR::Document &doc, Error *error)-
95{-
96 for (QmlIR::Object *object: qAsConst(doc.objects)) {-
97 for (auto binding = object->bindingsBegin(); binding != object->bindingsEnd()
binding != obj...>bindingsEnd()Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qmlcachegen
; ++binding) {
18-36
98 if (binding->type != QV4::CompiledData::Binding::Type_Script
binding->type ...g::Type_ScriptDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 16 times by 1 test
Evaluated by:
  • tst_qmlcachegen
)
16-20
99 continue;
executed 20 times by 1 test: continue;
Executed by:
  • tst_qmlcachegen
20
100 const QString propName = doc.stringAt(binding->propertyNameIndex);-
101 if (!propName.startsWith(QLatin1String("on"))
!propName.star...1String("on"))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlcachegen
8
102 || propName.length() < 3
propName.length() < 3Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlcachegen
0-8
103 || !propName.at(2).isUpper()
!propName.at(2).isUpper()Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlcachegen
)
0-8
104 continue;
executed 8 times by 1 test: continue;
Executed by:
  • tst_qmlcachegen
8
105 auto compiledFunction = doc.jsModule.functions.value(object->runtimeFunctionIndices.at(binding->value.compiledScriptIndex));-
106 if (!compiledFunction
!compiledFunctionDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlcachegen
)
0-8
107 continue;
never executed: continue;
0
108 if (compiledFunction->usesArgumentsObject == QV4::Compiler::Context::ArgumentsObjectUsed
compiledFuncti...entsObjectUsedDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
2-6
109 error->message = QLatin1Char(':') + QString::number(compiledFunction->line) + QLatin1Char(':');-
110 if (compiledFunction->column > 0
compiledFunction->column > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEnever evaluated
)
0-2
111 error->message += QString::number(compiledFunction->column) + QLatin1Char(':');
executed 2 times by 1 test: error->message += QString::number(compiledFunction->column) + QLatin1Char(':');
Executed by:
  • tst_qmlcachegen
2
112-
113 error->message += QLatin1String(" error: The use of eval() or the use of the arguments object in signal handlers is\n"-
114 "not supported when compiling qml files ahead of time. That is because it's ambiguous if \n"-
115 "any signal parameter is called \"arguments\". Similarly the string passed to eval might use\n"-
116 "\"arguments\". Unfortunately we cannot distinguish between it being a parameter or the\n"-
117 "JavaScript arguments object at this point.\n"-
118 "Consider renaming the parameter of the signal if applicable or moving the code into a\n"-
119 "helper function.");-
120 return
executed 2 times by 1 test: return false;
Executed by:
  • tst_qmlcachegen
false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_qmlcachegen
2
121 }-
122 }
executed 6 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
6
123 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
18
124 return
executed 10 times by 1 test: return true;
Executed by:
  • tst_qmlcachegen
true;
executed 10 times by 1 test: return true;
Executed by:
  • tst_qmlcachegen
10
125}-
126-
127using SaveFunction = std::function<bool (QV4::CompiledData::CompilationUnit *, QString *)>;-
128-
129static bool compileQmlFile(const QString &inputFileName, SaveFunction saveFunction, Error *error)-
130{-
131 QmlIR::Document irDocument( false);-
132-
133 QString sourceCode;-
134 {-
135 QFile f(inputFileName);-
136 if (!f.open(QIODevice::ReadOnly)
!f.open(QIODevice::ReadOnly)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
0-12
137 error->message = QLatin1String("Error opening ") + inputFileName + QLatin1Char(':') + f.errorString();-
138 return
never executed: return false;
false;
never executed: return false;
0
139 }-
140 sourceCode = QString::fromUtf8(f.readAll());-
141 if (f.error() != QFileDevice::NoError
f.error() != Q...evice::NoErrorDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
0-12
142 error->message = QLatin1String("Error reading from ") + inputFileName + QLatin1Char(':') + f.errorString();-
143 return
never executed: return false;
false;
never executed: return false;
0
144 }-
145 }-
146-
147 {-
148 QmlIR::IRBuilder irBuilder(illegalNames);-
149 if (!irBuilder.generateFromQml(sourceCode, inputFileName, &irDocument)
!irBuilder.gen..., &irDocument)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
0-12
150 for (const QQmlJS::DiagnosticMessage &parseError: qAsConst(irBuilder.errors)) {-
151 if (!error->message.isEmpty()
!error->message.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
152 error->message += QLatin1Char('\n');
never executed: error->message += QLatin1Char('\n');
0
153 error->message += diagnosticErrorMessage(inputFileName, parseError);-
154 }
never executed: end of block
0
155 return
never executed: return false;
false;
never executed: return false;
0
156 }-
157 }-
158-
159 annotateListElements(&irDocument);-
160-
161 {-
162 QmlIR::JSCodeGen v4CodeGen(irDocument.code,-
163 &irDocument.jsGenerator, &irDocument.jsModule,-
164 &irDocument.jsParserEngine, irDocument.program,-
165 nullptr, &irDocument.jsGenerator.stringTable, illegalNames);-
166 v4CodeGen.setUseFastLookups(false);-
167 for (QmlIR::Object *object: qAsConst(irDocument.objects)) {-
168 if (object->functionsAndExpressions->count == 0
object->functi...ns->count == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qmlcachegen
)
6-14
169 continue;
executed 6 times by 1 test: continue;
Executed by:
  • tst_qmlcachegen
6
170 QList<QmlIR::CompiledFunctionOrExpression> functionsToCompile;-
171 for (QmlIR::CompiledFunctionOrExpression *foe = object->functionsAndExpressions->first; foe
foeDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qmlcachegen
; foe = foe->next) {
14-22
172 foe->disableAcceleratedLookups = true;-
173 functionsToCompile << *foe;-
174 }
executed 22 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
22
175 const QVector<int> runtimeFunctionIndices = v4CodeGen.generateJSCodeForFunctionsAndBindings(functionsToCompile);-
176 QList<QQmlJS::DiagnosticMessage> jsErrors = v4CodeGen.errors();-
177 if (!jsErrors.isEmpty()
!jsErrors.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
0-14
178 for (const QQmlJS::DiagnosticMessage &e: qAsConst(jsErrors)) {-
179 if (!error->message.isEmpty()
!error->message.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
180 error->message += QLatin1Char('\n');
never executed: error->message += QLatin1Char('\n');
0
181 error->message += diagnosticErrorMessage(inputFileName, e);-
182 }
never executed: end of block
0
183 return
never executed: return false;
false;
never executed: return false;
0
184 }-
185-
186 QQmlJS::MemoryPool *pool = irDocument.jsParserEngine.pool();-
187 object->runtimeFunctionIndices.allocate(pool, runtimeFunctionIndices);-
188 }
executed 14 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
14
189-
190 if (!checkArgumentsObjectUseInSignalHandlers(irDocument, error)
!checkArgument...cument, error)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
2-10
191 *error = error->augment(inputFileName);-
192 return
executed 2 times by 1 test: return false;
Executed by:
  • tst_qmlcachegen
false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_qmlcachegen
2
193 }-
194-
195 QmlIR::QmlUnitGenerator generator;-
196 irDocument.javaScriptCompilationUnit = v4CodeGen.generateCompilationUnit( false);-
197 QV4::CompiledData::Unit *unit = generator.generate(irDocument);-
198 unit->flags |= QV4::CompiledData::Unit::StaticData;-
199 unit->flags |= QV4::CompiledData::Unit::PendingTypeCompilation;-
200 irDocument.javaScriptCompilationUnit->data = unit;-
201-
202 if (!saveFunction(irDocument.javaScriptCompilationUnit.data(), &error->message)
!saveFunction(...rror->message)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qmlcachegen
)
0-10
203 return
never executed: return false;
false;
never executed: return false;
0
204-
205 free(unit);-
206 }-
207 return
executed 10 times by 1 test: return true;
Executed by:
  • tst_qmlcachegen
true;
executed 10 times by 1 test: return true;
Executed by:
  • tst_qmlcachegen
10
208}-
209-
210static bool compileJSFile(const QString &inputFileName, const QString &inputFileUrl, SaveFunction saveFunction, Error *error)-
211{-
212 QmlIR::Document irDocument( false);-
213-
214 QString sourceCode;-
215 {-
216 QFile f(inputFileName);-
217 if (!f.open(QIODevice::ReadOnly)
!f.open(QIODevice::ReadOnly)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
218 error->message = QLatin1String("Error opening ") + inputFileName + QLatin1Char(':') + f.errorString();-
219 return
never executed: return false;
false;
never executed: return false;
0
220 }-
221 sourceCode = QString::fromUtf8(f.readAll());-
222 if (f.error() != QFileDevice::NoError
f.error() != Q...evice::NoErrorDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
223 error->message = QLatin1String("Error reading from ") + inputFileName + QLatin1Char(':') + f.errorString();-
224 return
never executed: return false;
false;
never executed: return false;
0
225 }-
226 }-
227-
228 QQmlJS::Engine *engine = &irDocument.jsParserEngine;-
229 QmlIR::ScriptDirectivesCollector directivesCollector(&irDocument);-
230 QQmlJS::Directives *oldDirs = engine->directives();-
231 engine->setDirectives(&directivesCollector);-
232-
233 QQmlJS::AST::Program *program = nullptr;-
234-
235 {-
236 QQmlJS::Lexer lexer(engine);-
237 lexer.setCode(sourceCode, 1, false);-
238 QQmlJS::Parser parser(engine);-
239-
240 bool parsed = parser.parseProgram();-
241-
242 for (const QQmlJS::DiagnosticMessage &parseError: parser.diagnosticMessages()) {-
243 if (!error->message.isEmpty()
!error->message.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
244 error->message += QLatin1Char('\n');
never executed: error->message += QLatin1Char('\n');
0
245 error->message += diagnosticErrorMessage(inputFileName, parseError);-
246 }
never executed: end of block
0
247-
248 if (!parsed
!parsedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
249 engine->setDirectives(oldDirs);-
250 return
never executed: return false;
false;
never executed: return false;
0
251 }-
252-
253 program = QQmlJS::AST::cast<QQmlJS::AST::Program*>(parser.rootNode());-
254 if (!program
!programDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
255 lexer.setCode(([]() noexcept -> QString { enum { Size = sizeof(u"" "undefined;")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "undefined;" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()), 1, false);
0
256 parsed = parser.parseProgram();-
257 ((parsed) ? static_cast<void>(0) : qt_assert("parsed", __FILE__, 295));-
258 program = QQmlJS::AST::cast<QQmlJS::AST::Program*>(parser.rootNode());-
259 ((program) ? static_cast<void>(0) : qt_assert("program", __FILE__, 297));-
260 }
never executed: end of block
0
261 }-
262-
263 {-
264 QmlIR::JSCodeGen v4CodeGen(irDocument.code, &irDocument.jsGenerator,-
265 &irDocument.jsModule, &irDocument.jsParserEngine,-
266 irDocument.program, nullptr,-
267 &irDocument.jsGenerator.stringTable, illegalNames);-
268 v4CodeGen.setUseFastLookups(false);-
269 v4CodeGen.generateFromProgram(inputFileName, inputFileUrl, sourceCode, program,-
270 &irDocument.jsModule, QV4::Compiler::ContextType::Global);-
271 QList<QQmlJS::DiagnosticMessage> jsErrors = v4CodeGen.errors();-
272 if (!jsErrors.isEmpty()
!jsErrors.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
273 for (const QQmlJS::DiagnosticMessage &e: qAsConst(jsErrors)) {-
274 if (!error->message.isEmpty()
!error->message.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
275 error->message += QLatin1Char('\n');
never executed: error->message += QLatin1Char('\n');
0
276 error->message += diagnosticErrorMessage(inputFileName, e);-
277 }
never executed: end of block
0
278 engine->setDirectives(oldDirs);-
279 return
never executed: return false;
false;
never executed: return false;
0
280 }-
281-
282 QmlIR::QmlUnitGenerator generator;-
283-
284 irDocument.javaScriptCompilationUnit = v4CodeGen.generateCompilationUnit( false);-
285 QV4::CompiledData::Unit *unit = generator.generate(irDocument);-
286 unit->flags |= QV4::CompiledData::Unit::StaticData;-
287 irDocument.javaScriptCompilationUnit->data = unit;-
288-
289 if (!saveFunction(irDocument.javaScriptCompilationUnit.data(), &error->message)
!saveFunction(...rror->message)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
290 engine->setDirectives(oldDirs);-
291 return
never executed: return false;
false;
never executed: return false;
0
292 }-
293-
294 free(unit);-
295 }-
296 engine->setDirectives(oldDirs);-
297 return
never executed: return true;
true;
never executed: return true;
0
298}-
299-
300static bool saveUnitAsCpp(const QString &inputFileName, const QString &outputFileName, QV4::CompiledData::CompilationUnit *unit, QString *errorString)-
301{-
302 QSaveFile f(outputFileName);-
303 if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)
!f.open(QIODev...ice::Truncate)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
304 *errorString = f.errorString();-
305 return
never executed: return false;
false;
never executed: return false;
0
306 }-
307-
308 auto writeStr = [&f, errorString](const QByteArray &data) {-
309 if (f.write(data) != data.size()
f.write(data) != data.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
310 *errorString = f.errorString();-
311 return
never executed: return false;
false;
never executed: return false;
0
312 }-
313 return
never executed: return true;
true;
never executed: return true;
0
314 };-
315-
316 if (!writeStr("// ")
!writeStr("// ")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
317 return
never executed: return false;
false;
never executed: return false;
0
318-
319 if (!writeStr(inputFileName.toUtf8())
!writeStr(inpu...Name.toUtf8())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
320 return
never executed: return false;
false;
never executed: return false;
0
321-
322 if (!writeStr("\n")
!writeStr("\n")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
323 return
never executed: return false;
false;
never executed: return false;
0
324-
325 if (!writeStr(([]() -> QByteArray { enum { Size = sizeof("namespace QmlCacheGeneratedCode {\nnamespace ") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "namespace QmlCacheGeneratedCode {\nnamespace " }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
!writeStr(([](...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
326 return
never executed: return false;
false;
never executed: return false;
0
327-
328 if (!writeStr(symbolNamespaceForPath(inputFileName).toUtf8())
!writeStr(symb...ame).toUtf8())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
329 return
never executed: return false;
false;
never executed: return false;
0
330-
331 if (!writeStr(([]() -> QByteArray { enum { Size = sizeof(" {\nextern const unsigned char qmlData alignas(16) [] = {\n") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, " {\nextern const unsigned char qmlData alignas(16) [] = {\n" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
!writeStr(([](...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
332 return
never executed: return false;
false;
never executed: return false;
0
333-
334 QByteArray hexifiedData;-
335 {-
336 QByteArray modifiedUnit;-
337 modifiedUnit.resize(unit->data->unitSize);-
338 memcpy(modifiedUnit.data(), unit->data, unit->data->unitSize);-
339 const char *dataPtr = modifiedUnit.data();-
340 QV4::CompiledData::Unit *unitPtr;-
341 memcpy(&unitPtr, &dataPtr, sizeof(unitPtr));-
342 unitPtr->flags |= QV4::CompiledData::Unit::StaticData;-
343-
344 QTextStream stream(&hexifiedData);-
345 const uchar *begin = reinterpret_cast<const uchar *>(modifiedUnit.constData());-
346 const uchar *end = begin + unit->data->unitSize;-
347 stream << hex;-
348 int col = 0;-
349 for (const uchar *data = begin; data < end
data < endDescription
TRUEnever evaluated
FALSEnever evaluated
; ++data, ++col) {
0
350 if (data > begin
data > beginDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
351 stream << ',';
never executed: stream << ',';
0
352 if (col % 8 == 0
col % 8 == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
353 stream << '\n';-
354 col = 0;-
355 }
never executed: end of block
0
356 stream << "0x" << *data;-
357 }
never executed: end of block
0
358 stream << '\n';-
359 };-
360-
361 if (!writeStr(hexifiedData)
!writeStr(hexifiedData)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
362 return
never executed: return false;
false;
never executed: return false;
0
363-
364 if (!writeStr("};\n}\n}\n")
!writeStr("};\n}\n}\n")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
365 return
never executed: return false;
false;
never executed: return false;
0
366-
367 if (!f.commit()
!f.commit()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
368 *errorString = f.errorString();-
369 return
never executed: return false;
false;
never executed: return false;
0
370 }-
371-
372 return
never executed: return true;
true;
never executed: return true;
0
373}-
374-
375int main(int argc, char **argv)-
376{-
377-
378 qSetGlobalQHashSeed(0);-
379-
380 QCoreApplication app(argc, argv);-
381 QCoreApplication::setApplicationName(([]() noexcept -> QString { enum { Size = sizeof(u"" "qmlcachegen")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "qmlcachegen" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
382 QCoreApplication::setApplicationVersion(QLatin1String("5.12.0"));-
383-
384 QCommandLineParser parser;-
385 parser.addHelpOption();-
386 parser.addVersionOption();-
387-
388 QCommandLineOption filterResourceFileOption(([]() noexcept -> QString { enum { Size = sizeof(u"" "filter-resource-file")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "filter-resource-file" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()), QCoreApplication::translate("main", "Filter out QML/JS files from a resource file that can be cached ahead of time instead"));
12
389 parser.addOption(filterResourceFileOption);-
390 QCommandLineOption resourceFileMappingOption(([]() noexcept -> QString { enum { Size = sizeof(u"" "resource-file-mapping")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "resource-file-mapping" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()), QCoreApplication::translate("main", "Path from original resource file to new one"), QCoreApplication::translate("main", "old-name:new-name"));
12
391 parser.addOption(resourceFileMappingOption);-
392 QCommandLineOption resourceOption(([]() noexcept -> QString { enum { Size = sizeof(u"" "resource")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "resource" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()), QCoreApplication::translate("main", "Qt resource file that might later contain one of the compiled files"), QCoreApplication::translate("main", "resource-file-name"));
12
393 parser.addOption(resourceOption);-
394 QCommandLineOption resourcePathOption(([]() noexcept -> QString { enum { Size = sizeof(u"" "resource-path")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "resource-path" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()), QCoreApplication::translate("main", "Qt resource file path corresponding to the file being compiled"), QCoreApplication::translate("main", "resource-path"));
12
395 parser.addOption(resourcePathOption);-
396-
397 QCommandLineOption outputFileOption(([]() noexcept -> QString { enum { Size = sizeof(u"" "o")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "o" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()), QCoreApplication::translate("main", "Output file name"), QCoreApplication::translate("main", "file name"));
12
398 parser.addOption(outputFileOption);-
399-
400 parser.addPositionalArgument(([]() noexcept -> QString { enum { Size = sizeof(u"" "[qml file]")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "[qml file]" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()),
12
401 ([]() noexcept -> QString { enum { Size = sizeof(u"" "QML source file to generate cache for.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QML source file to generate cache for." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
qstring_literal_temp;
executed 12 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_qmlcachegen
}()));
12
402-
403 parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);-
404-
405 parser.process(app);-
406-
407 enum Output {-
408 GenerateCpp,-
409 GenerateCacheFile,-
410 GenerateLoader-
411 } target = GenerateCacheFile;-
412-
413 QString outputFileName;-
414 if (parser.isSet(outputFileOption)
parser.isSet(outputFileOption)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
)
0-12
415 outputFileName = parser.value(outputFileOption);
never executed: outputFileName = parser.value(outputFileOption);
0
416-
417 if (outputFileName.endsWith(QLatin1String(".cpp"))
outputFileName...tring(".cpp"))Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
0-12
418 target = GenerateCpp;-
419 if (outputFileName.endsWith(QLatin1String("qmlcache_loader.cpp"))
outputFileName..._loader.cpp"))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
420 target = GenerateLoader;
never executed: target = GenerateLoader;
0
421 }
never executed: end of block
0
422-
423 const QStringList sources = parser.positionalArguments();-
424 if (sources.isEmpty()
sources.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
){
0-12
425 parser.showHelp();-
426 }
never executed: end of block
else if (sources.count() > 1
sources.count() > 1Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
&& target != GenerateLoader
target != GenerateLoaderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0-12
427 fprintf(-
428 stderr-
429 , "%s\n", QtPrivate::asString(([]() noexcept -> QString { enum { Size = sizeof(u"" "Too many input files specified: '")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Too many input files specified: '" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()) + sources.join(([]() noexcept -> QString { enum { Size = sizeof(u"" "' '")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "' '" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}())) + QLatin1Char('\'')).toLocal8Bit().constData());
0
430 return
never executed: return 1 ;
never executed: return 1 ;
0
431 1
never executed: return 1 ;
0
432 ;
never executed: return 1 ;
0
433 }-
434-
435 const QString inputFile = sources.first();-
436 if (outputFileName.isEmpty()
outputFileName.isEmpty()Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEnever evaluated
)
0-12
437 outputFileName = inputFile + QLatin1Char('c');
executed 12 times by 1 test: outputFileName = inputFile + QLatin1Char('c');
Executed by:
  • tst_qmlcachegen
12
438-
439 if (parser.isSet(filterResourceFileOption)
parser.isSet(f...rceFileOption)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
0-12
440 return
never executed: return filterResourceFile(inputFile, outputFileName);
filterResourceFile(inputFile, outputFileName);
never executed: return filterResourceFile(inputFile, outputFileName);
0
441 }-
442-
443 if (target == GenerateLoader
target == GenerateLoaderDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
0-12
444 ResourceFileMapper mapper(sources);-
445-
446 Error error;-
447 if (!generateLoader(mapper.qmlCompilerFiles(), outputFileName, parser.values(resourceFileMappingOption), &error.message)
!generateLoade...error.message)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
448 error.augment(QLatin1String("Error generating loader stub: ")).print();-
449 return
never executed: return 1 ;
never executed: return 1 ;
0
450 1
never executed: return 1 ;
0
451 ;
never executed: return 1 ;
0
452 }-
453 return
never executed: return 0 ;
never executed: return 0 ;
0
454 0
never executed: return 0 ;
0
455 ;
never executed: return 0 ;
0
456 }-
457-
458 QString inputFileUrl = inputFile;-
459-
460 SaveFunction saveFunction;-
461 if (target == GenerateCpp
target == GenerateCppDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
0-12
462 ResourceFileMapper fileMapper(parser.values(resourceOption));-
463 QString inputResourcePath = parser.value(resourcePathOption);-
464-
465 if (!inputResourcePath.isEmpty()
!inputResourcePath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& !fileMapper.isEmpty()
!fileMapper.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
466 fprintf(-
467 stderr-
468 , "--%s and --%s are mutually exclusive.\n",-
469 QtPrivate::asString(resourcePathOption.names().first()).toLocal8Bit().constData(),-
470 QtPrivate::asString(resourceOption.names().first()).toLocal8Bit().constData());-
471 return
never executed: return 1 ;
never executed: return 1 ;
0
472 1
never executed: return 1 ;
0
473 ;
never executed: return 1 ;
0
474 }-
475-
476-
477-
478 if (inputResourcePath.isEmpty()
inputResourcePath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
479 const QStringList resourcePaths = fileMapper.resourcePaths(inputFile);-
480 if (resourcePaths.isEmpty()
resourcePaths.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
481 fprintf(-
482 stderr-
483 , "No resource path for file: %s\n", QtPrivate::asString(inputFile).toLocal8Bit().constData());-
484 return
never executed: return 1 ;
never executed: return 1 ;
0
485 1
never executed: return 1 ;
0
486 ;
never executed: return 1 ;
0
487 }-
488-
489 if (resourcePaths.size() != 1
resourcePaths.size() != 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
490 fprintf(-
491 stderr-
492 , "Multiple resource paths for file %s. "-
493 "Use the --%s option to disambiguate:\n",-
494 QtPrivate::asString(inputFile).toLocal8Bit().constData(),-
495 QtPrivate::asString(resourcePathOption.names().first()).toLocal8Bit().constData());-
496 for (const QString &resourcePath: resourcePaths)-
497 fprintf(
never executed: fprintf( stderr , "\t%s\n", QtPrivate::asString(resourcePath).toLocal8Bit().constData());
0
498 stderr
never executed: fprintf( stderr , "\t%s\n", QtPrivate::asString(resourcePath).toLocal8Bit().constData());
0
499 , "\t%s\n", QtPrivate::asString(resourcePath).toLocal8Bit().constData());
never executed: fprintf( stderr , "\t%s\n", QtPrivate::asString(resourcePath).toLocal8Bit().constData());
0
500 return
never executed: return 1 ;
never executed: return 1 ;
0
501 1
never executed: return 1 ;
0
502 ;
never executed: return 1 ;
0
503 }-
504-
505 inputResourcePath = resourcePaths.first();-
506 }
never executed: end of block
0
507-
508 inputFileUrl = ([]() noexcept -> QString { enum { Size = sizeof(u"" "qrc://")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "qrc://" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()) + inputResourcePath;-
509-
510 saveFunction = [inputResourcePath, outputFileName](QV4::CompiledData::CompilationUnit *unit, QString *errorString) {-
511 return
never executed: return saveUnitAsCpp(inputResourcePath, outputFileName, unit, errorString);
saveUnitAsCpp(inputResourcePath, outputFileName, unit, errorString);
never executed: return saveUnitAsCpp(inputResourcePath, outputFileName, unit, errorString);
0
512 };-
513-
514 }
never executed: end of block
else {
0
515 saveFunction = [outputFileName](QV4::CompiledData::CompilationUnit *unit, QString *errorString) {-
516 return
executed 10 times by 1 test: return unit->saveToDisk(outputFileName, errorString);
Executed by:
  • tst_qmlcachegen
unit->saveToDisk(outputFileName, errorString);
executed 10 times by 1 test: return unit->saveToDisk(outputFileName, errorString);
Executed by:
  • tst_qmlcachegen
10
517 };-
518 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
12
519-
520 setupIllegalNames();-
521-
522-
523 if (inputFile.endsWith(QLatin1String(".qml"))
inputFile.ends...tring(".qml"))Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEnever evaluated
) {
0-12
524 Error error;-
525 if (!compileQmlFile(inputFile, saveFunction, &error)
!compileQmlFil...ction, &error)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmlcachegen
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qmlcachegen
) {
2-10
526 error.augment(QLatin1String("Error compiling qml file: ")).print();-
527 return
executed 2 times by 1 test: return 1 ;
Executed by:
  • tst_qmlcachegen
executed 2 times by 1 test: return 1 ;
Executed by:
  • tst_qmlcachegen
2
528 1
executed 2 times by 1 test: return 1 ;
Executed by:
  • tst_qmlcachegen
2
529 ;
executed 2 times by 1 test: return 1 ;
Executed by:
  • tst_qmlcachegen
2
530 }-
531 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qmlcachegen
else if (inputFile.endsWith(QLatin1String(".js"))
inputFile.ends...String(".js"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0-10
532 Error error;-
533 if (!compileJSFile(inputFile, inputFileUrl, saveFunction, &error)
!compileJSFile...ction, &error)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
534 error.augment(QLatin1String("Error compiling js file: ")).print();-
535 return
never executed: return 1 ;
never executed: return 1 ;
0
536 1
never executed: return 1 ;
0
537 ;
never executed: return 1 ;
0
538 }-
539 }
never executed: end of block
else {
0
540 fprintf(-
541 stderr-
542 , "Ignoring %s input file as it is not QML source code - maybe remove from QML_FILES?\n", QtPrivate::asString(inputFile).toLocal8Bit().constData());-
543 }
never executed: end of block
0
544-
545 return
executed 10 times by 1 test: return 0 ;
Executed by:
  • tst_qmlcachegen
executed 10 times by 1 test: return 0 ;
Executed by:
  • tst_qmlcachegen
10
546 0
executed 10 times by 1 test: return 0 ;
Executed by:
  • tst_qmlcachegen
10
547 ;
executed 10 times by 1 test: return 0 ;
Executed by:
  • tst_qmlcachegen
10
548}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0