File tree Expand file tree Collapse file tree 2 files changed +11
-13
lines changed
Expand file tree Collapse file tree 2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,11 @@ class AnnotatedLine {
156156 return First->is (tok::comment) ? First->getNextNonComment () : First;
157157 }
158158
159+ FormatToken *getLastNonComment () const {
160+ assert (Last);
161+ return Last->is (tok::comment) ? Last->getPreviousNonComment () : Last;
162+ }
163+
159164 FormatToken *First;
160165 FormatToken *Last;
161166
Original file line number Diff line number Diff line change @@ -346,14 +346,10 @@ class LineJoiner {
346346 return false ;
347347
348348 // Check if the found line starts a record.
349- const FormatToken *LastNonComment = Line->Last ;
349+ const auto *LastNonComment = Line->getLastNonComment ();
350+ // There must be another token (usually `{`), because we chose a
351+ // non-PPDirective and non-comment line that has a smaller level.
350352 assert (LastNonComment);
351- if (LastNonComment->is (tok::comment)) {
352- LastNonComment = LastNonComment->getPreviousNonComment ();
353- // There must be another token (usually `{`), because we chose a
354- // non-PPDirective and non-comment line that has a smaller level.
355- assert (LastNonComment);
356- }
357353 return isRecordLBrace (*LastNonComment);
358354 }
359355 }
@@ -363,12 +359,9 @@ class LineJoiner {
363359
364360 bool MergeShortFunctions = ShouldMergeShortFunctions ();
365361
366- const FormatToken *FirstNonComment = TheLine->First ;
367- if (FirstNonComment->is (tok::comment)) {
368- FirstNonComment = FirstNonComment->getNextNonComment ();
369- if (!FirstNonComment)
370- return 0 ;
371- }
362+ const auto *FirstNonComment = TheLine->getFirstNonComment ();
363+ if (!FirstNonComment)
364+ return 0 ;
372365 // FIXME: There are probably cases where we should use FirstNonComment
373366 // instead of TheLine->First.
374367
You can’t perform that action at this time.
0 commit comments