[PATCH] D119785: [clang-format] Fix formatting of struct-like records followed by variable declaration.
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 15 00:27:32 PST 2022
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.
LGTM, I really like the approach of us annotating more like this, it makes the token much easier to reason about when there is ambiguity. nice one!
================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:735
// We don't merge short records.
- FormatToken *RecordTok = Line.First;
- // Skip record modifiers.
- while (RecordTok->Next &&
- RecordTok->isOneOf(tok::kw_typedef, tok::kw_export,
- Keywords.kw_declare, Keywords.kw_abstract,
- tok::kw_default, Keywords.kw_override,
- tok::kw_public, tok::kw_private,
- tok::kw_protected, Keywords.kw_internal))
- RecordTok = RecordTok->Next;
- if (RecordTok &&
- RecordTok->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct,
- Keywords.kw_interface))
+ if (isRecordLBrace(*Line.Last))
return 0;
----------------
wow these are equivalent? do we need to worry about trailing comments?
```
public class A { /* comment */
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119785/new/
https://reviews.llvm.org/D119785
More information about the cfe-commits
mailing list