curdeius added inline comments.
================ 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; ---------------- curdeius wrote: > MyDeveloperDay wrote: > > wow these are equivalent? do we need to worry about trailing comments? > > > > ``` > > public class A { /* comment */ > > ``` > Yes, before we were doing a poor man's scan skipping some (but not all) > keywords (hence the bugs) that could appear before a record. > That was error-prone and redundant w.r.t. the parsing done in > UnwrappedLineParser. > > Anyway, good catch, I'll test what happens with comments. @MyDeveloperDay, do we want this (probably more coherent): ``` verifyFormat("struct A {};", AllowSimpleBracedStatements); // already tested verifyFormat("struct A { /* comment */ };", AllowSimpleBracedStatements); // added ``` or this (current behaviour): ``` verifyFormat("struct A {};", AllowSimpleBracedStatements); // already tested verifyFormat("struct A { /* comment */\n" "};", AllowSimpleBracedStatements); // added ``` (adapted from `TEST_F(FormatTest, FormatShortBracedStatements)`) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119785/new/ https://reviews.llvm.org/D119785 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits