This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Refactoring and asserts in LevelIndentTracker. (NFC)
ClosedPublic

Authored by Sedeniono on Jul 12 2023, 8:32 AM.

Details

Summary
  • adjustToUnmodifiedLine: The code does something only for non-PP-directives. This is now reflected by putting the if-check to the top. This also ensures that the assert() there is executed only if IndentForLevel is actually accessed.
  • getIndent(): assert valid index into IndentForLevel.
  • Added explanation regarding the intention of IndentForLevel.

This refactoring was split from https://reviews.llvm.org/D151047.
But both patches are independent of each other.

Diff Detail

Event Timeline

Sedeniono created this revision.Jul 12 2023, 8:32 AM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptJul 12 2023, 8:32 AM
Herald added a reviewer: rymiel. · View Herald Transcript
Herald added a subscriber: cfe-commits. · View Herald Transcript
Sedeniono requested review of this revision.Jul 12 2023, 8:32 AM
owenpan added inline comments.Jul 12 2023, 1:50 PM
clang/lib/Format/UnwrappedLineFormatter.cpp
98–99

Early return.

owenpan added inline comments.Jul 12 2023, 4:09 PM
clang/lib/Format/UnwrappedLineFormatter.cpp
99–103

Ditto.

Sedeniono updated this revision to Diff 540682.Jul 15 2023, 6:33 AM

Implemented review changes suggested by @owenpan.

Sedeniono marked 2 inline comments as done.Jul 15 2023, 6:33 AM
owenpan accepted this revision.Jul 17 2023, 12:48 AM
This revision is now accepted and ready to land.Jul 17 2023, 12:48 AM

I don't see how the failed test cases could be my fault; they deal with the address sanitizer.
So maybe some one could please commit this to main using Sedenion <39583823+Sedeniono@users.noreply.github.com>? Thanks!

owenpan retitled this revision from Refactoring and asserts in LevelIndentTracker. (NFC) to [clang-format] Refactoring and asserts in LevelIndentTracker. (NFC).Jul 18 2023, 1:26 PM
owenpan edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Jul 18 2023, 1:32 PM
This revision was automatically updated to reflect the committed changes.