aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/common
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2024-09-16 11:53:17 +0200
committerSami Shalayel <sami.shalayel@qt.io>2024-10-09 10:37:59 +0200
commitb14891e3d29e7c19717aaa77bb63aad94e358f4d (patch)
tree37fda484caed1cc328fc9a0b7f4cb8a23e969726 /src/qml/common
parent4baa3b7c5b5f6a2e89f701651e6240e2a17cc38b (diff)
SourceLocation: make begin() and end() qsizetype
Change begin() and end() to return a qsizetype, as now we only process QML files where quint32 can safely be casted to qsizetype. This allows to change all users of begin() and end() to use qsizetype, and to silence all MSVC compile warnings about comparison of ints with different signedness. Fixes: QTBUG-127833 Change-Id: I251435aa598386effe0259549dbe94d17b0d806b Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'src/qml/common')
-rw-r--r--src/qml/common/qqmljssourcelocation_p.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/qml/common/qqmljssourcelocation_p.h b/src/qml/common/qqmljssourcelocation_p.h
index 68e9471e35..bea953046b 100644
--- a/src/qml/common/qqmljssourcelocation_p.h
+++ b/src/qml/common/qqmljssourcelocation_p.h
@@ -66,8 +66,8 @@ public:
bool isValid() const { return *this != SourceLocation(); }
- quint32 begin() const { return offset; }
- quint32 end() const { return offset + length; }
+ qsizetype begin() const { return qsizetype(offset); }
+ qsizetype end() const { return qsizetype(offset) + length; }
// Returns a zero length location at the start of the current one.
SourceLocation startZeroLengthLocation() const
@@ -80,11 +80,12 @@ public:
quint32 i = offset;
quint32 endLine = startLine;
quint32 endColumn = startColumn;
- while (i < end()) {
+ const quint32 end = offset + length;
+ while (i < end) {
QChar c = text.at(i);
switch (c.unicode()) {
case '\n':
- if (i + 1 < end() && text.at(i + 1) == QLatin1Char('\r'))
+ if (i + 1 < end && text.at(i + 1) == QLatin1Char('\r'))
++i;
Q_FALLTHROUGH();
case '\r':
@@ -96,7 +97,7 @@ public:
}
++i;
}
- return SourceLocation(offset + length, 0, endLine, endColumn);
+ return SourceLocation(end, 0, endLine, endColumn);
}
// attributes