summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-08 15:08:22 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-01-10 08:43:15 +0100
commit390b16aea85e64bc33ce91e37898f59ad8a994c7 (patch)
tree0cefc9dd8f47cfca2af11e0337c26d22fc7af063 /src/corelib/tools
parent2c2801860dde4d707af9ce291489bee1750955d1 (diff)
QtCore: mark some operations nothrow
This shotgun-surgery approach is motivated by trying to get a clean(er) build for -Wnoexcept on GCC, so it is expected that for any class touched here, there will be more operations that can be marked nothrow. But they don't show up in conditional noexcept clauses, yet, so they are deferred to some later commit. Change-Id: I0eb10d75a26c361fb22cf785399e83b434bdf233 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qarraydata.h4
-rw-r--r--src/corelib/tools/qbitarray.h6
-rw-r--r--src/corelib/tools/qbytearray.h7
-rw-r--r--src/corelib/tools/qcache.h4
-rw-r--r--src/corelib/tools/qcollator.h10
-rw-r--r--src/corelib/tools/qhash.h8
-rw-r--r--src/corelib/tools/qlist.h2
-rw-r--r--src/corelib/tools/qregularexpression.h12
-rw-r--r--src/corelib/tools/qshareddata.h26
-rw-r--r--src/corelib/tools/qstring.h10
-rw-r--r--src/corelib/tools/qstringlist.h6
-rw-r--r--src/corelib/tools/qtimezone.h4
-rw-r--r--src/corelib/tools/qvector.h2
13 files changed, 52 insertions, 49 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index 2119b3d4ac..df44503a8e 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -113,7 +113,7 @@ struct Q_CORE_EXPORT QArrayData
size_t alignment) Q_DECL_NOTHROW;
static const QArrayData shared_null[2];
- static QArrayData *sharedNull() { return const_cast<QArrayData*>(shared_null); }
+ static QArrayData *sharedNull() Q_DECL_NOTHROW { return const_cast<QArrayData*>(shared_null); }
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QArrayData::AllocationOptions)
@@ -237,7 +237,7 @@ struct QTypedArrayData
return result;
}
- static QTypedArrayData *sharedNull()
+ static QTypedArrayData *sharedNull() Q_DECL_NOTHROW
{
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
return static_cast<QTypedArrayData *>(QArrayData::sharedNull());
diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h
index 768dfa912d..8d550554ff 100644
--- a/src/corelib/tools/qbitarray.h
+++ b/src/corelib/tools/qbitarray.h
@@ -53,12 +53,12 @@ public:
QBitArray(const QBitArray &other) : d(other.d) {}
inline QBitArray &operator=(const QBitArray &other) { d = other.d; return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
- inline QBitArray(QBitArray &&other) : d(std::move(other.d)) {}
- inline QBitArray &operator=(QBitArray &&other)
+ inline QBitArray(QBitArray &&other) Q_DECL_NOTHROW : d(std::move(other.d)) {}
+ inline QBitArray &operator=(QBitArray &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QBitArray &other) { qSwap(d, other.d); }
+ inline void swap(QBitArray &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
inline int size() const { return (d.size() << 3) - *d.constData(); }
inline int count() const { return (d.size() << 3) - *d.constData(); }
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 6286624961..a549585400 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -195,12 +195,13 @@ public:
QByteArray &operator=(const QByteArray &);
QByteArray &operator=(const char *str);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QByteArray(QByteArray && other) : d(other.d) { other.d = Data::sharedNull(); }
- inline QByteArray &operator=(QByteArray &&other)
+ inline QByteArray(QByteArray && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); }
+ inline QByteArray &operator=(QByteArray &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QByteArray &other) { qSwap(d, other.d); }
+ inline void swap(QByteArray &other) Q_DECL_NOTHROW
+ { qSwap(d, other.d); }
inline int size() const;
bool isEmpty() const;
diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h
index 960e0422a1..80fdb8c9cd 100644
--- a/src/corelib/tools/qcache.h
+++ b/src/corelib/tools/qcache.h
@@ -83,7 +83,7 @@ class QCache
Q_DISABLE_COPY(QCache)
public:
- inline explicit QCache(int maxCost = 100);
+ inline explicit QCache(int maxCost = 100) Q_DECL_NOTHROW;
inline ~QCache() { clear(); }
inline int maxCost() const { return mx; }
@@ -110,7 +110,7 @@ private:
};
template <class Key, class T>
-inline QCache<Key, T>::QCache(int amaxCost)
+inline QCache<Key, T>::QCache(int amaxCost) Q_DECL_NOTHROW
: f(0), l(0), mx(amaxCost), total(0) {}
template <class Key, class T>
diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h
index f9ae44cf6b..98f06bcc1f 100644
--- a/src/corelib/tools/qcollator.h
+++ b/src/corelib/tools/qcollator.h
@@ -52,10 +52,10 @@ public:
~QCollatorSortKey();
QCollatorSortKey &operator=(const QCollatorSortKey &other);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QCollatorSortKey &operator=(QCollatorSortKey &&other)
+ inline QCollatorSortKey &operator=(QCollatorSortKey &&other) Q_DECL_NOTHROW
{ swap(other); return *this; }
#endif
- void swap(QCollatorSortKey &other)
+ void swap(QCollatorSortKey &other) Q_DECL_NOTHROW
{ d.swap(other.d); }
int compare(const QCollatorSortKey &key) const;
@@ -82,13 +82,13 @@ public:
~QCollator();
QCollator &operator=(const QCollator &);
#ifdef Q_COMPILER_RVALUE_REFS
- QCollator(QCollator &&other)
+ QCollator(QCollator &&other) Q_DECL_NOTHROW
: d(other.d) { other.d = 0; }
- QCollator &operator=(QCollator &&other)
+ QCollator &operator=(QCollator &&other) Q_DECL_NOTHROW
{ swap(other); return *this; }
#endif
- void swap(QCollator &other)
+ void swap(QCollator &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
void setLocale(const QLocale &locale);
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 2a2c840c23..13006095e6 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -328,7 +328,7 @@ class QHash
static inline int alignOfNode() { return qMax<int>(sizeof(void*), Q_ALIGNOF(Node)); }
public:
- inline QHash() : d(const_cast<QHashData *>(&QHashData::shared_null)) { }
+ inline QHash() Q_DECL_NOTHROW : d(const_cast<QHashData *>(&QHashData::shared_null)) { }
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QHash(std::initializer_list<std::pair<Key,T> > list)
: d(const_cast<QHashData *>(&QHashData::shared_null))
@@ -343,11 +343,11 @@ public:
QHash<Key, T> &operator=(const QHash<Key, T> &other);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QHash(QHash<Key, T> &&other) : d(other.d) { other.d = const_cast<QHashData *>(&QHashData::shared_null); }
- inline QHash<Key, T> &operator=(QHash<Key, T> &&other)
+ inline QHash(QHash<Key, T> &&other) Q_DECL_NOTHROW : d(other.d) { other.d = const_cast<QHashData *>(&QHashData::shared_null); }
+ inline QHash<Key, T> &operator=(QHash<Key, T> &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QHash<Key, T> &other) { qSwap(d, other.d); }
+ inline void swap(QHash<Key, T> &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
bool operator==(const QHash<Key, T> &other) const;
inline bool operator!=(const QHash<Key, T> &other) const { return !(*this == other); }
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 321c3e6765..2031c32069 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -112,7 +112,7 @@ class QList : public QListSpecialMethods<T>
union { QListData p; QListData::Data *d; };
public:
- inline QList() : d(const_cast<QListData::Data *>(&QListData::shared_null)) { }
+ inline QList() Q_DECL_NOTHROW : d(const_cast<QListData::Data *>(&QListData::shared_null)) { }
QList(const QList<T> &l);
~QList();
QList<T> &operator=(const QList<T> &l);
diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h
index f332227094..8e19a53142 100644
--- a/src/corelib/tools/qregularexpression.h
+++ b/src/corelib/tools/qregularexpression.h
@@ -77,11 +77,11 @@ public:
QRegularExpression &operator=(const QRegularExpression &re);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QRegularExpression &operator=(QRegularExpression &&re)
+ QRegularExpression &operator=(QRegularExpression &&re) Q_DECL_NOTHROW
{ d.swap(re.d); return *this; }
#endif
- inline void swap(QRegularExpression &re) { d.swap(re.d); }
+ void swap(QRegularExpression &other) Q_DECL_NOTHROW { d.swap(other.d); }
QString pattern() const;
void setPattern(const QString &pattern);
@@ -169,10 +169,10 @@ public:
QRegularExpressionMatch &operator=(const QRegularExpressionMatch &match);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QRegularExpressionMatch &operator=(QRegularExpressionMatch &&match)
+ QRegularExpressionMatch &operator=(QRegularExpressionMatch &&match) Q_DECL_NOTHROW
{ d.swap(match.d); return *this; }
#endif
- inline void swap(QRegularExpressionMatch &match) { d.swap(match.d); }
+ void swap(QRegularExpressionMatch &other) Q_DECL_NOTHROW { d.swap(other.d); }
QRegularExpression regularExpression() const;
QRegularExpression::MatchType matchType() const;
@@ -226,10 +226,10 @@ public:
QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator &iterator);
QRegularExpressionMatchIterator &operator=(const QRegularExpressionMatchIterator &iterator);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QRegularExpressionMatchIterator &operator=(QRegularExpressionMatchIterator &&iterator)
+ QRegularExpressionMatchIterator &operator=(QRegularExpressionMatchIterator &&iterator) Q_DECL_NOTHROW
{ d.swap(iterator.d); return *this; }
#endif
- void swap(QRegularExpressionMatchIterator &iterator) { d.swap(iterator.d); }
+ void swap(QRegularExpressionMatchIterator &other) Q_DECL_NOTHROW { d.swap(other.d); }
bool isValid() const;
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index 53f51b7f2e..183b9ff238 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -79,7 +79,7 @@ public:
inline QSharedDataPointer() { d = 0; }
inline ~QSharedDataPointer() { if (d && !d->ref.deref()) delete d; }
- explicit QSharedDataPointer(T *data);
+ explicit QSharedDataPointer(T *data) Q_DECL_NOTHROW;
inline QSharedDataPointer(const QSharedDataPointer<T> &o) : d(o.d) { if (d) d->ref.ref(); }
inline QSharedDataPointer<T> & operator=(const QSharedDataPointer<T> &o) {
if (o.d != d) {
@@ -104,14 +104,14 @@ public:
return *this;
}
#ifdef Q_COMPILER_RVALUE_REFS
- QSharedDataPointer(QSharedDataPointer &&o) : d(o.d) { o.d = 0; }
- inline QSharedDataPointer<T> &operator=(QSharedDataPointer<T> &&other)
+ QSharedDataPointer(QSharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = Q_NULLPTR; }
+ inline QSharedDataPointer<T> &operator=(QSharedDataPointer<T> &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
inline bool operator!() const { return !d; }
- inline void swap(QSharedDataPointer &other)
+ inline void swap(QSharedDataPointer &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
protected:
@@ -155,7 +155,7 @@ public:
inline QExplicitlySharedDataPointer() { d = 0; }
inline ~QExplicitlySharedDataPointer() { if (d && !d->ref.deref()) delete d; }
- explicit QExplicitlySharedDataPointer(T *data);
+ explicit QExplicitlySharedDataPointer(T *data) Q_DECL_NOTHROW;
inline QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer<T> &o) : d(o.d) { if (d) d->ref.ref(); }
template<class X>
@@ -193,14 +193,14 @@ public:
return *this;
}
#ifdef Q_COMPILER_RVALUE_REFS
- inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) : d(o.d) { o.d = 0; }
- inline QExplicitlySharedDataPointer<T> &operator=(QExplicitlySharedDataPointer<T> &&other)
+ inline QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) Q_DECL_NOTHROW : d(o.d) { o.d = Q_NULLPTR; }
+ inline QExplicitlySharedDataPointer<T> &operator=(QExplicitlySharedDataPointer<T> &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
inline bool operator!() const { return !d; }
- inline void swap(QExplicitlySharedDataPointer &other)
+ inline void swap(QExplicitlySharedDataPointer &other) Q_DECL_NOTHROW
{ qSwap(d, other.d); }
protected:
@@ -213,7 +213,8 @@ private:
};
template <class T>
-Q_INLINE_TEMPLATE QSharedDataPointer<T>::QSharedDataPointer(T *adata) : d(adata)
+Q_INLINE_TEMPLATE QSharedDataPointer<T>::QSharedDataPointer(T *adata) Q_DECL_NOTHROW
+ : d(adata)
{ if (d) d->ref.ref(); }
template <class T>
@@ -249,7 +250,8 @@ Q_OUTOFLINE_TEMPLATE void QExplicitlySharedDataPointer<T>::detach_helper()
}
template <class T>
-Q_INLINE_TEMPLATE QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer(T *adata) : d(adata)
+Q_INLINE_TEMPLATE QExplicitlySharedDataPointer<T>::QExplicitlySharedDataPointer(T *adata) Q_DECL_NOTHROW
+ : d(adata)
{ if (d) d->ref.ref(); }
template <class T>
@@ -273,12 +275,12 @@ namespace std {
QT_BEGIN_NAMESPACE
template <class T>
-Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer<T> &ptr, uint seed = 0)
+Q_INLINE_TEMPLATE uint qHash(const QSharedDataPointer<T> &ptr, uint seed = 0) Q_DECL_NOTHROW
{
return qHash(ptr.data(), seed);
}
template <class T>
-Q_INLINE_TEMPLATE uint qHash(const QExplicitlySharedDataPointer<T> &ptr, uint seed = 0)
+Q_INLINE_TEMPLATE uint qHash(const QExplicitlySharedDataPointer<T> &ptr, uint seed = 0) Q_DECL_NOTHROW
{
return qHash(ptr.data(), seed);
}
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 4d51521b12..71d10f0663 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -210,7 +210,7 @@ class Q_CORE_EXPORT QString
public:
typedef QStringData Data;
- inline QString();
+ inline QString() Q_DECL_NOTHROW;
explicit QString(const QChar *unicode, int size = -1);
QString(QChar c);
QString(int size, QChar c);
@@ -221,11 +221,11 @@ public:
QString &operator=(const QString &);
inline QString &operator=(QLatin1String latin1);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QString(QString && other) : d(other.d) { other.d = Data::sharedNull(); }
- inline QString &operator=(QString &&other)
+ inline QString(QString && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); }
+ inline QString &operator=(QString &&other) Q_DECL_NOTHROW
{ qSwap(d, other.d); return *this; }
#endif
- inline void swap(QString &other) { qSwap(d, other.d); }
+ inline void swap(QString &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
inline int size() const { return d->size; }
inline int count() const { return d->size; }
inline int length() const;
@@ -1040,7 +1040,7 @@ inline void QCharRef::setRow(uchar arow) { QChar(*this).setRow(arow); }
inline void QCharRef::setCell(uchar acell) { QChar(*this).setCell(acell); }
-inline QString::QString() : d(Data::sharedNull()) {}
+inline QString::QString() Q_DECL_NOTHROW : d(Data::sharedNull()) {}
inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); }
inline void QString::reserve(int asize)
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h
index 542ab781c5..f82981b9dc 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/tools/qstringlist.h
@@ -90,11 +90,11 @@ class QStringList : public QList<QString>
{
#endif
public:
- inline QStringList() { }
+ inline QStringList() Q_DECL_NOTHROW { }
inline explicit QStringList(const QString &i) { append(i); }
inline QStringList(const QList<QString> &l) : QList<QString>(l) { }
#ifdef Q_COMPILER_RVALUE_REFS
- inline QStringList(QList<QString> &&l) : QList<QString>(std::move(l)) { }
+ inline QStringList(QList<QString> &&l) Q_DECL_NOTHROW : QList<QString>(std::move(l)) { }
#endif
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QStringList(std::initializer_list<QString> args) : QList<QString>(args) { }
@@ -103,7 +103,7 @@ public:
QStringList &operator=(const QList<QString> &other)
{ QList<QString>::operator=(other); return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
- QStringList &operator=(QList<QString> &&other)
+ QStringList &operator=(QList<QString> &&other) Q_DECL_NOTHROW
{ QList<QString>::operator=(std::move(other)); return *this; }
#endif
diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h
index ffc2316b5f..ef0bdc57cd 100644
--- a/src/corelib/tools/qtimezone.h
+++ b/src/corelib/tools/qtimezone.h
@@ -79,10 +79,10 @@ public:
QTimeZone &operator=(const QTimeZone &other);
#ifdef Q_COMPILER_RVALUE_REFS
- QTimeZone &operator=(QTimeZone &&other) { swap(other); return *this; }
+ QTimeZone &operator=(QTimeZone &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- void swap(QTimeZone &other)
+ void swap(QTimeZone &other) Q_DECL_NOTHROW
{ d.swap(other.d); }
bool operator==(const QTimeZone &other) const;
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index c00bd07a72..c3d65b7d51 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -61,7 +61,7 @@ class QVector
Data *d;
public:
- inline QVector() : d(Data::sharedNull()) { }
+ inline QVector() Q_DECL_NOTHROW : d(Data::sharedNull()) { }
explicit QVector(int size);
QVector(int size, const T &t);
inline QVector(const QVector<T> &v);