This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Insert closing braces after an unaffected line
ClosedPublic

Authored by owenpan on Oct 21 2022, 3:32 AM.

Details

Summary

The token that records the number of closing braces to be inserted may be on an unaffected line. Extra work is required in order to actually insert the closing braces after inserting the matching opening braces of affected lines.

Fixes https://github.com/llvm/llvm-project/issues/58161.

Diff Detail

Event Timeline

owenpan created this revision.Oct 21 2022, 3:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 3:32 AM
owenpan requested review of this revision.Oct 21 2022, 3:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2022, 3:32 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MyDeveloperDay accepted this revision.Oct 21 2022, 8:44 AM

Does this need a unit test? or are we good?

This revision is now accepted and ready to land.Oct 21 2022, 8:44 AM
owenpan retitled this revision from [clang-format] Insert closing braces of unaffected lines to [clang-format] Insert closing braces after an unaffected line.Oct 22 2022, 12:01 AM
owenpan edited the summary of this revision. (Show Details)

Does this need a unit test? or are we good?

I will add the tests from https://github.com/llvm/llvm-project/issues/58161 in another patch after moving InsertBraces tests out of FormatTest.cpp, which doesn't support line range tests.

owenpan planned changes to this revision.Oct 22 2022, 1:33 PM

The assertions failed on the new examples in #58161.

This revision is now accepted and ready to land.Oct 23 2022, 1:46 AM
owenpan requested review of this revision.Oct 23 2022, 1:47 AM
MyDeveloperDay accepted this revision.Oct 23 2022, 7:21 AM
This revision is now accepted and ready to land.Oct 23 2022, 7:21 AM
This revision was landed with ongoing or failed builds.Oct 24 2022, 8:00 PM
This revision was automatically updated to reflect the committed changes.