This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix short enums getting wrapped even when denied
ClosedPublic

Authored by yodaldevoid on Dec 22 2021, 2:21 PM.

Details

Summary

Single-variant enums were still getting placed on a single line even
when AllowShortEnumsOnASingleLine was false. This fixes that by checking
that setting when looking to merge lines.

Diff Detail

Event Timeline

yodaldevoid requested review of this revision.Dec 22 2021, 2:21 PM
yodaldevoid created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2021, 2:21 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Can you test the typedef case you added?

owenpan added inline comments.Dec 22 2021, 5:47 PM
clang/lib/Format/UnwrappedLineFormatter.cpp
398–403

Nits:

  • It's unnecessary to add the checking for a null TheLine->First on line 398 since TheLine->Last is nonnull.
  • The suggested assert is optional.
  • Since the first token is typedef and the last {, checking for a null Tok on line 400 is unnecessary.
406
MyDeveloperDay added a project: Restricted Project.Dec 23 2021, 7:15 AM

Addressed reviewer comments

  • Removed unnecessary null checks
  • Added tests for typedefs preceding short enums
yodaldevoid marked an inline comment as done.Dec 23 2021, 9:42 AM
yodaldevoid marked an inline comment as done.

Correct commit email

Correct commit email

Since you only upload a diff, there is no name or email. ;)

This revision is now accepted and ready to land.Dec 23 2021, 12:07 PM
owenpan accepted this revision.Dec 23 2021, 4:32 PM

Since you only upload a diff, there is no name or email. ;)

It had looked like arcanist was retaining this information, but I now realize what it was doing.

At any rate, I would appreciate it if someone could merge this for me as I don't have commit access.

Gabriel Smith <ga29smith@gmail.com>

This revision was landed with ongoing or failed builds.Dec 24 2021, 11:48 AM
This revision was automatically updated to reflect the committed changes.