This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Improve understanding of combined typedef+record declarations
ClosedPublic

Authored by jtbandes on May 3 2017, 12:49 PM.

Details

Reviewers
djasper
Summary

Fixes an issue where struct A { int X; }; would be broken onto multiple lines, but typedef struct A { int X; } A2; was collapsed onto a single line.

Event Timeline

jtbandes created this revision.May 3 2017, 12:49 PM

It strikes me that this doesn't handle using-style type aliases, but it seems hard to do this correctly in general, so still valuable to catch this simple, common case. Let me know if you have any better suggestions!

djasper accepted this revision.May 10 2017, 10:36 PM

One nit, otherwise looks good.

lib/Format/UnwrappedLineFormatter.cpp
367–368

Don't use "T", that's too much engrained as template parameter. Use "Tok".

This revision is now accepted and ready to land.May 10 2017, 10:36 PM
jtbandes updated this revision to Diff 98593.May 11 2017, 1:15 AM

Update from review

jtbandes marked an inline comment as done.May 11 2017, 1:15 AM
jtbandes added inline comments.
lib/Format/UnwrappedLineFormatter.cpp
367–368

Added nested scope to avoid shadowing Tok from above.

jtbandes marked an inline comment as done.May 16 2017, 11:35 AM

Another ping.

djasper closed this revision.Jun 19 2017, 12:46 AM

Renamed Tok to RecordTok to avoid the nested scope and submitted as r305667.