Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 64c83f6f011bf6d550e515510ecef920a3b1c570
https://github.com/WebKit/WebKit/commit/64c83f6f011bf6d550e515510ecef920a3b1c570
Author: David Kilzer <[email protected]>
Date: 2026-09-28 (Mon, 28 Sep 2026)
Changed paths:
M Tools/Scripts/webkitpy/style/checker.py
M Tools/Scripts/webkitpy/style/checker_unittest.py
M Tools/Scripts/webkitpy/style/checkers/cpp.py
M Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
M Tools/TestWebKitAPI/Tests/WTF/Vector.cpp
Log Message:
-----------
check-webkit-style: flag Deque/Vector::append() of a temporary that
constructAndAppend() will build in place
<https://bugs.webkit.org/show_bug.cgi?id=325442>
<rdar://188544013>
Reviewed by Zak Ridouh.
Add a `runtime/construct_and_append` rule. `append(Foo { })`,
`append(Foo())`, and `append({ })` build a temporary in the caller's
frame and move it into the container, so a large temporary stays
reserved in that frame. In Bug 325430, a 4 KB `NestingContext`
temporary in `CSSParser`'s recursion let deeply nested rules overflow
the stack. A regex cannot see the receiver's type, so each message
starts "If this is a WTF::Vector"; on current main the rule has 1 false
positive among its 102 hits.
The `Vector` tests pin the behavior the message relies on:
`constructAndAppend()` builds the element with no move,
`constructAndAppend(WTF::InPlaceType<T>)` builds a `Variant`
alternative in place, and `append({ })` appends exactly one
value-initialized element. Exempt `Tests/WTF/Deque.cpp` and
`Tests/WTF/Vector.cpp` from the rule, since their tests use the
flagged forms on purpose.
Tests: Tools/Scripts/webkitpy/style/checker_unittest.py
Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
Tools/TestWebKitAPI/Tests/WTF/Vector.cpp
* Tools/Scripts/webkitpy/style/checker.py:
* Tools/Scripts/webkitpy/style/checker_unittest.py:
(GlobalVariablesTest.test_path_rules_specifier):
* Tools/Scripts/webkitpy/style/checkers/cpp.py:
(check_construct_and_append): Add.
(check_style):
(CppChecker):
* Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py:
(WebKitStyleTest._construct_and_append_message): Add.
(WebKitStyleTest.test_construct_and_append): Add.
(WebKitStyleTest.test_construct_and_append_empty_braces): Add.
(WebKitStyleTest.test_construct_and_append_std_types): Add.
(WebKitStyleTest.test_construct_and_append_without_receiver): Add.
(WebKitStyleTest.test_construct_and_append_allowed): Add.
* Tools/TestWebKitAPI/Tests/WTF/Vector.cpp:
(TestWebKitAPI::TEST(WTF_Vector,
AppendDefaultConstructedTemporaryMovesFromIt)): Add.
(TestWebKitAPI::TEST(WTF_Vector, ConstructAndAppendConstructsInPlace)): Add.
(TestWebKitAPI::TEST(WTF_Vector,
AppendEmptyBracesAppendsOneValueInitializedElement)): Add.
(TestWebKitAPI::TEST(WTF_Vector, ConstructAndAppendVariantAlternativeInPlace)):
Add.
Canonical link: https://commits.webkit.org/322081@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications