diff --git a/src/libs/qmljs/parser/gen-parser.sh b/src/libs/qmljs/parser/gen-parser.sh index e19de7ffb73..856759237d9 100755 --- a/src/libs/qmljs/parser/gen-parser.sh +++ b/src/libs/qmljs/parser/gen-parser.sh @@ -37,7 +37,14 @@ perl -p -0777 -i -e 's/#include \//' qmldirparser_p perl -p -0777 -i -e 's/QHashedStringRef/QString/g' qmldirparser_p.h qmldirparser.cpp # don't use the new QVarLengthArray::length() sed -i -e 's/chars.length()/chars.size()/' $me/qmljslexer.cpp +sed -i -e 's/DiagnosticMessage::Error/Severity::Error/g' $me/qmljsparser.cpp +sed -i -e 's/DiagnosticMessage::Warning/Severity::Warning/g' $me/qmljsparser.cpp +sed -i -e 's/DiagnosticMessage::Warning/Severity::Warning/g' $me/qmljsparser_p.h +sed -i -e 's|#include ||g' $me/qmlerror.cpp +sed -i -e 's|#include |#include |g' $me/qmljsengine_p.h +sed -i -e 's|#include |#include |g' $me/qmljsengine_p.h +perl -p -0777 -i -e 's/QT_QML_BEGIN_NAMESPACE/#include \nQT_QML_BEGIN_NAMESPACE/' qmljsengine_p.h ./changeLicense.py $me/../qmljs_global.h qml*.{cpp,h} -patch -p5 < parser.patch +#patch -R -p5 < parser.patch diff --git a/src/libs/qmljs/parser/parser.patch b/src/libs/qmljs/parser/parser.patch index 4c56a5e2d59..c1bef1860c3 100644 --- a/src/libs/qmljs/parser/parser.patch +++ b/src/libs/qmljs/parser/parser.patch @@ -1,5 +1,22 @@ +diff --git a/src/libs/qmljs/parser/qmlerror.cpp b/src/libs/qmljs/parser/qmlerror.cpp +index d090a19..5ec311d 100644 +--- a/src/libs/qmljs/parser/qmlerror.cpp ++++ b/src/libs/qmljs/parser/qmlerror.cpp +@@ -65,6 +65,12 @@ QT_BEGIN_NAMESPACE + + \sa QQuickView::errors(), QmlComponent::errors() + */ ++ ++static quint16 qmlSourceCoordinate(int n) ++{ ++ return (n > 0 && n <= static_cast(USHRT_MAX)) ? static_cast(n) : 0; ++} ++ + class QmlErrorPrivate + { + public: diff --git a/src/libs/qmljs/parser/qmljsengine_p.cpp b/src/libs/qmljs/parser/qmljsengine_p.cpp -index 73850bb..d7d2189 100644 +index 1e22fa5..10fc3d1 100644 --- a/src/libs/qmljs/parser/qmljsengine_p.cpp +++ b/src/libs/qmljs/parser/qmljsengine_p.cpp @@ -110,7 +110,7 @@ double integerFromString(const QString &str, int radix) @@ -25,10 +42,21 @@ index 73850bb..d7d2189 100644 { return &_pool; } diff --git a/src/libs/qmljs/parser/qmljsengine_p.h b/src/libs/qmljs/parser/qmljsengine_p.h -index d4ed4b37..4908e02 100644 +index b1f7e1a..29b69d1 100644 --- a/src/libs/qmljs/parser/qmljsengine_p.h +++ b/src/libs/qmljs/parser/qmljsengine_p.h -@@ -53,6 +53,7 @@ QT_QML_BEGIN_NAMESPACE +@@ -44,36 +44,35 @@ + #include "qmljsglobal_p.h" + #include "qmljsastfwd_p.h" + #include "qmljsmemorypool_p.h" ++#include + + #include + #include + +-#include + QT_QML_BEGIN_NAMESPACE + namespace QmlJS { class Lexer; @@ -36,7 +64,32 @@ index d4ed4b37..4908e02 100644 class MemoryPool; class QML_PARSER_EXPORT DiagnosticMessage -@@ -80,6 +81,7 @@ public: + { + public: +- enum Kind { Warning, Error }; +- + DiagnosticMessage() +- : kind(Error) {} ++ : kind(Severity::Error) {} + +- DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message) ++ DiagnosticMessage(Severity::Enum kind, const AST::SourceLocation &loc, const QString &message) + : kind(kind), loc(loc), message(message) {} + + bool isWarning() const +- { return kind == Warning; } ++ { return kind == Severity::Warning; } + + bool isError() const +- { return kind == Error; } ++ { return kind == Severity::Error; } + +- Kind kind; ++ Severity::Enum kind; + AST::SourceLocation loc; + QString message; + }; +@@ -81,6 +80,7 @@ public: class QML_PARSER_EXPORT Engine { Lexer *_lexer; @@ -44,7 +97,7 @@ index d4ed4b37..4908e02 100644 MemoryPool _pool; QList _comments; QString _extraCode; -@@ -97,6 +99,9 @@ public: +@@ -99,6 +99,9 @@ public: Lexer *lexer() const; void setLexer(Lexer *lexer); @@ -54,11 +107,33 @@ index d4ed4b37..4908e02 100644 MemoryPool *pool(); inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); } +diff --git a/src/libs/qmljs/parser/qmljslexer.cpp b/src/libs/qmljs/parser/qmljslexer.cpp +index 9698e9d..036be75 100644 +--- a/src/libs/qmljs/parser/qmljslexer.cpp ++++ b/src/libs/qmljs/parser/qmljslexer.cpp +@@ -345,7 +345,7 @@ static inline bool isIdentifierStart(QChar ch) + // fast path for ascii + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || + (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || +- ch == '$' || ch == '_') ++ ch == QLatin1Char('$') || ch == QLatin1Char('_')) + return true; + + switch (ch.category()) { +@@ -368,7 +368,7 @@ static bool isIdentifierPart(QChar ch) + if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || + (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || + (ch.unicode() >= '0' && ch.unicode() <= '9') || +- ch == '$' || ch == '_' || ++ ch == QLatin1Char('$') || ch == QLatin1Char('_') || + ch.unicode() == 0x200c /* ZWNJ */ || ch.unicode() == 0x200d /* ZWJ */) + return true; + diff --git a/src/libs/qmljs/parser/qmljsparser.cpp b/src/libs/qmljs/parser/qmljsparser.cpp -index d53960b..71e994f 100644 +index 6e61637..e016b91 100644 --- a/src/libs/qmljs/parser/qmljsparser.cpp +++ b/src/libs/qmljs/parser/qmljsparser.cpp -@@ -143,7 +143,20 @@ bool Parser::parse(int startToken) +@@ -157,7 +157,20 @@ bool Parser::parse(int startToken) token_buffer[0].token = startToken; first_token = &token_buffer[0]; @@ -80,244 +155,3 @@ index d53960b..71e994f 100644 tos = -1; program = 0; -diff --git a/src/libs/qmljs/parser/qmlerror.cpp b/src/libs/qmljs/parser/qmlerror.cpp -index a244235..e334ae9 100644 ---- a/src/libs/qmljs/parser/qmlerror.cpp -+++ b/src/libs/qmljs/parser/qmlerror.cpp -@@ -63,6 +63,12 @@ QT_BEGIN_NAMESPACE - - \sa QQuickView::errors(), QmlComponent::errors() - */ -+ -+static quint16 qmlSourceCoordinate(int n) -+{ -+ return (n > 0 && n <= static_cast(USHRT_MAX)) ? static_cast(n) : 0; -+} -+ - class QmlErrorPrivate - { - public: -diff --git a/src/libs/qmljs/parser/qmljskeywords_p.h b/src/libs/qmljs/parser/qmljskeywords_p.h -index 3c827da..e981040 100644 ---- a/src/libs/qmljs/parser/qmljskeywords_p.h -+++ b/src/libs/qmljs/parser/qmljskeywords_p.h -@@ -41,6 +41,12 @@ - // We mean it. - // - -+// Note on the int() casts in the following code: -+// they casts values from Lexer's anonymous enum (aliasing some of the inherited -+// QmlJSGrammar::VariousConstants) to int when used with inherited values of the -+// enum QmlJSGrammar::VariousConstants in a ?: expression to suppress gcc -+// "enumeral mismatch" warning -+ - static inline int classify2(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'a') { - if (s[1].unicode() == 's') { -@@ -79,7 +85,7 @@ static inline int classify3(const QChar *s, bool qmlMode) { - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'n') { - if (s[2].unicode() == 't') { -- return qmlMode ? Lexer::T_INT : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_INT) : Lexer::T_IDENTIFIER; - } - } - } -@@ -112,7 +118,7 @@ static inline int classify4(const QChar *s, bool qmlMode) { - if (s[1].unicode() == 'y') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { -- return qmlMode ? Lexer::T_BYTE : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_BYTE) : Lexer::T_IDENTIFIER; - } - } - } -@@ -128,7 +134,7 @@ static inline int classify4(const QChar *s, bool qmlMode) { - else if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'r') { -- return qmlMode ? Lexer::T_CHAR : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_CHAR) : Lexer::T_IDENTIFIER; - } - } - } -@@ -153,7 +159,7 @@ static inline int classify4(const QChar *s, bool qmlMode) { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'o') { -- return qmlMode ? Lexer::T_GOTO : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_GOTO) : Lexer::T_IDENTIFIER; - } - } - } -@@ -162,7 +168,7 @@ static inline int classify4(const QChar *s, bool qmlMode) { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'g') { -- return qmlMode ? Lexer::T_LONG : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_LONG) : Lexer::T_IDENTIFIER; - } - } - } -@@ -268,7 +274,7 @@ static inline int classify5(const QChar *s, bool qmlMode) { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'l') { -- return qmlMode ? Lexer::T_FINAL : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_FINAL) : Lexer::T_IDENTIFIER; - } - } - } -@@ -277,7 +283,7 @@ static inline int classify5(const QChar *s, bool qmlMode) { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 't') { -- return qmlMode ? Lexer::T_FLOAT : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_FLOAT) : Lexer::T_IDENTIFIER; - } - } - } -@@ -288,7 +294,7 @@ static inline int classify5(const QChar *s, bool qmlMode) { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'r') { - if (s[4].unicode() == 't') { -- return qmlMode ? Lexer::T_SHORT : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_SHORT) : Lexer::T_IDENTIFIER; - } - } - } -@@ -297,7 +303,7 @@ static inline int classify5(const QChar *s, bool qmlMode) { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'r') { -- return qmlMode ? Lexer::T_SUPER : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_SUPER) : Lexer::T_IDENTIFIER; - } - } - } -@@ -346,7 +352,7 @@ static inline int classify6(const QChar *s, bool qmlMode) { - if (s[3].unicode() == 'b') { - if (s[4].unicode() == 'l') { - if (s[5].unicode() == 'e') { -- return qmlMode ? Lexer::T_DOUBLE : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_DOUBLE) : Lexer::T_IDENTIFIER; - } - } - } -@@ -385,7 +391,7 @@ static inline int classify6(const QChar *s, bool qmlMode) { - if (s[3].unicode() == 'i') { - if (s[4].unicode() == 'v') { - if (s[5].unicode() == 'e') { -- return qmlMode ? Lexer::T_NATIVE : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_NATIVE) : Lexer::T_IDENTIFIER; - } - } - } -@@ -435,7 +441,7 @@ static inline int classify6(const QChar *s, bool qmlMode) { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'c') { -- return qmlMode ? Lexer::T_STATIC : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_STATIC) : Lexer::T_IDENTIFIER; - } - } - } -@@ -459,7 +465,7 @@ static inline int classify6(const QChar *s, bool qmlMode) { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'w') { - if (s[5].unicode() == 's') { -- return qmlMode ? Lexer::T_THROWS : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_THROWS) : Lexer::T_IDENTIFIER; - } - } - } -@@ -488,7 +494,7 @@ static inline int classify7(const QChar *s, bool qmlMode) { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'a') { - if (s[6].unicode() == 'n') { -- return qmlMode ? Lexer::T_BOOLEAN : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_BOOLEAN) : Lexer::T_IDENTIFIER; - } - } - } -@@ -548,7 +554,7 @@ static inline int classify7(const QChar *s, bool qmlMode) { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'g') { - if (s[6].unicode() == 'e') { -- return qmlMode ? Lexer::T_PACKAGE : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_PACKAGE) : Lexer::T_IDENTIFIER; - } - } - } -@@ -561,7 +567,7 @@ static inline int classify7(const QChar *s, bool qmlMode) { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 't') { - if (s[6].unicode() == 'e') { -- return qmlMode ? Lexer::T_PRIVATE : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_PRIVATE) : Lexer::T_IDENTIFIER; - } - } - } -@@ -581,7 +587,7 @@ static inline int classify8(const QChar *s, bool qmlMode) { - if (s[5].unicode() == 'a') { - if (s[6].unicode() == 'c') { - if (s[7].unicode() == 't') { -- return qmlMode ? Lexer::T_ABSTRACT : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_ABSTRACT) : Lexer::T_IDENTIFIER; - } - } - } -@@ -683,7 +689,7 @@ static inline int classify8(const QChar *s, bool qmlMode) { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'l') { - if (s[7].unicode() == 'e') { -- return qmlMode ? Lexer::T_VOLATILE : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_VOLATILE) : Lexer::T_IDENTIFIER; - } - } - } -@@ -705,7 +711,7 @@ static inline int classify9(const QChar *s, bool qmlMode) { - if (s[6].unicode() == 'a') { - if (s[7].unicode() == 'c') { - if (s[8].unicode() == 'e') { -- return qmlMode ? Lexer::T_INTERFACE : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_INTERFACE) : Lexer::T_IDENTIFIER; - } - } - } -@@ -724,7 +730,7 @@ static inline int classify9(const QChar *s, bool qmlMode) { - if (s[6].unicode() == 't') { - if (s[7].unicode() == 'e') { - if (s[8].unicode() == 'd') { -- return qmlMode ? Lexer::T_PROTECTED : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_PROTECTED) : Lexer::T_IDENTIFIER; - } - } - } -@@ -743,7 +749,7 @@ static inline int classify9(const QChar *s, bool qmlMode) { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 't') { -- return qmlMode ? Lexer::T_TRANSIENT : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_TRANSIENT) : Lexer::T_IDENTIFIER; - } - } - } -@@ -767,7 +773,7 @@ static inline int classify10(const QChar *s, bool qmlMode) { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 't') { - if (s[9].unicode() == 's') { -- return qmlMode ? Lexer::T_IMPLEMENTS : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_IMPLEMENTS) : Lexer::T_IDENTIFIER; - } - } - } -@@ -813,7 +819,7 @@ static inline int classify12(const QChar *s, bool qmlMode) { - if (s[9].unicode() == 'z') { - if (s[10].unicode() == 'e') { - if (s[11].unicode() == 'd') { -- return qmlMode ? Lexer::T_SYNCHRONIZED : Lexer::T_IDENTIFIER; -+ return qmlMode ? int(Lexer::T_SYNCHRONIZED) : Lexer::T_IDENTIFIER; - } - } - } diff --git a/src/libs/qmljs/parser/qmldirparser.cpp b/src/libs/qmljs/parser/qmldirparser.cpp index 1e152a101c1..7355800b3fb 100644 --- a/src/libs/qmljs/parser/qmldirparser.cpp +++ b/src/libs/qmljs/parser/qmldirparser.cpp @@ -130,7 +130,7 @@ bool QmlDirParser::parse(const QString &source) if (invalidLine) { reportError(lineNumber, 0, - QString::fromUtf8("invalid qmldir directive contains too many tokens")); + QString::fromLatin1("invalid qmldir directive contains too many tokens")); continue; } else if (sectionCount == 0) { continue; // no sections, no party. @@ -138,17 +138,17 @@ bool QmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("module")) { if (sectionCount != 2) { reportError(lineNumber, 0, - QString::fromUtf8("module identifier directive requires one argument, but %1 were provided").arg(sectionCount - 1)); + QString::fromLatin1("module identifier directive requires one argument, but %1 were provided").arg(sectionCount - 1)); continue; } if (!_typeNamespace.isEmpty()) { reportError(lineNumber, 0, - QString::fromUtf8("only one module identifier directive may be defined in a qmldir file")); + QString::fromLatin1("only one module identifier directive may be defined in a qmldir file")); continue; } if (!firstLine) { reportError(lineNumber, 0, - QString::fromUtf8("module identifier directive must be the first directive in a qmldir file")); + QString::fromLatin1("module identifier directive must be the first directive in a qmldir file")); continue; } @@ -157,7 +157,7 @@ bool QmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("plugin")) { if (sectionCount < 2 || sectionCount > 3) { reportError(lineNumber, 0, - QString::fromUtf8("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1)); + QString::fromLatin1("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1)); continue; } @@ -169,7 +169,7 @@ bool QmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("internal")) { if (sectionCount != 3) { reportError(lineNumber, 0, - QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1)); + QString::fromLatin1("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1)); continue; } Component entry(sections[1], sections[2], -1, -1); @@ -178,7 +178,7 @@ bool QmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("singleton")) { if (sectionCount < 3 || sectionCount > 4) { reportError(lineNumber, 0, - QString::fromUtf8("singleton types require 2 or 3 arguments, but %1 were provided").arg(sectionCount - 1)); + QString::fromLatin1("singleton types require 2 or 3 arguments, but %1 were provided").arg(sectionCount - 1)); continue; } else if (sectionCount == 3) { // handle qmldir directory listing case where singleton is defined in the following pattern: @@ -215,7 +215,7 @@ bool QmlDirParser::parse(const QString &source) } else if (sections[0] == QLatin1String("typeinfo")) { if (sectionCount != 2) { reportError(lineNumber, 0, - QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1)); + QString::fromLatin1("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1)); continue; } #ifdef QT_CREATOR @@ -258,7 +258,7 @@ bool QmlDirParser::parse(const QString &source) } } else { reportError(lineNumber, 0, - QString::fromUtf8("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount)); + QString::fromLatin1("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount)); } firstLine = false; diff --git a/src/libs/qmljs/parser/qmlerror.cpp b/src/libs/qmljs/parser/qmlerror.cpp index 2f152bdbbd1..5ec311dde60 100644 --- a/src/libs/qmljs/parser/qmlerror.cpp +++ b/src/libs/qmljs/parser/qmlerror.cpp @@ -34,6 +34,8 @@ #include #include + + QT_BEGIN_NAMESPACE /*! diff --git a/src/libs/qmljs/parser/qmljskeywords_p.h b/src/libs/qmljs/parser/qmljskeywords_p.h index b2a54e104ee..8b014451a93 100644 --- a/src/libs/qmljs/parser/qmljskeywords_p.h +++ b/src/libs/qmljs/parser/qmljskeywords_p.h @@ -47,12 +47,6 @@ QT_QML_BEGIN_NAMESPACE namespace QmlJS { -// Note on the int() casts in the following code: -// they casts values from Lexer's anonymous enum (aliasing some of the inherited -// QmlJSGrammar::VariousConstants) to int when used with inherited values of the -// enum QmlJSGrammar::VariousConstants in a ?: expression to suppress gcc -// "enumeral mismatch" warning - static inline int classify2(const QChar *s, bool qmlMode) { if (s[0].unicode() == 'a') { if (s[1].unicode() == 's') {