Page MenuHomePhabricator

[SyntaxTree] Improve the signature of `replaceChildRangeLowLevel`.
AbandonedPublic

Authored by eduucaldas on Oct 9 2020, 10:09 AM.

Details

Reviewers
gribozavr2
Summary

Previously replaceChildRangeLowLevel took the new child range as a Node* New. New was expected to have siblings attached already, and thus it was interpreted as a range. Additionally, the role of New and its siblings were expected to be set prior to calling the function. As a result the New argument broke the invariant New->Parent == nullptr <=> New->Role == Detached, at call site. We change the signature of replaceChildRangeLowLevel to take instead an ArrayRef<std::pair<Node*, NodeRole>>, and thus move the burden of setting siblings and roles from the user to the member function.

Moreover, replaceChildRangeLowLevel returns now a vector of the replaced range, following the "law of useful returns". Previously, in
order to reuse the replaced elements the user needed to get pointers to those elements and before calling the function.

We also fixed some minor bugs in addAfter, and added more asserts to the new replaceChildRangeLowLevel.

Diff Detail

Unit TestsFailed

TimeTest
3,950 mswindows > Clang-Unit.DirectoryWatcher/_/DirectoryWatcherTests_exe::DirectoryWatcherTest.AddFiles
Note: Google Test filter = DirectoryWatcherTest.AddFiles [==========] Running 1 test from 1 test case.
3,710 mswindows > Clang-Unit.DirectoryWatcher/_/DirectoryWatcherTests_exe::DirectoryWatcherTest.DeleteFile
Note: Google Test filter = DirectoryWatcherTest.DeleteFile [==========] Running 1 test from 1 test case.
3,820 mswindows > Clang-Unit.DirectoryWatcher/_/DirectoryWatcherTests_exe::DirectoryWatcherTest.ModifyFile
Note: Google Test filter = DirectoryWatcherTest.ModifyFile [==========] Running 1 test from 1 test case.

Event Timeline

eduucaldas created this revision.Oct 9 2020, 10:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 9 2020, 10:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
eduucaldas requested review of this revision.Oct 9 2020, 10:09 AM

Add reachability assertions

eduucaldas edited the summary of this revision. (Show Details)Oct 10 2020, 12:20 AM
eduucaldas edited the summary of this revision. (Show Details)

Add role sanity-check. Introduce GetBegin().

Fix whitespacing

Add asserts to MutationsImpl::remove

eduucaldas abandoned this revision.Oct 20 2020, 7:47 AM