Skip to content

Commit cf30450

Browse files
committed
Fix ineffective LEGACY_NODELETE annotations on function templates and explicit conversion operators
https://bugs.webkit.org/show_bug.cgi?id=327985 Reviewed by Anne van Kesteren. Re-running the reverse no-delete static analysis after the recent NODELETE annotation patches revealed two cases where LEGACY_NODELETE was present but not honored by the checker: 1. Function templates with a separate declaration: annotating only the declaration (in a header or as a forward declaration) did not suppress the per-instantiation warnings. The annotation also needs to be on the out-of-line definition, so this patch adds it there. 2. Explicit conversion operators: `explicit LEGACY_NODELETE operator bool()` is accepted by the compiler but ignored by the checker, while `operator T LEGACY_NODELETE ()` is honored. This patch moves the annotation to after the conversion type. No new tests since there should be no behavioral changes. * Source/WTF/wtf/MediaTime.h: * Source/WTF/wtf/URLParser.cpp: (WTF::URLParser::takesTwoAdvancesUntilEnd): (WTF::URLParser::checkLocalhostCodePoint): (WTF::URLParser::isAtLocalhost): (WTF::URLParser::parseIPv4Piece): (WTF::URLParser::parseIPv4PieceInsideIPv6): (WTF::URLParser::parseIPv4AddressInsideIPv6): * Source/WebCore/dom/Node.cpp: (WebCore::commonInclusiveAncestor): (WebCore::treeOrder): * Source/WebCore/html/HTMLAttachmentElement.cpp: (WebCore::AttachmentEvent::operator bool LEGACY_NODELETE const): (WebCore::AttachmentEvent::operator bool const): Deleted. * Source/WebCore/layout/integration/inline/InlineIteratorLineBox.h: * Source/WebCore/platform/DateComponents.cpp: (WebCore::DateComponents::parseYear): (WebCore::DateComponents::parseMonth): (WebCore::DateComponents::parseDate): (WebCore::DateComponents::parseWeek): (WebCore::DateComponents::parseTime): (WebCore::DateComponents::parseDateTimeLocal): * Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.mm: (WebCore::AudioBufferListHolder::operator bool LEGACY_NODELETE const): (WebCore::AudioBufferListHolder::operator bool const): Deleted. * Source/WebCore/platform/graphics/filters/software/FECompositeSoftwareArithmeticApplier.cpp: (WebCore::FECompositeSoftwareArithmeticApplier::computePixels): (WebCore::FECompositeSoftwareArithmeticApplier::computePixelsUnclamped): * Source/WebCore/rendering/HitTestLocation.cpp: (WebCore::HitTestLocation::intersectsRect const): * Source/WebCore/style/calc/StyleCalculationTree+Copy.cpp: * Source/WebCore/style/calc/StyleCalculationTree+Substitution.cpp: (WebCore::Style::Calculation::mapLeaves): * Source/WebCore/svg/SVGPathStringViewSource.cpp: (WebCore::SVGPathStringViewSource::parse): Canonical link: https://commits.webkit.org/324090@main
1 parent 8b0147f commit cf30450

12 files changed

Lines changed: 24 additions & 24 deletions

File tree

