RESOLVED FIXED 198175
[WHLSL] Add a helper for in-place AST mutation
https://bugs.webkit.org/show_bug.cgi?id=198175
Summary [WHLSL] Add a helper for in-place AST mutation
Myles C. Maxfield
Reported 2019-05-23 00:30:13 PDT
Something like template <typename Old, typename New, typename ...Args> New* replace(Old& old, Args&&... args) { static_assert(sizeof(New) <= sizeof(Old)); return new (&old) New(std::forward<Args>(args)...); }
Attachments
patch (10.95 KB, patch)
2019-05-23 11:26 PDT, Saam Barati
mmaxfield: review+
patch for landing (10.98 KB, patch)
2019-05-23 11:40 PDT, Saam Barati
no flags
Saam Barati
Comment 1 2019-05-23 10:54:20 PDT
patch forthcoming
Saam Barati
Comment 2 2019-05-23 11:26:03 PDT
Myles C. Maxfield
Comment 3 2019-05-23 11:32:05 PDT
Comment on attachment 370510 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=370510&action=review > Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNode.h:56 > + return new (&old) New(std::forward<Args>(args)...); Don’t you have to save the address of “old” before you call its destructor?
Saam Barati
Comment 4 2019-05-23 11:38:47 PDT
(In reply to Myles C. Maxfield from comment #3) > Comment on attachment 370510 [details] > patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=370510&action=review > > > Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNode.h:56 > > + return new (&old) New(std::forward<Args>(args)...); > > Don’t you have to save the address of “old” before you call its destructor? Spoke with Myles offline. This code is probably fine (since dtor is just a method call), but we're just going to be explicit and do it before.
Saam Barati
Comment 5 2019-05-23 11:40:04 PDT
Created attachment 370512 [details] patch for landing
WebKit Commit Bot
Comment 6 2019-05-23 12:55:00 PDT
Comment on attachment 370512 [details] patch for landing Clearing flags on attachment: 370512 Committed r245706: <https://trac.webkit.org/changeset/245706>
WebKit Commit Bot
Comment 7 2019-05-23 12:55:01 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 8 2019-05-23 12:55:17 PDT
Note You need to log in before you can comment on or make changes to this bug.