@@ -368,7 +368,8 @@ class LineJoiner {
368
368
if (TheLine->Last ->is (tok::l_brace)) {
369
369
if (Style.AllowShortNamespacesOnASingleLine &&
370
370
TheLine->First ->is (tok::kw_namespace)) {
371
- if (unsigned result = tryMergeNamespace (I, E, Limit))
371
+ unsigned result = tryMergeNamespace (I, E, Limit);
372
+ if (result > 0 )
372
373
return result;
373
374
}
374
375
}
@@ -643,26 +644,27 @@ class LineJoiner {
643
644
if (!nextTwoLinesFitInto (I, Limit))
644
645
return 0 ;
645
646
646
- // Check if it's a namespace inside a namespace, and call recursively if so
647
+ // Check if it's a namespace inside a namespace, and call recursively if so.
647
648
// '3' is the sizes of the whitespace and closing brace for " _inner_ }".
648
649
if (I[1 ]->First ->is (tok::kw_namespace)) {
649
- if (I[1 ]->Last ->is (TT_LineComment ))
650
+ if (I[1 ]->Last ->is (tok::comment ))
650
651
return 0 ;
651
652
652
653
const unsigned InnerLimit = Limit - I[1 ]->Last ->TotalLength - 3 ;
653
654
const unsigned MergedLines = tryMergeNamespace (I + 1 , E, InnerLimit);
654
655
if (!MergedLines)
655
656
return 0 ;
657
+ const auto N = MergedLines + 2 ;
656
658
// Check if there is even a line after the inner result.
657
- if (std::distance (I, E) <= MergedLines + 2 )
659
+ if (std::distance (I, E) <= N )
658
660
return 0 ;
659
661
// Check that the line after the inner result starts with a closing brace
660
662
// which we are permitted to merge into one line.
661
- if (I[2 + MergedLines ]->First ->is (tok::r_brace) &&
662
- !I[2 + MergedLines ]->First ->MustBreakBefore &&
663
- !I[1 + MergedLines ]->Last ->is (TT_LineComment ) &&
664
- nextNLinesFitInto (I, I + 2 + MergedLines + 1 , Limit)) {
665
- return 2 + MergedLines ;
663
+ if (I[N ]->First ->is (tok::r_brace) &&
664
+ !I[N ]->First ->MustBreakBefore &&
665
+ !I[MergedLines + 1 ]->Last ->is (tok::comment ) &&
666
+ nextNLinesFitInto (I, I + N + 1 , Limit)) {
667
+ return N ;
666
668
}
667
669
return 0 ;
668
670
}
0 commit comments