‎Source/WTF/wtf/MediaTime.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class WTF_EXPORT_PRIVATE MediaTime final {
7676
MediaTime LEGACY_NODELETE operator-() const;
7777
MediaTime operator*(int32_t) const;
7878
bool LEGACY_NODELETE operator!() const;
79-
explicit LEGACY_NODELETE operator bool() const;
79+
explicit operator bool LEGACY_NODELETE () const;
8080

8181
WTF_EXPORT_PRIVATE friend std::partial_ordering LEGACY_NODELETE operator<=>(const MediaTime&, const MediaTime&);
8282
friend bool operator==(const MediaTime& a, const MediaTime& b) { return is_eq(a <=> b); }

‎Source/WTF/wtf/URLParser.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ ALWAYS_INLINE void URLParser::advance(CodePointIterator<CharacterType>& iterator
382382
}
383383

384384
template<typename CharacterType>
385-
bool URLParser::takesTwoAdvancesUntilEnd(CodePointIterator<CharacterType> iterator)
385+
bool LEGACY_NODELETE URLParser::takesTwoAdvancesUntilEnd(CodePointIterator<CharacterType> iterator)
386386
{
387387
if (iterator.atEnd())
388388
return false;
@@ -1096,7 +1096,7 @@ void URLParser::failure()
10961096
}
10971097

10981098
template<typename CharacterType>
1099-
bool URLParser::checkLocalhostCodePoint(CodePointIterator<CharacterType>& iterator, char32_t codePoint)
1099+
bool LEGACY_NODELETE URLParser::checkLocalhostCodePoint(CodePointIterator<CharacterType>& iterator, char32_t codePoint)
11001100
{
11011101
if (iterator.atEnd() || toASCIILower(*iterator) != codePoint)
11021102
return false;
@@ -1105,7 +1105,7 @@ bool URLParser::checkLocalhostCodePoint(CodePointIterator<CharacterType>& iterat
11051105
}
11061106

11071107
template<typename CharacterType>
1108-
bool URLParser::isAtLocalhost(CodePointIterator<CharacterType> iterator)
1108+
bool LEGACY_NODELETE URLParser::isAtLocalhost(CodePointIterator<CharacterType> iterator)
11091109
{
11101110
if (!checkLocalhostCodePoint(iterator, 'l'))
11111111
return false;
@@ -2287,7 +2287,7 @@ enum class URLParser::IPv4PieceParsingError {
22872287
};
22882288

22892289
template<typename CharacterType>
2290-
std::expected<uint32_t, URLParser::IPv4PieceParsingError> URLParser::parseIPv4Piece(CodePointIterator<CharacterType>& iterator, bool& didSeeSyntaxViolation)
2290+
std::expected<uint32_t, URLParser::IPv4PieceParsingError> LEGACY_NODELETE URLParser::parseIPv4Piece(CodePointIterator<CharacterType>& iterator, bool& didSeeSyntaxViolation)
22912291
{
22922292
enum class State : uint8_t {
22932293
UnknownBase,
@@ -2435,7 +2435,7 @@ std::expected<URLParser::IPv4Address, URLParser::IPv4ParsingError> URLParser::pa
24352435
}
24362436

24372437
template<typename CharacterType>
2438-
std::optional<uint32_t> URLParser::parseIPv4PieceInsideIPv6(CodePointIterator<CharacterType>& iterator)
2438+
std::optional<uint32_t> LEGACY_NODELETE URLParser::parseIPv4PieceInsideIPv6(CodePointIterator<CharacterType>& iterator)
24392439
{
24402440
if (iterator.atEnd())
24412441
return std::nullopt;
@@ -2464,7 +2464,7 @@ std::optional<uint32_t> URLParser::parseIPv4PieceInsideIPv6(CodePointIterator<Ch
24642464
}
24652465

24662466
template<typename CharacterType>
2467-
std::optional<URLParser::IPv4Address> URLParser::parseIPv4AddressInsideIPv6(CodePointIterator<CharacterType> iterator)
2467+
std::optional<URLParser::IPv4Address> LEGACY_NODELETE URLParser::parseIPv4AddressInsideIPv6(CodePointIterator<CharacterType> iterator)
24682468
{
24692469
IPv4Address address = 0;
24702470
for (size_t i = 0; i < 4; ++i) {

‎Source/WebCore/dom/Node.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3092,7 +3092,7 @@ template<TreeType treeType> AncestorAndChildren LEGACY_NODELETE commonInclusiveA
30923092
return { x, distinctAncestorA, distinctAncestorB };
30933093
}
30943094

3095-
template<TreeType treeType> Node* commonInclusiveAncestor(const Node& a, const Node& b)
3095+
template<TreeType treeType> Node* LEGACY_NODELETE commonInclusiveAncestor(const Node& a, const Node& b)
30963096
{
30973097
return const_cast<Node*>(commonInclusiveAncestorAndChildren<treeType>(a, b).commonAncestor);
30983098
}
@@ -3134,7 +3134,7 @@ template<TreeType treeType> bool LEGACY_NODELETE isSiblingSubsequent(const Node&
31343134
return false;
31353135
}
31363136

3137-
template<TreeType treeType> std::partial_ordering treeOrder(const Node& a, const Node& b)
3137+
template<TreeType treeType> std::partial_ordering LEGACY_NODELETE treeOrder(const Node& a, const Node& b)
31383138
{
31393139
if (&a == &b)
31403140
return std::partial_ordering::equivalent;

‎Source/WebCore/html/HTMLAttachmentElement.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ class AttachmentEvent {
611611
m_stackTrace = 0;
612612
}
613613

614-
explicit LEGACY_NODELETE operator bool() const
614+
explicit operator bool LEGACY_NODELETE () const
615615
{
616616
ASSERT(!m_attachment == !m_stackTrace);
617617
return !!m_attachment;

‎Source/WebCore/layout/integration/inline/InlineIteratorLineBox.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class LineBoxIterator {
122122
WEBCORE_EXPORT LineBoxIterator& LEGACY_NODELETE traverseNext();
123123
LineBoxIterator& LEGACY_NODELETE traversePrevious();
124124

125-
WEBCORE_EXPORT explicit LEGACY_NODELETE operator bool() const;
125+
WEBCORE_EXPORT explicit operator bool LEGACY_NODELETE () const;
126126

127127
bool LEGACY_NODELETE operator==(const LineBoxIterator&) const;
128128
bool operator==(EndLineBoxIterator) const { return atEnd(); }

‎Source/WebCore/platform/DateComponents.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ template<typename CharacterType> static std::optional<int> LEGACY_NODELETE parse
126126
}
127127

128128
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#months
129-
template<typename CharacterType> bool DateComponents::parseYear(StringParsingBuffer<CharacterType>& buffer)
129+
template<typename CharacterType> bool LEGACY_NODELETE DateComponents::parseYear(StringParsingBuffer<CharacterType>& buffer)
130130
{
131131
unsigned digitsLength = countDigits(buffer);
132132
// Needs at least 4 digits according to the standard.
@@ -365,7 +365,7 @@ template<typename CharacterType> bool DateComponents::parseTimeZone(StringParsin
365365
}
366366

367367
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#months
368-
template<typename CharacterType> bool DateComponents::parseMonth(StringParsingBuffer<CharacterType>& buffer)
368+
template<typename CharacterType> bool LEGACY_NODELETE DateComponents::parseMonth(StringParsingBuffer<CharacterType>& buffer)
369369
{
370370
if (!parseYear(buffer))
371371
return false;
@@ -387,7 +387,7 @@ template<typename CharacterType> bool DateComponents::parseMonth(StringParsingBu
387387
}
388388

389389
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#dates
390-
template<typename CharacterType> bool DateComponents::parseDate(StringParsingBuffer<CharacterType>& buffer)
390+
template<typename CharacterType> bool LEGACY_NODELETE DateComponents::parseDate(StringParsingBuffer<CharacterType>& buffer)
391391
{
392392
if (!parseMonth(buffer))
393393
return false;
@@ -408,7 +408,7 @@ template<typename CharacterType> bool DateComponents::parseDate(StringParsingBuf
408408
}
409409

410410
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#weeks
411-
template<typename CharacterType> bool DateComponents::parseWeek(StringParsingBuffer<CharacterType>& buffer)
411+
template<typename CharacterType> bool LEGACY_NODELETE DateComponents::parseWeek(StringParsingBuffer<CharacterType>& buffer)
412412
{
413413
if (!parseYear(buffer))
414414
return false;
@@ -431,7 +431,7 @@ template<typename CharacterType> bool DateComponents::parseWeek(StringParsingBuf
431431
}
432432

433433
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#times
434-
template<typename CharacterType> bool DateComponents::parseTime(StringParsingBuffer<CharacterType>& buffer)
434+
template<typename CharacterType> bool LEGACY_NODELETE DateComponents::parseTime(StringParsingBuffer<CharacterType>& buffer)
435435
{
436436
auto hour = parseIntWithinLimits(buffer, 2, 0, 23);
437437
if (!hour)
@@ -497,7 +497,7 @@ template<typename CharacterType> static bool LEGACY_NODELETE isDateTimeLocalSepa
497497
}
498498

499499
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#local-dates-and-times
500-
template<typename CharacterType> bool DateComponents::parseDateTimeLocal(StringParsingBuffer<CharacterType>& buffer)
500+
template<typename CharacterType> bool LEGACY_NODELETE DateComponents::parseDateTimeLocal(StringParsingBuffer<CharacterType>& buffer)
501501
{
502502
if (!parseDate(buffer))
503503
return false;

‎Source/WebCore/platform/audio/cocoa/AudioFileReaderCocoa.mm‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ explicit AudioBufferListHolder(size_t numberOfChannels)
276276
destroyAudioBufferList(m_bufferList);
277277
}
278278

279-
explicit LEGACY_NODELETE operator bool() const { return !!m_bufferList; }
279+
explicit operator bool LEGACY_NODELETE () const { return !!m_bufferList; }
280280
AudioBufferList* LEGACY_NODELETE operator->() const { return m_bufferList; }
281281
operator AudioBufferList* LEGACY_NODELETE () const { return m_bufferList; }
282282
AudioBufferList& LEGACY_NODELETE operator*() const { ASSERT(m_bufferList); return *m_bufferList; }

‎Source/WebCore/platform/graphics/filters/software/FECompositeSoftwareArithmeticApplier.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ uint8_t FECompositeSoftwareArithmeticApplier::clampByte(int c)
5252
}
5353

5454
template <int b1, int b4>
55-
inline void FECompositeSoftwareArithmeticApplier::computePixels(std::span<unsigned char> source, std::span<unsigned char> destination, int pixelArrayLength, float k1, float k2, float k3, float k4)
55+
inline void LEGACY_NODELETE FECompositeSoftwareArithmeticApplier::computePixels(std::span<unsigned char> source, std::span<unsigned char> destination, int pixelArrayLength, float k1, float k2, float k3, float k4)
5656
{
5757
float scaledK1;
5858
float scaledK4;
@@ -77,7 +77,7 @@ inline void FECompositeSoftwareArithmeticApplier::computePixels(std::span<unsign
7777
// computePixelsUnclamped is a faster version of computePixels for the common case where clamping
7878
// is not necessary. This enables aggresive compiler optimizations such as auto-vectorization.
7979
template <int b1, int b4>
80-
inline void FECompositeSoftwareArithmeticApplier::computePixelsUnclamped(std::span<unsigned char> source, std::span<unsigned char> destination, int pixelArrayLength, float k1, float k2, float k3, float k4)
80+
inline void LEGACY_NODELETE FECompositeSoftwareArithmeticApplier::computePixelsUnclamped(std::span<unsigned char> source, std::span<unsigned char> destination, int pixelArrayLength, float k1, float k2, float k3, float k4)
8181
{
8282
float scaledK1;
8383
float scaledK4;

‎Source/WebCore/rendering/HitTestLocation.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void HitTestLocation::move(const LayoutSize& offset)
7979
}
8080

8181
template<typename RectType>
82-
bool HitTestLocation::intersectsRect(const RectType& rect) const
82+
bool LEGACY_NODELETE HitTestLocation::intersectsRect(const RectType& rect) const
8383
{
8484
// FIXME: When the hit test is not rect based we should use rect.contains(m_point).
8585
// That does change some corner case tests though.

‎Source/WebCore/style/calc/StyleCalculationTree+Copy.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static auto copy(const Vector<CalcMix::Item>&) -> Vector<CalcMix::Item>;
4040
static auto copy(const ChildOrNone&) -> ChildOrNone;
4141
static auto copy(const Children&) -> Children;
4242
template<Leaf Op>
43-
Child copy(const Op&);
43+
Child LEGACY_NODELETE copy(const Op&);
4444
template<typename Op>
4545
static auto copy(const IndirectNode<Op>&) -> Child;
4646

0 commit comments

Comments
 (0)