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 {
156
156
return First->is (tok::comment) ? First->getNextNonComment () : First;
157
157
}
158
158
159
+ FormatToken *getLastNonComment () const {
160
+ assert (Last);
161
+ return Last->is (tok::comment) ? Last->getPreviousNonComment () : Last;
162
+ }
163
+
159
164
FormatToken *First;
160
165
FormatToken *Last;
161
166
Original file line number Diff line number Diff line change @@ -346,14 +346,10 @@ class LineJoiner {
346
346
return false ;
347
347
348
348
// 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.
350
352
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
- }
357
353
return isRecordLBrace (*LastNonComment);
358
354
}
359
355
}
@@ -363,12 +359,9 @@ class LineJoiner {
363
359
364
360
bool MergeShortFunctions = ShouldMergeShortFunctions ();
365
361
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 ;
372
365
// FIXME: There are probably cases where we should use FirstNonComment
373
366
// instead of TheLine->First.
374
367
You can’t perform that action at this time.
0 commit comments