OpenCoverage

main.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/tools/qmlmin/main.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8namespace QQmlJS {-
9-
10enum RegExpFlag {-
11 Global = 0x01,-
12 IgnoreCase = 0x02,-
13 Multiline = 0x04-
14};-
15-
16-
17class QmlminLexer: protected Lexer, public Directives-
18{-
19 QQmlJS::Engine _engine;-
20 QString _fileName;-
21 QString _directives;-
22-
23protected:-
24 QVector<int> _stateStack;-
25 QList<int> _tokens;-
26 QList<QString> _tokenStrings;-
27 int yytoken = -1;-
28 QString yytokentext;-
29-
30 void lex() {-
31 if (_tokens.isEmpty()
_tokens.isEmpty()Description
TRUEevaluated 8894968 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 339844 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
339844-8894968
32 _tokens.append(Lexer::lex());-
33 _tokenStrings.append(tokenText());-
34 }
executed 8894968 times by 1 test: end of block
Executed by:
  • tst_qmlmin
8894968
35-
36 yytoken = _tokens.takeFirst();-
37 yytokentext = _tokenStrings.takeFirst();-
38 }
executed 9234812 times by 1 test: end of block
Executed by:
  • tst_qmlmin
9234812
39-
40 int lookaheadToken()-
41 {-
42 if (yytoken < 0
yytoken < 0Description
TRUEevaluated 851740 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 398546 times by 1 test
Evaluated by:
  • tst_qmlmin
)
398546-851740
43 lex();
executed 851740 times by 1 test: lex();
Executed by:
  • tst_qmlmin
851740
44 return
executed 1250286 times by 1 test: return yytoken;
Executed by:
  • tst_qmlmin
yytoken;
executed 1250286 times by 1 test: return yytoken;
Executed by:
  • tst_qmlmin
1250286
45 }-
46-
47 void pushToken(int token)-
48 {-
49 _tokens.prepend(yytoken);-
50 _tokenStrings.prepend(yytokentext);-
51 yytoken = token;-
52 yytokentext = QString();-
53 }
executed 48632 times by 1 test: end of block
Executed by:
  • tst_qmlmin
48632
54-
55public:-
56 QmlminLexer()-
57 : Lexer(&_engine), _stateStack(128) {}
executed 39940 times by 1 test: end of block
Executed by:
  • tst_qmlmin
39940
58 virtual ~QmlminLexer() {}-
59-
60 QString fileName() const { return
executed 76 times by 1 test: return _fileName;
Executed by:
  • tst_qmlmin
_fileName;
executed 76 times by 1 test: return _fileName;
Executed by:
  • tst_qmlmin
}
76
61-
62 bool operator()(const QString &fileName, const QString &code)-
63 {-
64 int startToken = T_FEED_JS_SCRIPT;-
65 const QFileInfo fileInfo(fileName);-
66 if (fileInfo.suffix().toLower() == QLatin1String("qml")
fileInfo.suffi...1String("qml")Description
TRUEevaluated 29332 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 10608 times by 1 test
Evaluated by:
  • tst_qmlmin
)
10608-29332
67 startToken = T_FEED_UI_PROGRAM;
executed 29332 times by 1 test: startToken = T_FEED_UI_PROGRAM;
Executed by:
  • tst_qmlmin
29332
68 setCode(code, 1, startToken == T_FEED_UI_PROGRAM);-
69 _fileName = fileName;-
70 _directives.clear();-
71 return
executed 39940 times by 1 test: return parse(startToken);
Executed by:
  • tst_qmlmin
parse(startToken);
executed 39940 times by 1 test: return parse(startToken);
Executed by:
  • tst_qmlmin
39940
72 }-
73-
74 QString directives()-
75 {-
76 return
executed 10586 times by 1 test: return _directives;
Executed by:
  • tst_qmlmin
_directives;
executed 10586 times by 1 test: return _directives;
Executed by:
  • tst_qmlmin
10586
77 }-
78-
79-
80-
81-
82 void pragmaLibrary() override-
83 {-
84 _directives += QLatin1String(".pragma library\n");-
85 }
executed 178 times by 1 test: end of block
Executed by:
  • tst_qmlmin
178
86-
87 void importFile(const QString &jsfile, const QString &module, int line, int column) override-
88 {-
89 _directives += QLatin1String(".import");-
90 _directives += QLatin1Char('"');-
91 _directives += quote(jsfile);-
92 _directives += QLatin1Char('"');-
93 _directives += QLatin1String("as ");-
94 _directives += module;-
95 _directives += QLatin1Char('\n');-
96 (void)line;;-
97 (void)column;;-
98 }
executed 872 times by 1 test: end of block
Executed by:
  • tst_qmlmin
872
99-
100 void importModule(const QString &uri, const QString &version, const QString &module, int line, int column) override-
101 {-
102 _directives += QLatin1String(".import ");-
103 _directives += uri;-
104 _directives += QLatin1Char(' ');-
105 _directives += version;-
106 _directives += QLatin1String(" as ");-
107 _directives += module;-
108 _directives += QLatin1Char('\n');-
109 (void)line;;-
110 (void)column;;-
111 }
executed 312 times by 1 test: end of block
Executed by:
  • tst_qmlmin
312
112-
113protected:-
114 virtual bool parse(int startToken) = 0;-
115-
116 static QString quote(const QString &string)-
117 {-
118 QString quotedString;-
119 for (const QChar &ch : string) {-
120 if (ch == QLatin1Char('"')
ch == QLatin1Char('"')Description
TRUEevaluated 19620 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3624962 times by 1 test
Evaluated by:
  • tst_qmlmin
)
19620-3624962
121 quotedString += QLatin1String("\\\"");
executed 19620 times by 1 test: quotedString += QLatin1String("\\\"");
Executed by:
  • tst_qmlmin
19620
122 else {-
123 if (ch == QLatin1Char('\\')
ch == QLatin1Char('\\')Description
TRUEevaluated 2024 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3622938 times by 1 test
Evaluated by:
  • tst_qmlmin
) quotedString += QLatin1String("\\\\");
executed 2024 times by 1 test: quotedString += QLatin1String("\\\\");
Executed by:
  • tst_qmlmin
2024-3622938
124 else if (ch == QLatin1Char('\"')
ch == QLatin1Char('\"')Description
TRUEnever evaluated
FALSEevaluated 3622938 times by 1 test
Evaluated by:
  • tst_qmlmin
) quotedString += QLatin1String("\\\"");
never executed: quotedString += QLatin1String("\\\"");
0-3622938
125 else if (ch == QLatin1Char('\b')
ch == QLatin1Char('\b')Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3622910 times by 1 test
Evaluated by:
  • tst_qmlmin
) quotedString += QLatin1String("\\b");
executed 28 times by 1 test: quotedString += QLatin1String("\\b");
Executed by:
  • tst_qmlmin
28-3622910
126 else if (ch == QLatin1Char('\f')
ch == QLatin1Char('\f')Description
TRUEevaluated 200 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3622710 times by 1 test
Evaluated by:
  • tst_qmlmin
) quotedString += QLatin1String("\\f");
executed 200 times by 1 test: quotedString += QLatin1String("\\f");
Executed by:
  • tst_qmlmin
200-3622710
127 else if (ch == QLatin1Char('\n')
ch == QLatin1Char('\n')Description
TRUEevaluated 7328 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3615382 times by 1 test
Evaluated by:
  • tst_qmlmin
) quotedString += QLatin1String("\\n");
executed 7328 times by 1 test: quotedString += QLatin1String("\\n");
Executed by:
  • tst_qmlmin
7328-3615382
128 else if (ch == QLatin1Char('\r')
ch == QLatin1Char('\r')Description
TRUEevaluated 336 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3615046 times by 1 test
Evaluated by:
  • tst_qmlmin
) quotedString += QLatin1String("\\r");
executed 336 times by 1 test: quotedString += QLatin1String("\\r");
Executed by:
  • tst_qmlmin
336-3615046
129 else if (ch == QLatin1Char('\t')
ch == QLatin1Char('\t')Description
TRUEevaluated 5864 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3609182 times by 1 test
Evaluated by:
  • tst_qmlmin
) quotedString += QLatin1String("\\t");
executed 5864 times by 1 test: quotedString += QLatin1String("\\t");
Executed by:
  • tst_qmlmin
5864-3609182
130 else if (ch == QLatin1Char('\v')
ch == QLatin1Char('\v')Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3609074 times by 1 test
Evaluated by:
  • tst_qmlmin
) quotedString += QLatin1String("\\v");
executed 108 times by 1 test: quotedString += QLatin1String("\\v");
Executed by:
  • tst_qmlmin
108-3609074
131 else if (ch == QLatin1Char('\0')
ch == QLatin1Char('\0')Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3609050 times by 1 test
Evaluated by:
  • tst_qmlmin
) quotedString += QLatin1String("\\0");
executed 24 times by 1 test: quotedString += QLatin1String("\\0");
Executed by:
  • tst_qmlmin
24-3609050
132 else quotedString += ch;
executed 3609050 times by 1 test: quotedString += ch;
Executed by:
  • tst_qmlmin
3609050
133 }-
134 }-
135 return
executed 205310 times by 1 test: return quotedString;
Executed by:
  • tst_qmlmin
quotedString;
executed 205310 times by 1 test: return quotedString;
Executed by:
  • tst_qmlmin
205310
136 }-
137-
138 bool isIdentChar(const QChar &ch) const-
139 {-
140 if (ch.isLetterOrNumber()
ch.isLetterOrNumber()Description
TRUEevaluated 1609510 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3510010 times by 1 test
Evaluated by:
  • tst_qmlmin
)
1609510-3510010
141 return
executed 1609510 times by 1 test: return true;
Executed by:
  • tst_qmlmin
true;
executed 1609510 times by 1 test: return true;
Executed by:
  • tst_qmlmin
1609510
142 else if (ch == QLatin1Char('_')
ch == QLatin1Char('_')Description
TRUEevaluated 464 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3509546 times by 1 test
Evaluated by:
  • tst_qmlmin
|| ch == QLatin1Char('$')
ch == QLatin1Char('$')Description
TRUEnever evaluated
FALSEevaluated 3509546 times by 1 test
Evaluated by:
  • tst_qmlmin
)
0-3509546
143 return
executed 464 times by 1 test: return true;
Executed by:
  • tst_qmlmin
true;
executed 464 times by 1 test: return true;
Executed by:
  • tst_qmlmin
464
144 return
executed 3509546 times by 1 test: return false;
Executed by:
  • tst_qmlmin
false;
executed 3509546 times by 1 test: return false;
Executed by:
  • tst_qmlmin
3509546
145 }-
146-
147 bool isRegExpRule(int ruleno) const-
148 {-
149 return
executed 60844938 times by 1 test: return ruleno == 128 || ruleno == 129;
Executed by:
  • tst_qmlmin
ruleno == 128 ||
executed 60844938 times by 1 test: return ruleno == 128 || ruleno == 129;
Executed by:
  • tst_qmlmin
60844938
150 ruleno == 129;
executed 60844938 times by 1 test: return ruleno == 128 || ruleno == 129;
Executed by:
  • tst_qmlmin
60844938
151 }-
152-
153 void handleLookaheads(int ruleno) {-
154 if (ruleno == 420
ruleno == 420Description
TRUEevaluated 1250286 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 59594652 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
1250286-59594652
155 int token = lookaheadToken();-
156 if (token == T_LBRACE
token == T_LBRACEDescription
TRUEevaluated 33624 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 1216662 times by 1 test
Evaluated by:
  • tst_qmlmin
)
33624-1216662
157 pushToken(T_FORCE_BLOCK);
executed 33624 times by 1 test: pushToken(T_FORCE_BLOCK);
Executed by:
  • tst_qmlmin
33624
158 else if (token == T_FUNCTION
token == T_FUNCTIONDescription
TRUEevaluated 15008 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 1201654 times by 1 test
Evaluated by:
  • tst_qmlmin
|| token == T_CLASS
token == T_CLASSDescription
TRUEnever evaluated
FALSEevaluated 1201654 times by 1 test
Evaluated by:
  • tst_qmlmin
|| token == T_LET
token == T_LETDescription
TRUEnever evaluated
FALSEevaluated 1201654 times by 1 test
Evaluated by:
  • tst_qmlmin
|| token == T_CONST
token == T_CONSTDescription
TRUEnever evaluated
FALSEevaluated 1201654 times by 1 test
Evaluated by:
  • tst_qmlmin
)
0-1201654
159 pushToken(T_FORCE_DECLARATION);
executed 15008 times by 1 test: pushToken(T_FORCE_DECLARATION);
Executed by:
  • tst_qmlmin
15008
160 }
executed 1250286 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else if (ruleno == 498
ruleno == 498Description
TRUEnever evaluated
FALSEevaluated 59594652 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-59594652
161 int token = lookaheadToken();-
162 if (token == T_LBRACE
token == T_LBRACEDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
163 pushToken(T_FORCE_BLOCK);
never executed: pushToken(T_FORCE_BLOCK);
0
164 }
never executed: end of block
else if (ruleno == 568
ruleno == 568Description
TRUEnever evaluated
FALSEevaluated 59594652 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-59594652
165 int token = lookaheadToken();-
166 if (token == T_FUNCTION
token == T_FUNCTIONDescription
TRUEnever evaluated
FALSEnever evaluated
|| token == T_CLASS
token == T_CLASSDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
167 pushToken(T_FORCE_DECLARATION);
never executed: pushToken(T_FORCE_DECLARATION);
0
168 }
never executed: end of block
0
169 }
executed 60844938 times by 1 test: end of block
Executed by:
  • tst_qmlmin
60844938
170-
171 bool scanRestOfRegExp(int ruleno, QString *restOfRegExp)-
172 {-
173 if (! scanRegExp(ruleno == 128 ? Lexer::NoPrefix : Lexer::EqualPrefix)
! scanRegExp(r...::EqualPrefix)Description
TRUEnever evaluated
FALSEevaluated 7464 times by 1 test
Evaluated by:
  • tst_qmlmin
)
0-7464
174 return
never executed: return false;
false;
never executed: return false;
0
175-
176 *restOfRegExp = regExpPattern();-
177 if (ruleno == 129
ruleno == 129Description
TRUEnever evaluated
FALSEevaluated 7464 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-7464
178 ((! restOfRegExp->isEmpty()) ? static_cast<void>(0) : qt_assert("! restOfRegExp->isEmpty()", __FILE__, 215));-
179 ((restOfRegExp->at(0) == QLatin1Char('=')) ? static_cast<void>(0) : qt_assert("restOfRegExp->at(0) == QLatin1Char('=')", __FILE__, 216));-
180 *restOfRegExp = restOfRegExp->mid(1);-
181 }
never executed: end of block
0
182 *restOfRegExp += QLatin1Char('/');-
183 const RegExpFlag flags = (RegExpFlag) regExpFlags();-
184 if (flags & Global
flags & GlobalDescription
TRUEevaluated 992 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 6472 times by 1 test
Evaluated by:
  • tst_qmlmin
)
992-6472
185 *
executed 992 times by 1 test: *restOfRegExp += QLatin1Char('g');
Executed by:
  • tst_qmlmin
restOfRegExp += QLatin1Char('g');
executed 992 times by 1 test: *restOfRegExp += QLatin1Char('g');
Executed by:
  • tst_qmlmin
992
186 if (flags & IgnoreCase
flags & IgnoreCaseDescription
TRUEevaluated 1256 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 6208 times by 1 test
Evaluated by:
  • tst_qmlmin
)
1256-6208
187 *
executed 1256 times by 1 test: *restOfRegExp += QLatin1Char('i');
Executed by:
  • tst_qmlmin
restOfRegExp += QLatin1Char('i');
executed 1256 times by 1 test: *restOfRegExp += QLatin1Char('i');
Executed by:
  • tst_qmlmin
1256
188 if (flags & Multiline
flags & MultilineDescription
TRUEevaluated 888 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 6576 times by 1 test
Evaluated by:
  • tst_qmlmin
)
888-6576
189 *
executed 888 times by 1 test: *restOfRegExp += QLatin1Char('m');
Executed by:
  • tst_qmlmin
restOfRegExp += QLatin1Char('m');
executed 888 times by 1 test: *restOfRegExp += QLatin1Char('m');
Executed by:
  • tst_qmlmin
888
190-
191 if (regExpFlags() == 0
regExpFlags() == 0Description
TRUEevaluated 4680 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 2784 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
2784-4680
192-
193-
194-
195 *restOfRegExp += QLatin1Char(' ');-
196 }
executed 4680 times by 1 test: end of block
Executed by:
  • tst_qmlmin
4680
197 return
executed 7464 times by 1 test: return true;
Executed by:
  • tst_qmlmin
true;
executed 7464 times by 1 test: return true;
Executed by:
  • tst_qmlmin
7464
198 }-
199};-
200-
201-
202class Minify: public QmlminLexer-
203{-
204 QString _minifiedCode;-
205 int _maxWidth;-
206 int _width;-
207-
208public:-
209 Minify(int maxWidth);-
210-
211 QString minifiedCode() const;-
212-
213protected:-
214 void append(const QString &s);-
215 bool parse(int startToken) override;-
216 void escape(const QChar &ch, QString *out);-
217};-
218-
219Minify::Minify(int maxWidth)-
220 : _maxWidth(maxWidth), _width(0)-
221{-
222}
executed 20008 times by 1 test: end of block
Executed by:
  • tst_qmlmin
20008
223-
224QString Minify::minifiedCode() const-
225{-
226 return
executed 39864 times by 1 test: return _minifiedCode;
Executed by:
  • tst_qmlmin
_minifiedCode;
executed 39864 times by 1 test: return _minifiedCode;
Executed by:
  • tst_qmlmin
39864
227}-
228-
229void Minify::append(const QString &s)-
230{-
231 if (!s.isEmpty()
!s.isEmpty()Description
TRUEevaluated 548296 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 4892 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
4892-548296
232 if (_maxWidth
_maxWidthDescription
TRUEevaluated 548296 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEnever evaluated
) {
0-548296
233-
234 int segmentLength = s.count();-
235 if (_width
_widthDescription
TRUEevaluated 528526 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 19770 times by 1 test
Evaluated by:
  • tst_qmlmin
&& ((
((_width + seg...) > _maxWidth)Description
TRUEevaluated 177076 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 351450 times by 1 test
Evaluated by:
  • tst_qmlmin
_width + segmentLength) > _maxWidth)
((_width + seg...) > _maxWidth)Description
TRUEevaluated 177076 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 351450 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
19770-528526
236 _minifiedCode.append(QLatin1Char('\n'));-
237 _width = 0;-
238 }
executed 177076 times by 1 test: end of block
Executed by:
  • tst_qmlmin
177076
239-
240 _width += segmentLength;-
241 }
executed 548296 times by 1 test: end of block
Executed by:
  • tst_qmlmin
548296
242-
243 _minifiedCode.append(s);-
244 }
executed 548296 times by 1 test: end of block
Executed by:
  • tst_qmlmin
548296
245}
executed 553188 times by 1 test: end of block
Executed by:
  • tst_qmlmin
553188
246-
247void Minify::escape(const QChar &ch, QString *out)-
248{-
249 out->append(QLatin1String("\\u"));-
250 const QString hx = QString::number(ch.unicode(), 16);-
251 switch (hx.length()) {-
252 case
never executed: case 1:
1:
never executed: case 1:
out->append(QLatin1String("000")); break;
never executed: break;
0
253 case
executed 4 times by 1 test: case 2:
Executed by:
  • tst_qmlmin
2:
executed 4 times by 1 test: case 2:
Executed by:
  • tst_qmlmin
out->append(QLatin1String("00")); break;
executed 4 times by 1 test: break;
Executed by:
  • tst_qmlmin
4
254 case
never executed: case 3:
3:
never executed: case 3:
out->append(QLatin1Char('0')); break;
never executed: break;
0
255 case
never executed: case 4:
4:
never executed: case 4:
break;
never executed: break;
0
256 default
never executed: default:
:
never executed: default:
((!"unreachable") ? static_cast<void>(0) : qt_assert("!\"unreachable\"", __FILE__, 293));
0
257 }
never executed: end of block
0
258 out->append(hx);-
259}
executed 4 times by 1 test: end of block
Executed by:
  • tst_qmlmin
4
260-
261bool Minify::parse(int startToken)-
262{-
263 int yyaction = 0;-
264 int yytos = -1;-
265 QString assembled;-
266-
267 _minifiedCode.clear();-
268 _tokens.append(startToken);-
269 _tokenStrings.append(QString());-
270-
271 if (startToken == T_FEED_JS_SCRIPT
startToken == T_FEED_JS_SCRIPTDescription
TRUEevaluated 5320 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 14688 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
5320-14688
272-
273 DiagnosticMessage error;-
274 if (scanDirectives(this, &error)
scanDirectives(this, &error)Description
TRUEevaluated 5298 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
22-5298
275-
276 append(directives());-
277-
278 _tokens.append(tokenKind());-
279 _tokenStrings.append(tokenText());-
280 }
executed 5298 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else {
5298
281 std::cerr << QtPrivate::asString(fileName()).toLocal8Bit().constData() << ':' << tokenStartLine() << ':'-
282 << tokenStartColumn() << ": syntax error" << std::endl;-
283 return
executed 22 times by 1 test: return false;
Executed by:
  • tst_qmlmin
false;
executed 22 times by 1 test: return false;
Executed by:
  • tst_qmlmin
22
284 }-
285 }-
286-
287 do {-
288 if (++
++yytos == _stateStack.size()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 35040890 times by 1 test
Evaluated by:
  • tst_qmlmin
yytos == _stateStack.size()
++yytos == _stateStack.size()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 35040890 times by 1 test
Evaluated by:
  • tst_qmlmin
)
8-35040890
289 _stateStack.resize(_stateStack.size() * 2);
executed 8 times by 1 test: _stateStack.resize(_stateStack.size() * 2);
Executed by:
  • tst_qmlmin
8
290-
291 _stateStack[yytos] = yyaction;-
292-
293 again:
code before this statement executed 35040898 times by 1 test: again:
Executed by:
  • tst_qmlmin
35040898
294 if (yytoken == -1
yytoken == -1Description
TRUEevaluated 13218344 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 21942928 times by 1 test
Evaluated by:
  • tst_qmlmin
&& action_index[yyaction] != -TERMINAL_COUNT
action_index[y...TERMINAL_COUNTDescription
TRUEevaluated 4191852 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 9026492 times by 1 test
Evaluated by:
  • tst_qmlmin
)
4191852-21942928
295 lex();
executed 4191852 times by 1 test: lex();
Executed by:
  • tst_qmlmin
4191852
296-
297 yyaction = t_action(yyaction, yytoken);-
298 if (yyaction > 0
yyaction > 0Description
TRUEevaluated 4617682 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 30543590 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
4617682-30543590
299 if (yyaction == ACCEPT_STATE
yyaction == ACCEPT_STATEDescription
TRUEevaluated 19932 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 4597750 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
19932-4597750
300 --yytos;-
301 if (!assembled.isEmpty()
!assembled.isEmpty()Description
TRUEevaluated 14656 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 5276 times by 1 test
Evaluated by:
  • tst_qmlmin
)
5276-14656
302 append(assembled);
executed 14656 times by 1 test: append(assembled);
Executed by:
  • tst_qmlmin
14656
303 return
executed 19932 times by 1 test: return true;
Executed by:
  • tst_qmlmin
true;
executed 19932 times by 1 test: return true;
Executed by:
  • tst_qmlmin
19932
304 }-
305-
306 const QChar lastChar = assembled.isEmpty()
assembled.isEmpty()Description
TRUEevaluated 575288 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 4022462 times by 1 test
Evaluated by:
  • tst_qmlmin
? (_minifiedCode.isEmpty()
_minifiedCode.isEmpty()Description
TRUEevaluated 39192 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 536096 times by 1 test
Evaluated by:
  • tst_qmlmin
? QChar()
39192-4022462
307 : _minifiedCode.at(_minifiedCode.length() - 1))-
308 : assembled.at(assembled.length() - 1);-
309-
310 if (yytoken == T_SEMICOLON
yytoken == T_SEMICOLONDescription
TRUEevaluated 533234 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 4064516 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
533234-4064516
311 assembled += QLatin1Char(';');-
312-
313 append(assembled);-
314 assembled.clear();-
315-
316 }
executed 533234 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else if (yytoken == T_PLUS
yytoken == T_PLUSDescription
TRUEevaluated 46288 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 4018228 times by 1 test
Evaluated by:
  • tst_qmlmin
|| yytoken == T_MINUS
yytoken == T_MINUSDescription
TRUEevaluated 34228 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3984000 times by 1 test
Evaluated by:
  • tst_qmlmin
|| yytoken == T_PLUS_PLUS
yytoken == T_PLUS_PLUSDescription
TRUEevaluated 4158 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3979842 times by 1 test
Evaluated by:
  • tst_qmlmin
|| yytoken == T_MINUS_MINUS
yytoken == T_MINUS_MINUSDescription
TRUEevaluated 592 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3979250 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
592-4018228
317 if (lastChar == QLatin1Char(spell[yytoken][0])
lastChar == QL...l[yytoken][0])Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 85226 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
40-85226
318-
319 assembled += QLatin1Char(' ');-
320 }
executed 40 times by 1 test: end of block
Executed by:
  • tst_qmlmin
40
321-
322 assembled += QLatin1String(spell[yytoken]);-
323-
324 }
executed 85266 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else if (yytoken == T_NUMERIC_LITERAL
yytoken == T_NUMERIC_LITERALDescription
TRUEevaluated 394448 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 3584802 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
85266-3584802
325 if (isIdentChar(lastChar)
isIdentChar(lastChar)Description
TRUEevaluated 92852 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 301596 times by 1 test
Evaluated by:
  • tst_qmlmin
)
92852-301596
326 assembled += QLatin1Char(' ');
executed 92852 times by 1 test: assembled += QLatin1Char(' ');
Executed by:
  • tst_qmlmin
92852
327-
328 if (yytokentext.startsWith('.')
yytokentext.startsWith('.')Description
TRUEevaluated 348 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 394100 times by 1 test
Evaluated by:
  • tst_qmlmin
)
348-394100
329 assembled += QLatin1Char('0');
executed 348 times by 1 test: assembled += QLatin1Char('0');
Executed by:
  • tst_qmlmin
348
330-
331 assembled += yytokentext;-
332-
333 if (assembled.endsWith(QLatin1Char('.'))
assembled.ends...tin1Char('.'))Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 394426 times by 1 test
Evaluated by:
  • tst_qmlmin
)
22-394426
334 assembled += QLatin1Char('0');
executed 22 times by 1 test: assembled += QLatin1Char('0');
Executed by:
  • tst_qmlmin
22
335-
336 }
executed 394448 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else if (yytoken == T_IDENTIFIER
yytoken == T_IDENTIFIERDescription
TRUEevaluated 1232022 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 2352780 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
394448-2352780
337 QString identifier = yytokentext;-
338-
339 if (classify(identifier.constData(), identifier.size(), qmlMode()) != T_IDENTIFIER
classify(ident...= T_IDENTIFIERDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 1232018 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
4-1232018
340-
341-
342 const QChar ch = identifier.at(identifier.length() - 1);-
343 identifier.chop(1);-
344 escape(ch, &identifier);-
345 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qmlmin
4
346-
347 if (isIdentChar(lastChar)
isIdentChar(lastChar)Description
TRUEevaluated 158358 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 1073664 times by 1 test
Evaluated by:
  • tst_qmlmin
)
158358-1073664
348 assembled += QLatin1Char(' ');
executed 158358 times by 1 test: assembled += QLatin1Char(' ');
Executed by:
  • tst_qmlmin
158358
349-
350 assembled += identifier;-
351-
352 }
executed 1232022 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else if (yytoken == T_STRING_LITERAL
yytoken == T_STRING_LITERALDescription
TRUEevaluated 204262 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 2148518 times by 1 test
Evaluated by:
  • tst_qmlmin
|| yytoken == T_MULTILINE_STRING_LITERAL
yytoken == T_M...STRING_LITERALDescription
TRUEevaluated 176 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 2148342 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
176-2148518
353 assembled += QLatin1Char('"');-
354 assembled += quote(yytokentext);-
355 assembled += QLatin1Char('"');-
356 }
executed 204438 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else {
204438
357 if (isIdentChar(lastChar)
isIdentChar(lastChar)Description
TRUEevaluated 1346108 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 802234 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
802234-1346108
358 if (! yytokentext.isEmpty()
! yytokentext.isEmpty()Description
TRUEevaluated 1344708 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 1400 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
1400-1344708
359 const QChar ch = yytokentext.at(0);-
360 if (isIdentChar(ch)
isIdentChar(ch)Description
TRUEevaluated 12656 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 1332052 times by 1 test
Evaluated by:
  • tst_qmlmin
)
12656-1332052
361 assembled += QLatin1Char(' ');
executed 12656 times by 1 test: assembled += QLatin1Char(' ');
Executed by:
  • tst_qmlmin
12656
362 }
executed 1344708 times by 1 test: end of block
Executed by:
  • tst_qmlmin
1344708
363 }
executed 1346108 times by 1 test: end of block
Executed by:
  • tst_qmlmin
1346108
364 assembled += yytokentext;-
365 }
executed 2148342 times by 1 test: end of block
Executed by:
  • tst_qmlmin
2148342
366 yytoken = -1;-
367 }
executed 4597750 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else if (yyaction < 0
yyaction < 0Description
TRUEevaluated 30423162 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 120428 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
120428-30423162
368 const int ruleno = -yyaction - 1;-
369 yytos -= rhs[ruleno];-
370-
371 handleLookaheads(ruleno);-
372-
373 if (isRegExpRule(ruleno)
isRegExpRule(ruleno)Description
TRUEevaluated 3732 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 30419430 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
3732-30419430
374 QString restOfRegExp;-
375-
376 if (! scanRestOfRegExp(ruleno, &restOfRegExp)
! scanRestOfRe...&restOfRegExp)Description
TRUEnever evaluated
FALSEevaluated 3732 times by 1 test
Evaluated by:
  • tst_qmlmin
)
0-3732
377 break;
never executed: break;
0
378-
379 assembled += restOfRegExp;-
380 }
executed 3732 times by 1 test: end of block
Executed by:
  • tst_qmlmin
3732
381 yyaction = nt_action(_stateStack[yytos], lhs[ruleno] - TERMINAL_COUNT);-
382 }
executed 30423162 times by 1 test: end of block
Executed by:
  • tst_qmlmin
30423162
383 }
executed 35141340 times by 1 test: end of block
Executed by:
  • tst_qmlmin
while (yyaction
yyactionDescription
TRUEevaluated 35020912 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 120428 times by 1 test
Evaluated by:
  • tst_qmlmin
);
120428-35141340
384-
385 const int yyerrorstate = _stateStack[yytos];-
386-
387-
388 if (yytoken != -1
yytoken != -1Description
TRUEevaluated 120428 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEnever evaluated
&& ((t_action(yyerrorstate, T_AUTOMATIC_SEMICOLON)
t_action(yyerr...TIC_SEMICOLON)Description
TRUEevaluated 120380 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 48 times by 1 test
Evaluated by:
  • tst_qmlmin
&& canInsertAutomaticSemicolon(yytoken)
canInsertAutom...colon(yytoken)Description
TRUEevaluated 120372 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlmin
)
0-120428
389 || t_action(yyerrorstate, T_COMPATIBILITY_SEMICOLON)
t_action(yyerr...ITY_SEMICOLON)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 54 times by 1 test
Evaluated by:
  • tst_qmlmin
)) {
2-54
390 _tokens.prepend(yytoken);-
391 _tokenStrings.prepend(yytokentext);-
392 yyaction = yyerrorstate;-
393 yytoken = T_SEMICOLON;-
394 goto
executed 120374 times by 1 test: goto again;
Executed by:
  • tst_qmlmin
again;
executed 120374 times by 1 test: goto again;
Executed by:
  • tst_qmlmin
120374
395 }-
396-
397 std::cerr << QtPrivate::asString(fileName()).toLocal8Bit().constData() << ':' << tokenStartLine() << ':' << tokenStartColumn()-
398 << ": syntax error" << std::endl;-
399 return
executed 54 times by 1 test: return false;
Executed by:
  • tst_qmlmin
false;
executed 54 times by 1 test: return false;
Executed by:
  • tst_qmlmin
54
400}-
401-
402-
403class Tokenize: public QmlminLexer-
404{-
405 QStringList _minifiedCode;-
406-
407public:-
408 Tokenize() {}-
409-
410 QStringList tokenStream() const;-
411-
412protected:-
413 bool parse(int startToken) override;-
414};-
415-
416QStringList Tokenize::tokenStream() const-
417{-
418 return
executed 19932 times by 1 test: return _minifiedCode;
Executed by:
  • tst_qmlmin
_minifiedCode;
executed 19932 times by 1 test: return _minifiedCode;
Executed by:
  • tst_qmlmin
19932
419}-
420-
421bool Tokenize::parse(int startToken)-
422{-
423 int yyaction = 0;-
424 int yytos = -1;-
425-
426 _minifiedCode.clear();-
427 _tokens.append(startToken);-
428 _tokenStrings.append(QString());-
429-
430 if (startToken == T_FEED_JS_SCRIPT
startToken == T_FEED_JS_SCRIPTDescription
TRUEevaluated 5288 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 14644 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
5288-14644
431-
432 DiagnosticMessage error;-
433 if (scanDirectives(this, &error)
scanDirectives(this, &error)Description
TRUEevaluated 5288 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEnever evaluated
) {
0-5288
434-
435-
436 _minifiedCode.append(directives());-
437-
438 _tokens.append(tokenKind());-
439 _tokenStrings.append(tokenText());-
440 }
executed 5288 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else {
5288
441 std::cerr << QtPrivate::asString(fileName()).toLocal8Bit().constData() << ':' << tokenStartLine() << ':'-
442 << tokenStartColumn() << ": syntax error" << std::endl;-
443 return
never executed: return false;
false;
never executed: return false;
0
444 }-
445 }-
446-
447 do {-
448 if (++
++yytos == _stateStack.size()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 35038844 times by 1 test
Evaluated by:
  • tst_qmlmin
yytos == _stateStack.size()
++yytos == _stateStack.size()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 35038844 times by 1 test
Evaluated by:
  • tst_qmlmin
)
8-35038844
449 _stateStack.resize(_stateStack.size() * 2);
executed 8 times by 1 test: _stateStack.resize(_stateStack.size() * 2);
Executed by:
  • tst_qmlmin
8
450-
451 _stateStack[yytos] = yyaction;-
452-
453 again:
code before this statement executed 35038852 times by 1 test: again:
Executed by:
  • tst_qmlmin
35038852
454 if (yytoken == -1
yytoken == -1Description
TRUEevaluated 13216968 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 21942220 times by 1 test
Evaluated by:
  • tst_qmlmin
&& action_index[yyaction] != -TERMINAL_COUNT
action_index[y...TERMINAL_COUNTDescription
TRUEevaluated 4191220 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 9025748 times by 1 test
Evaluated by:
  • tst_qmlmin
)
4191220-21942220
455 lex();
executed 4191220 times by 1 test: lex();
Executed by:
  • tst_qmlmin
4191220
456-
457 yyaction = t_action(yyaction, yytoken);-
458 if (yyaction > 0
yyaction > 0Description
TRUEevaluated 4617076 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 30542112 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
4617076-30542112
459 if (yyaction == ACCEPT_STATE
yyaction == ACCEPT_STATEDescription
TRUEevaluated 19932 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 4597144 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
19932-4597144
460 --yytos;-
461 return
executed 19932 times by 1 test: return true;
Executed by:
  • tst_qmlmin
true;
executed 19932 times by 1 test: return true;
Executed by:
  • tst_qmlmin
19932
462 }-
463-
464 if (yytoken == T_SEMICOLON
yytoken == T_SEMICOLONDescription
TRUEevaluated 533188 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 4063956 times by 1 test
Evaluated by:
  • tst_qmlmin
)
533188-4063956
465 _minifiedCode += QLatin1String(";");
executed 533188 times by 1 test: _minifiedCode += QLatin1String(";");
Executed by:
  • tst_qmlmin
533188
466 else-
467 _minifiedCode += yytokentext;
executed 4063956 times by 1 test: _minifiedCode += yytokentext;
Executed by:
  • tst_qmlmin
4063956
468-
469 yytoken = -1;-
470 }
executed 4597144 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else if (yyaction < 0
yyaction < 0Description
TRUEevaluated 30421776 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 120336 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
120336-30421776
471 const int ruleno = -yyaction - 1;-
472 yytos -= rhs[ruleno];-
473-
474 handleLookaheads(ruleno);-
475-
476 if (isRegExpRule(ruleno)
isRegExpRule(ruleno)Description
TRUEevaluated 3732 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 30418044 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
3732-30418044
477 QString restOfRegExp;-
478-
479 if (! scanRestOfRegExp(ruleno, &restOfRegExp)
! scanRestOfRe...&restOfRegExp)Description
TRUEnever evaluated
FALSEevaluated 3732 times by 1 test
Evaluated by:
  • tst_qmlmin
)
0-3732
480 break;
never executed: break;
0
481-
482 _minifiedCode.last().append(restOfRegExp);-
483 }
executed 3732 times by 1 test: end of block
Executed by:
  • tst_qmlmin
3732
484-
485 yyaction = nt_action(_stateStack[yytos], lhs[ruleno] - TERMINAL_COUNT);-
486 }
executed 30421776 times by 1 test: end of block
Executed by:
  • tst_qmlmin
30421776
487 }
executed 35139256 times by 1 test: end of block
Executed by:
  • tst_qmlmin
while (yyaction
yyactionDescription
TRUEevaluated 35018920 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 120336 times by 1 test
Evaluated by:
  • tst_qmlmin
);
120336-35139256
488-
489 const int yyerrorstate = _stateStack[yytos];-
490-
491-
492 if (yytoken != -1
yytoken != -1Description
TRUEevaluated 120336 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEnever evaluated
&& ((t_action(yyerrorstate, T_AUTOMATIC_SEMICOLON)
t_action(yyerr...TIC_SEMICOLON)Description
TRUEevaluated 120336 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEnever evaluated
&& canInsertAutomaticSemicolon(yytoken)
canInsertAutom...colon(yytoken)Description
TRUEevaluated 120334 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmlmin
)
0-120336
493 || t_action(yyerrorstate, T_COMPATIBILITY_SEMICOLON)
t_action(yyerr...ITY_SEMICOLON)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEnever evaluated
)) {
0-2
494 _tokens.prepend(yytoken);-
495 _tokenStrings.prepend(yytokentext);-
496 yyaction = yyerrorstate;-
497 yytoken = T_SEMICOLON;-
498 goto
executed 120336 times by 1 test: goto again;
Executed by:
  • tst_qmlmin
again;
executed 120336 times by 1 test: goto again;
Executed by:
  • tst_qmlmin
120336
499 }-
500-
501 std::cerr << QtPrivate::asString(fileName()).toLocal8Bit().constData() << ':' << tokenStartLine() << ':'-
502 << tokenStartColumn() << ": syntax error" << std::endl;-
503 return
never executed: return false;
false;
never executed: return false;
0
504}-
505-
506}-
507-
508static void usage(bool showHelp = false)-
509{-
510 std::cerr << "Usage: qmlmin [options] file" << std::endl;-
511-
512 if (showHelp
showHelpDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
513 std::cerr << " Removes comments and layout characters" << std::endl-
514 << " The options are:" << std::endl-
515 << " -o<file> write output to file rather than stdout" << std::endl-
516 << " -v --verify-only just run the verifier, no output" << std::endl-
517 << " -w<width> restrict line characters to width" << std::endl-
518 << " -h display this output" << std::endl;-
519 }
never executed: end of block
0
520}
never executed: end of block
0
521-
522int runQmlmin(int argc, char *argv[])-
523{-
524 QCoreApplication app(argc, argv);-
525 QCoreApplication::setApplicationVersion(QLatin1String("5.12.0"));-
526-
527 const QStringList args = app.arguments();-
528-
529 QString fileName;-
530 QString outputFile;-
531 bool verifyOnly = false;-
532-
533-
534 int width = -
535 (0x7fff * 2 + 1)-
536 ;-
537-
538 int index = 1;-
539 while (index < args.size()
index < args.size()Description
TRUEevaluated 30126 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
10042-30126
540 const QString arg = args.at(index++);-
541 const QString next = index < args.size()
index < args.size()Description
TRUEevaluated 20084 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
? args.at(index) : QString();
10042-20084
542-
543 if (arg == QLatin1String("-h")
arg == QLatin1String("-h")Description
TRUEnever evaluated
FALSEevaluated 30126 times by 1 test
Evaluated by:
  • tst_qmlmin
|| arg == QLatin1String("--help")
arg == QLatin1String("--help")Description
TRUEnever evaluated
FALSEevaluated 30126 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-30126
544 usage( true);-
545 return
never executed: return 0;
0;
never executed: return 0;
0
546 } else if (arg == QLatin1String("-v")
arg == QLatin1String("-v")Description
TRUEnever evaluated
FALSEevaluated 30126 times by 1 test
Evaluated by:
  • tst_qmlmin
|| arg == QLatin1String("--verify-only")
arg == QLatin1...-verify-only")Description
TRUEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 20084 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-30126
547 verifyOnly = true;-
548 }
executed 10042 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else if (arg == QLatin1String("-o")
arg == QLatin1String("-o")Description
TRUEnever evaluated
FALSEevaluated 20084 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-20084
549 if (next.isEmpty()
next.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
550 std::cerr << "qmlmin: argument to '-o' is missing" << std::endl;-
551 return
never executed: return 1 ;
never executed: return 1 ;
0
552 1
never executed: return 1 ;
0
553 ;
never executed: return 1 ;
0
554 } else {-
555 outputFile = next;-
556 ++index;-
557 }
never executed: end of block
0
558 } else if (arg.startsWith(QLatin1String("-o"))
arg.startsWith...1String("-o"))Description
TRUEnever evaluated
FALSEevaluated 20084 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-20084
559 outputFile = arg.mid(2);-
560-
561 if (outputFile.isEmpty()
outputFile.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
562 std::cerr << "qmlmin: argument to '-o' is missing" << std::endl;-
563 return
never executed: return 1 ;
never executed: return 1 ;
0
564 1
never executed: return 1 ;
0
565 ;
never executed: return 1 ;
0
566 }-
567 }
never executed: end of block
else if (arg == QLatin1String("-w")
arg == QLatin1String("-w")Description
TRUEnever evaluated
FALSEevaluated 20084 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-20084
568 if (next.isEmpty()
next.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
569 std::cerr << "qmlmin: argument to '-w' is missing" << std::endl;-
570 return
never executed: return 1 ;
never executed: return 1 ;
0
571 1
never executed: return 1 ;
0
572 ;
never executed: return 1 ;
0
573 } else {-
574 bool ok;-
575 width = next.toInt(&ok);-
576-
577 if (!ok
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
578 std::cerr << "qmlmin: argument to '-w' is invalid" << std::endl;-
579 return
never executed: return 1 ;
never executed: return 1 ;
0
580 1
never executed: return 1 ;
0
581 ;
never executed: return 1 ;
0
582 }-
583-
584 ++index;-
585 }
never executed: end of block
0
586 } else if (arg.startsWith(QLatin1String("-w"))
arg.startsWith...1String("-w"))Description
TRUEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
10042
587 bool ok;-
588 width = arg.midRef(2).toInt(&ok);-
589-
590 if (!ok
!okDescription
TRUEnever evaluated
FALSEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-10042
591 std::cerr << "qmlmin: argument to '-w' is invalid" << std::endl;-
592 return
never executed: return 1 ;
never executed: return 1 ;
0
593 1
never executed: return 1 ;
0
594 ;
never executed: return 1 ;
0
595 }-
596 }
executed 10042 times by 1 test: end of block
Executed by:
  • tst_qmlmin
else {
10042
597 const bool isInvalidOpt = arg.startsWith(QLatin1Char('-'));-
598 if (! isInvalidOpt
! isInvalidOptDescription
TRUEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEnever evaluated
&& fileName.isEmpty()
fileName.isEmpty()Description
TRUEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEnever evaluated
)
0-10042
599 fileName = arg;
executed 10042 times by 1 test: fileName = arg;
Executed by:
  • tst_qmlmin
10042
600 else {-
601 usage( isInvalidOpt);-
602 if (isInvalidOpt
isInvalidOptDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
603 std::cerr << "qmlmin: invalid option '" << QtPrivate::asString(arg).toLocal8Bit().constData() << '\'' << std::endl;
never executed: std::cerr << "qmlmin: invalid option '" << QtPrivate::asString(arg).toLocal8Bit().constData() << '\'' << std::endl;
0
604 else-
605 std::cerr << "qmlmin: too many input files specified" << std::endl;
never executed: std::cerr << "qmlmin: too many input files specified" << std::endl;
0
606 return
never executed: return 1 ;
never executed: return 1 ;
0
607 1
never executed: return 1 ;
0
608 ;
never executed: return 1 ;
0
609 }-
610 }-
611 }-
612-
613 if (fileName.isEmpty()
fileName.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-10042
614 usage();-
615 return
never executed: return 0;
0;
never executed: return 0;
0
616 }-
617-
618 QFile file(fileName);-
619 if (! file.open(QFile::ReadOnly)
! file.open(QFile::ReadOnly)Description
TRUEnever evaluated
FALSEevaluated 10042 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-10042
620 std::cerr << "qmlmin: '" << QtPrivate::asString(fileName).toLocal8Bit().constData() << "' no such file or directory" << std::endl;-
621 return
never executed: return 1 ;
never executed: return 1 ;
0
622 1
never executed: return 1 ;
0
623 ;
never executed: return 1 ;
0
624 }-
625-
626 const QString code = QString::fromUtf8(file.readAll());-
627 file.close();-
628-
629 QQmlJS::Minify minify(width);-
630 if (! minify(fileName, code)
! minify(fileName, code)Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • tst_qmlmin
FALSEevaluated 9966 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
76-9966
631 std::cerr << "qmlmin: cannot minify '" << QtPrivate::asString(fileName).toLocal8Bit().constData() << "' (not a valid QML/JS file)" << std::endl;-
632 return
executed 76 times by 1 test: return 1 ;
Executed by:
  • tst_qmlmin
executed 76 times by 1 test: return 1 ;
Executed by:
  • tst_qmlmin
76
633 1
executed 76 times by 1 test: return 1 ;
Executed by:
  • tst_qmlmin
76
634 ;
executed 76 times by 1 test: return 1 ;
Executed by:
  • tst_qmlmin
76
635 }-
636-
637-
638-
639-
640 QQmlJS::Minify secondMinify(width);-
641 if (! secondMinify(fileName, minify.minifiedCode())
! secondMinify...inifiedCode())Description
TRUEnever evaluated
FALSEevaluated 9966 times by 1 test
Evaluated by:
  • tst_qmlmin
|| secondMinify.minifiedCode() != minify.minifiedCode()
secondMinify.m...minifiedCode()Description
TRUEnever evaluated
FALSEevaluated 9966 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-9966
642 std::cerr << "qmlmin: cannot minify '" << QtPrivate::asString(fileName).toLocal8Bit().constData() << '\'' << std::endl;-
643 return
never executed: return 1 ;
never executed: return 1 ;
0
644 1
never executed: return 1 ;
0
645 ;
never executed: return 1 ;
0
646 }-
647-
648 QQmlJS::Tokenize originalTokens, minimizedTokens;-
649 originalTokens(fileName, code);-
650 minimizedTokens(fileName, minify.minifiedCode());-
651-
652 if (originalTokens.tokenStream().size() != minimizedTokens.tokenStream().size()
originalTokens...tream().size()Description
TRUEnever evaluated
FALSEevaluated 9966 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-9966
653 std::cerr << "qmlmin: cannot minify '" << QtPrivate::asString(fileName).toLocal8Bit().constData() << '\'' << std::endl;-
654 return
never executed: return 1 ;
never executed: return 1 ;
0
655 1
never executed: return 1 ;
0
656 ;
never executed: return 1 ;
0
657 }-
658-
659 if (! verifyOnly
! verifyOnlyDescription
TRUEnever evaluated
FALSEevaluated 9966 times by 1 test
Evaluated by:
  • tst_qmlmin
) {
0-9966
660 if (outputFile.isEmpty()
outputFile.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
661 const QByteArray chars = minify.minifiedCode().toUtf8();-
662 std::cout << chars.constData();-
663 }
never executed: end of block
else {
0
664 QFile file(outputFile);-
665 if (! file.open(QFile::WriteOnly)
! file.open(QFile::WriteOnly)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
666 std::cerr << "qmlmin: cannot minify '" << QtPrivate::asString(fileName).toLocal8Bit().constData() << "' (permission denied)" << std::endl;-
667 return
never executed: return 1 ;
never executed: return 1 ;
0
668 1
never executed: return 1 ;
0
669 ;
never executed: return 1 ;
0
670 }-
671-
672 file.write(minify.minifiedCode().toUtf8());-
673 file.close();-
674 }
never executed: end of block
0
675 }-
676-
677 return
executed 9966 times by 1 test: return 0;
Executed by:
  • tst_qmlmin
0;
executed 9966 times by 1 test: return 0;
Executed by:
  • tst_qmlmin
9966
678}-
679-
680-
681-
682int main(int argc, char **argv)-
683{-
684 return
executed 10042 times by 1 test: return ::runQmlmin(argc, argv);
Executed by:
  • tst_qmlmin
::runQmlmin(argc, argv);
executed 10042 times by 1 test: return ::runQmlmin(argc, argv);
Executed by:
  • tst_qmlmin
10042
685}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.0