Bug 2064677 - Add MOZ_LIFETIME_CAPTURE_BY_THIS to fix -Wdeprecated-attributes with clang 23 r=sergesanspaille
clang 23 deprecates lifetime_capture_by(this) in favor of lifetime_capture_by_this. Keep the old spelling as a fallback since the minimum supported clang is still 19. Differential Revision: https://phabricator.services.mozilla.com/D319738
This commit is contained in:
committed by
sledru@mozilla.com
parent
fec53586cc
commit
17705b58c6
@@ -486,6 +486,24 @@
|
||||
# define MOZ_LIFETIME_CAPTURE_BY(x) /* nothing */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MOZ_LIFETIME_CAPTURE_BY_THIS is the equivalent of
|
||||
* MOZ_LIFETIME_CAPTURE_BY(this). It needs to be spelled differently because
|
||||
* clang 23 deprecated passing `this` to lifetime_capture_by in favor of the
|
||||
* dedicated lifetime_capture_by_this attribute.
|
||||
*/
|
||||
#if defined(__clang__) && defined(__has_cpp_attribute)
|
||||
# if __has_cpp_attribute(clang::lifetime_capture_by_this)
|
||||
# define MOZ_LIFETIME_CAPTURE_BY_THIS [[clang::lifetime_capture_by_this]]
|
||||
# elif __has_cpp_attribute(clang::lifetime_capture_by)
|
||||
# define MOZ_LIFETIME_CAPTURE_BY_THIS [[clang::lifetime_capture_by(this)]]
|
||||
# else
|
||||
# define MOZ_LIFETIME_CAPTURE_BY_THIS /* nothing */
|
||||
# endif
|
||||
#else
|
||||
# define MOZ_LIFETIME_CAPTURE_BY_THIS /* nothing */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MOZ_REINITIALIZES tells static analyser that a call to the associated
|
||||
* method leave it in an initialized state, typically after a std::move.
|
||||
|
||||
@@ -101,6 +101,7 @@ Attributes.h:
|
||||
- MOZ_GSL_POINTER
|
||||
- MOZ_LIFETIME_BOUND
|
||||
- MOZ_LIFETIME_CAPTURE_BY
|
||||
- MOZ_LIFETIME_CAPTURE_BY_THIS
|
||||
- MOZ_STANDALONE_DEBUG
|
||||
- MOZ_NULL_AFTER_MOVE
|
||||
- MOZ_PUSH_DISABLE_NONTRIVIAL_UNION_WARNINGS
|
||||
|
||||
@@ -103,12 +103,12 @@ class MOZ_GSL_POINTER nsTDependentString : public nsTString<T> {
|
||||
*/
|
||||
|
||||
using nsTString<T>::Rebind;
|
||||
void Rebind(const char_type* aData MOZ_LIFETIME_CAPTURE_BY(this)) {
|
||||
void Rebind(const char_type* aData MOZ_LIFETIME_CAPTURE_BY_THIS) {
|
||||
Rebind(aData, char_traits::length(aData));
|
||||
}
|
||||
|
||||
void Rebind(const char_type* aStart MOZ_LIFETIME_CAPTURE_BY(this),
|
||||
const char_type* aEnd MOZ_LIFETIME_CAPTURE_BY(this));
|
||||
void Rebind(const char_type* aStart MOZ_LIFETIME_CAPTURE_BY_THIS,
|
||||
const char_type* aEnd MOZ_LIFETIME_CAPTURE_BY_THIS);
|
||||
void Rebind(const string_type&, index_type aStartPos);
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user