Bug 237265

Summary: WTF::SentinelLinkedList::iterator should have operator++ for range-for loop
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: Web Template FrameworkAssignee: Fujii Hironori <Hironori.Fujii>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, ews-watchlist, fpizlo, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch for landing none

Description Fujii Hironori 2022-02-27 22:01:43 PST
WTF::SentinelLinkedList has three problems.

Even though it has begin() and end(), using SentinelLinkedList
with range-for loop results in a broken node because
iterator::operator++ doesn't work as expected.

If I use a SentinelLinkedList in a movable type, the sentinel
pointer gets stale.

It doesn't have const_iterator.
Comment 1 Fujii Hironori 2022-02-27 22:10:01 PST
Created attachment 453366 [details]
Patch
Comment 2 Fujii Hironori 2022-02-28 04:20:07 PST
Created attachment 453381 [details]
Patch
Comment 3 Fujii Hironori 2022-02-28 05:09:23 PST
Created attachment 453382 [details]
Patch
Comment 4 Yusuke Suzuki 2022-02-28 21:48:49 PST
Comment on attachment 453382 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453382&action=review

r=me

> Source/WTF/wtf/SentinelLinkedList.h:89
> +        BaseIterator(RawNodeType* node)

Let's make it `explicit` constructor.
Comment 5 Fujii Hironori 2022-03-01 12:04:47 PST
Comment on attachment 453382 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453382&action=review

Thank you very much for the review.

>> Source/WTF/wtf/SentinelLinkedList.h:89
>> +        BaseIterator(RawNodeType* node)
> 
> Let's make it `explicit` constructor.

It's a good idea. 
But, I did this because there are some existing code assuming an iterator can compare with a node pointer.
But, It seeds a bad idea comparing an iterator without deference. I'm going to rewrite them.
Comment 6 Fujii Hironori 2022-03-01 13:28:42 PST
Created attachment 453534 [details]
Patch for landing
Comment 7 Fujii Hironori 2022-03-01 15:51:42 PST
Comment on attachment 453534 [details]
Patch for landing

Clearing flags on attachment: 453534

Committed r290705 (247954@trunk): <https://commits.webkit.org/247954@trunk>
Comment 8 Fujii Hironori 2022-03-01 15:51:48 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2022-03-01 15:52:17 PST
<rdar://problem/89646622>