File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -2325,7 +2325,7 @@ class SemiRemover : public TokenAnalyzer {
23252325private:
23262326 void removeSemi (TokenAnnotator &Annotator,
23272327 SmallVectorImpl<AnnotatedLine *> &Lines,
2328- tooling::Replacements &Result) {
2328+ tooling::Replacements &Result, bool Children = false ) {
23292329 auto PrecededByFunctionRBrace = [](const FormatToken &Tok) {
23302330 const auto *Prev = Tok.Previous ;
23312331 if (!Prev || Prev->isNot (tok::r_brace))
@@ -2337,10 +2337,12 @@ class SemiRemover : public TokenAnalyzer {
23372337 const auto End = Lines.end ();
23382338 for (auto I = Lines.begin (); I != End; ++I) {
23392339 const auto Line = *I;
2340- removeSemi (Annotator, Line->Children , Result);
2340+ if (!Line->Children .empty ())
2341+ removeSemi (Annotator, Line->Children , Result, /* Children=*/ true );
23412342 if (!Line->Affected )
23422343 continue ;
2343- Annotator.calculateFormattingInformation (*Line);
2344+ if (!Children)
2345+ Annotator.calculateFormattingInformation (*Line);
23442346 const auto NextLine = I + 1 == End ? nullptr : I[1 ];
23452347 for (auto Token = Line->First ; Token && !Token->Finalized ;
23462348 Token = Token->Next ) {
Original file line number Diff line number Diff line change @@ -27386,6 +27386,13 @@ TEST_F(FormatTest, RemoveSemicolon) {
2738627386 Style);
2738727387#endif
2738827388
27389+ verifyFormat("auto sgf = [] {\n"
27390+ " ogl = {\n"
27391+ " a, b, c, d, e,\n"
27392+ " };\n"
27393+ "};",
27394+ Style);
27395+
2738927396 Style.TypenameMacros.push_back("STRUCT");
2739027397 verifyFormat("STRUCT(T, B) { int i; };", Style);
2739127398}
You can’t perform that action at this time.
0 commit comments