@@ -183,9 +183,9 @@ class LevelIndentTracker {
183
183
unsigned Indent = 0 ;
184
184
};
185
185
186
- const FormatToken *getMatchingNamespaceToken (
187
- const AnnotatedLine *Line,
188
- const SmallVectorImpl <AnnotatedLine *> &AnnotatedLines) {
186
+ const FormatToken *
187
+ getMatchingNamespaceToken ( const AnnotatedLine *Line,
188
+ const ArrayRef <AnnotatedLine *> &AnnotatedLines) {
189
189
if (!Line->startsWith (tok::r_brace))
190
190
return nullptr ;
191
191
size_t StartLineIndex = Line->MatchingOpeningBlockLineIndex ;
@@ -200,9 +200,9 @@ StringRef getNamespaceTokenText(const AnnotatedLine *Line) {
200
200
return NamespaceToken ? NamespaceToken->TokenText : StringRef ();
201
201
}
202
202
203
- StringRef getMatchingNamespaceTokenText (
204
- const AnnotatedLine *Line,
205
- const SmallVectorImpl <AnnotatedLine *> &AnnotatedLines) {
203
+ StringRef
204
+ getMatchingNamespaceTokenText ( const AnnotatedLine *Line,
205
+ const ArrayRef <AnnotatedLine *> &AnnotatedLines) {
206
206
const FormatToken *NamespaceToken =
207
207
getMatchingNamespaceToken (Line, AnnotatedLines);
208
208
return NamespaceToken ? NamespaceToken->TokenText : StringRef ();
@@ -241,8 +241,8 @@ class LineJoiner {
241
241
// / Calculates how many lines can be merged into 1 starting at \p I.
242
242
unsigned
243
243
tryFitMultipleLinesInOne (LevelIndentTracker &IndentTracker,
244
- SmallVectorImpl <AnnotatedLine *>::const_iterator I,
245
- SmallVectorImpl <AnnotatedLine *>::const_iterator E) {
244
+ ArrayRef <AnnotatedLine *>::const_iterator I,
245
+ ArrayRef <AnnotatedLine *>::const_iterator E) {
246
246
const unsigned Indent = IndentTracker.getIndent ();
247
247
248
248
// Can't join the last line with anything.
@@ -614,8 +614,8 @@ class LineJoiner {
614
614
}
615
615
616
616
unsigned
617
- tryMergeSimplePPDirective (SmallVectorImpl <AnnotatedLine *>::const_iterator I,
618
- SmallVectorImpl <AnnotatedLine *>::const_iterator E,
617
+ tryMergeSimplePPDirective (ArrayRef <AnnotatedLine *>::const_iterator I,
618
+ ArrayRef <AnnotatedLine *>::const_iterator E,
619
619
unsigned Limit) {
620
620
if (Limit == 0 )
621
621
return 0 ;
@@ -626,8 +626,8 @@ class LineJoiner {
626
626
return 1 ;
627
627
}
628
628
629
- unsigned tryMergeNamespace (SmallVectorImpl <AnnotatedLine *>::const_iterator I,
630
- SmallVectorImpl <AnnotatedLine *>::const_iterator E,
629
+ unsigned tryMergeNamespace (ArrayRef <AnnotatedLine *>::const_iterator I,
630
+ ArrayRef <AnnotatedLine *>::const_iterator E,
631
631
unsigned Limit) {
632
632
if (Limit == 0 )
633
633
return 0 ;
@@ -692,9 +692,10 @@ class LineJoiner {
692
692
return 2 ;
693
693
}
694
694
695
- unsigned tryMergeSimpleControlStatement (
696
- SmallVectorImpl<AnnotatedLine *>::const_iterator I,
697
- SmallVectorImpl<AnnotatedLine *>::const_iterator E, unsigned Limit) {
695
+ unsigned
696
+ tryMergeSimpleControlStatement (ArrayRef<AnnotatedLine *>::const_iterator I,
697
+ ArrayRef<AnnotatedLine *>::const_iterator E,
698
+ unsigned Limit) {
698
699
if (Limit == 0 )
699
700
return 0 ;
700
701
if (Style.BraceWrapping .AfterControlStatement ==
@@ -734,10 +735,9 @@ class LineJoiner {
734
735
return 1 ;
735
736
}
736
737
737
- unsigned
738
- tryMergeShortCaseLabels (SmallVectorImpl<AnnotatedLine *>::const_iterator I,
739
- SmallVectorImpl<AnnotatedLine *>::const_iterator E,
740
- unsigned Limit) {
738
+ unsigned tryMergeShortCaseLabels (ArrayRef<AnnotatedLine *>::const_iterator I,
739
+ ArrayRef<AnnotatedLine *>::const_iterator E,
740
+ unsigned Limit) {
741
741
if (Limit == 0 || I + 1 == E ||
742
742
I[1 ]->First ->isOneOf (tok::kw_case, tok::kw_default)) {
743
743
return 0 ;
@@ -768,7 +768,7 @@ class LineJoiner {
768
768
if (Line->First ->is (tok::comment)) {
769
769
if (Level != Line->Level )
770
770
return 0 ;
771
- SmallVectorImpl<AnnotatedLine *>::const_iterator J = I + 2 + NumStmts;
771
+ const auto * J = I + 2 + NumStmts;
772
772
for (; J != E; ++J) {
773
773
Line = *J;
774
774
if (Line->InPPDirective != InPPDirective)
@@ -789,10 +789,9 @@ class LineJoiner {
789
789
return NumStmts;
790
790
}
791
791
792
- unsigned
793
- tryMergeSimpleBlock (SmallVectorImpl<AnnotatedLine *>::const_iterator I,
794
- SmallVectorImpl<AnnotatedLine *>::const_iterator E,
795
- unsigned Limit) {
792
+ unsigned tryMergeSimpleBlock (ArrayRef<AnnotatedLine *>::const_iterator I,
793
+ ArrayRef<AnnotatedLine *>::const_iterator E,
794
+ unsigned Limit) {
796
795
// Don't merge with a preprocessor directive.
797
796
if (I[1 ]->Type == LT_PreprocessorDirective)
798
797
return 0 ;
@@ -974,26 +973,25 @@ class LineJoiner {
974
973
975
974
// / Returns the modified column limit for \p I if it is inside a macro and
976
975
// / needs a trailing '\'.
977
- unsigned
978
- limitConsideringMacros (SmallVectorImpl<AnnotatedLine *>::const_iterator I,
979
- SmallVectorImpl<AnnotatedLine *>::const_iterator E,
980
- unsigned Limit) {
976
+ unsigned limitConsideringMacros (ArrayRef<AnnotatedLine *>::const_iterator I,
977
+ ArrayRef<AnnotatedLine *>::const_iterator E,
978
+ unsigned Limit) {
981
979
if (I[0 ]->InPPDirective && I + 1 != E &&
982
980
!I[1 ]->First ->HasUnescapedNewline && I[1 ]->First ->isNot (tok::eof)) {
983
981
return Limit < 2 ? 0 : Limit - 2 ;
984
982
}
985
983
return Limit;
986
984
}
987
985
988
- bool nextTwoLinesFitInto (SmallVectorImpl <AnnotatedLine *>::const_iterator I,
986
+ bool nextTwoLinesFitInto (ArrayRef <AnnotatedLine *>::const_iterator I,
989
987
unsigned Limit) {
990
988
if (I[1 ]->First ->MustBreakBefore || I[2 ]->First ->MustBreakBefore )
991
989
return false ;
992
990
return 1 + I[1 ]->Last ->TotalLength + 1 + I[2 ]->Last ->TotalLength <= Limit;
993
991
}
994
992
995
- bool nextNLinesFitInto (SmallVectorImpl <AnnotatedLine *>::const_iterator I,
996
- SmallVectorImpl <AnnotatedLine *>::const_iterator E,
993
+ bool nextNLinesFitInto (ArrayRef <AnnotatedLine *>::const_iterator I,
994
+ ArrayRef <AnnotatedLine *>::const_iterator E,
997
995
unsigned Limit) {
998
996
unsigned JoinedLength = 0 ;
999
997
for (const auto *J = I + 1 ; J != E; ++J) {
@@ -1034,9 +1032,9 @@ class LineJoiner {
1034
1032
1035
1033
const FormatStyle &Style;
1036
1034
const AdditionalKeywords &Keywords;
1037
- const SmallVectorImpl <AnnotatedLine *>::const_iterator End;
1035
+ const ArrayRef <AnnotatedLine *>::const_iterator End;
1038
1036
1039
- SmallVectorImpl <AnnotatedLine *>::const_iterator Next;
1037
+ ArrayRef <AnnotatedLine *>::const_iterator Next;
1040
1038
const SmallVectorImpl<AnnotatedLine *> &AnnotatedLines;
1041
1039
};
1042
1040
0 commit comments