Btw. Just for your information.
I have attached a few random examples of what we can look forward too after
running an auto-"beautifying" tool over our hand-formated Qt code. And these
changes are NOT something we can configure out ouf of in clang-format, it is
just cases where it can't do any better.
Before:
// QStringRef <> QByteArray
inline QT_ASCII_CAST_WARN bool operator==(const QStringRef &lhs, const
QByteArray &rhs) { return lhs.compare(rhs) == 0; }
inline QT_ASCII_CAST_WARN bool operator!=(const QStringRef &lhs, const
QByteArray &rhs) { return lhs.compare(rhs) != 0; }
inline QT_ASCII_CAST_WARN bool operator< (const QStringRef &lhs, const
QByteArray &rhs) { return lhs.compare(rhs) < 0; }
inline QT_ASCII_CAST_WARN bool operator> (const QStringRef &lhs, const
QByteArray &rhs) { return lhs.compare(rhs) > 0; }
inline QT_ASCII_CAST_WARN bool operator<=(const QStringRef &lhs, const
QByteArray &rhs) { return lhs.compare(rhs) <= 0; }
inline QT_ASCII_CAST_WARN bool operator>=(const QStringRef &lhs, const
QByteArray &rhs) { return lhs.compare(rhs) >= 0; }
inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &lhs, const
QStringRef &rhs) { return rhs.compare(lhs) == 0; }
inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &lhs, const
QStringRef &rhs) { return rhs.compare(lhs) != 0; }
inline QT_ASCII_CAST_WARN bool operator< (const QByteArray &lhs, const
QStringRef &rhs) { return rhs.compare(lhs) > 0; }
inline QT_ASCII_CAST_WARN bool operator> (const QByteArray &lhs, const
QStringRef &rhs) { return rhs.compare(lhs) < 0; }
inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &lhs, const
QStringRef &rhs) { return rhs.compare(lhs) >= 0; }
inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &lhs, const
QStringRef &rhs) { return rhs.compare(lhs) <= 0; }
After:
// QStringRef <> QByteArray
inline QT_ASCII_CAST_WARN bool operator==(const QStringRef &lhs, const
QByteArray &rhs)
{
return lhs.compare(rhs) == 0;
}
inline QT_ASCII_CAST_WARN bool operator!=(const QStringRef &lhs, const
QByteArray &rhs)
{
return lhs.compare(rhs) != 0;
}
inline QT_ASCII_CAST_WARN bool operator<(const QStringRef &lhs, const
QByteArray &rhs) { return lhs.compare(rhs) < 0; }
inline QT_ASCII_CAST_WARN bool operator>(const QStringRef &lhs, const
QByteArray &rhs) { return lhs.compare(rhs) > 0; }
inline QT_ASCII_CAST_WARN bool operator<=(const QStringRef &lhs, const
QByteArray &rhs)
{
return lhs.compare(rhs) <= 0;
}
inline QT_ASCII_CAST_WARN bool operator>=(const QStringRef &lhs, const
QByteArray &rhs)
{
return lhs.compare(rhs) >= 0;
}
inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &lhs, const
QStringRef &rhs)
{
return rhs.compare(lhs) == 0;
}
inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &lhs, const
QStringRef &rhs)
{
return rhs.compare(lhs) != 0;
}
inline QT_ASCII_CAST_WARN bool operator<(const QByteArray &lhs, const
QStringRef &rhs) { return rhs.compare(lhs) > 0; }
inline QT_ASCII_CAST_WARN bool operator>(const QByteArray &lhs, const
QStringRef &rhs) { return rhs.compare(lhs) < 0; }
inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &lhs, const
QStringRef &rhs)
{
return rhs.compare(lhs) >= 0;
}
inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &lhs, const
QStringRef &rhs)
{
return rhs.compare(lhs) <= 0;
}
Before:
#define QT_MEMCPY_USHORT(dest, src, length) \
do { \
/* Duff's device */ \
ushort *_d = (ushort*)(dest); \
const ushort *_s = (const ushort*)(src); \
int n = ((length) + 7) / 8; \
switch ((length) & 0x07) \
{ \
case 0: do { *_d++ = *_s++; Q_FALLTHROUGH(); \
case 7: *_d++ = *_s++; Q_FALLTHROUGH(); \
case 6: *_d++ = *_s++; Q_FALLTHROUGH(); \
case 5: *_d++ = *_s++; Q_FALLTHROUGH(); \
case 4: *_d++ = *_s++; Q_FALLTHROUGH(); \
case 3: *_d++ = *_s++; Q_FALLTHROUGH(); \
case 2: *_d++ = *_s++; Q_FALLTHROUGH(); \
case 1: *_d++ = *_s++; \
} while (--n > 0); \
} \
} while (false)
inline ushort qConvertRgb32To16(uint c)
{
return (((c) >> 3) & 0x001f)
| (((c) >> 5) & 0x07e0)
| (((c) >> 8) & 0xf800);
}
inline QRgb qConvertRgb16To32(uint c)
{
return 0xff000000
| ((((c) << 3) & 0xf8) | (((c) >> 2) & 0x7))
| ((((c) << 5) & 0xfc00) | (((c) >> 1) & 0x300))
| ((((c) << 8) & 0xf80000) | (((c) << 3) & 0x70000));
}
After:
#define QT_MEMCPY_USHORT(dest, src, length)
\
do {
\
/* Duff's device */
\
ushort *_d = (ushort *)(dest);
\
const ushort *_s = (const ushort *)(src);
\
int n = ((length) + 7) / 8;
\
switch ((length)&0x07) {
\
case 0:
\
do {
\
*_d++ = *_s++;
\
Q_FALLTHROUGH();
\
case 7:
\
*_d++ = *_s++;
\
Q_FALLTHROUGH();
\
case 6:
\
*_d++ = *_s++;
\
Q_FALLTHROUGH();
\
case 5:
\
*_d++ = *_s++;
\
Q_FALLTHROUGH();
\
case 4:
\
*_d++ = *_s++;
\
Q_FALLTHROUGH();
\
case 3:
\
*_d++ = *_s++;
\
Q_FALLTHROUGH();
\
case 2:
\
*_d++ = *_s++;
\
Q_FALLTHROUGH();
\
case 1:
\
*_d++ = *_s++;
\
} while (--n > 0);
\
}
\
} while (false)
inline ushort qConvertRgb32To16(uint c)
{
return (((c) >> 3) & 0x001f) | (((c) >> 5) & 0x07e0) | (((c) >> 8) &
0xf800);
}
inline QRgb qConvertRgb16To32(uint c)
{
return 0xff000000 | ((((c) << 3) & 0xf8) | (((c) >> 2) & 0x7)) | ((((c) <<
5) & 0xfc00) | (((c) >> 1) & 0x300))
| ((((c) << 8) & 0xf80000) | (((c) << 3) & 0x70000));
}
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development