This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Handle "complex" conditionals in RemoveBracesLLVM
ClosedPublic

Authored by owenpan on May 20 2022, 2:25 AM.

Details

Summary

Do not remove braces if the conditional of if/for/while might not fit on a single line even after the opening brace is removed.

Examples:

// ColumnLimit: 20
// 45678901234567890
if (a) { /* Remove. */
  foo();
}
if (-b >= c) { // Keep.
  bar();
}

This is the last feature/exception of RemoveBracesLLVM.

Diff Detail

Event Timeline

owenpan created this revision.May 20 2022, 2:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 20 2022, 2:25 AM
owenpan requested review of this revision.May 20 2022, 2:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 20 2022, 2:25 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
This revision is now accepted and ready to land.May 20 2022, 4:25 AM
owenpan updated this revision to Diff 431100.May 20 2022, 5:07 PM

Changed an unnecessary condition to an assertion.