@@ -26,6 +26,13 @@ namespace format {
26
26
27
27
namespace {
28
28
29
+ // / Returns \c true if the line starts with a token that can start a statement
30
+ // / with an initializer.
31
+ static bool startsWithInitStatement (const AnnotatedLine &Line) {
32
+ return Line.startsWith (tok::kw_for) || Line.startsWith (tok::kw_if) ||
33
+ Line.startsWith (tok::kw_switch);
34
+ }
35
+
29
36
// / Returns \c true if the token can be used as an identifier in
30
37
// / an Objective-C \c \@selector, \c false otherwise.
31
38
// /
@@ -1135,7 +1142,7 @@ class AnnotatingParser {
1135
1142
else if (Contexts.back ().InInheritanceList )
1136
1143
Tok->setType (TT_InheritanceComma);
1137
1144
else if (Contexts.back ().FirstStartOfName &&
1138
- (Contexts.size () == 1 || Line. startsWith (tok::kw_for ))) {
1145
+ (Contexts.size () == 1 || startsWithInitStatement (Line ))) {
1139
1146
Contexts.back ().FirstStartOfName ->PartOfMultiVariableDeclStmt = true ;
1140
1147
Line.IsMultiVariableDeclStmt = true ;
1141
1148
}
@@ -3090,7 +3097,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
3090
3097
FormatStyle::PAS_Left ||
3091
3098
(Line.IsMultiVariableDeclStmt &&
3092
3099
(Left.NestingLevel == 0 ||
3093
- (Left.NestingLevel == 1 && Line. First -> is (tok::kw_for )))));
3100
+ (Left.NestingLevel == 1 && startsWithInitStatement (Line )))));
3094
3101
}
3095
3102
if (Right.is (TT_FunctionTypeLParen) && Left.isNot (tok::l_paren) &&
3096
3103
(!Left.is (TT_PointerOrReference) ||
0 commit comments