diff options
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index be22fee9b2a..be4dc886008 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1550,11 +1550,16 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, if (Right.is(tok::star) && Left.is(tok::l_paren)) return false; if (Left.is(tok::l_square)) - return Left.Type == TT_ArrayInitializerLSquare && - Style.SpacesInContainerLiterals && Right.isNot(tok::r_square); + return (Left.Type == TT_ArrayInitializerLSquare && + Style.SpacesInContainerLiterals && Right.isNot(tok::r_square)) || + (Left.Type == TT_ArraySubscriptLSquare && + Style.SpacesInSquareBrackets && Right.isNot(tok::r_square)); if (Right.is(tok::r_square)) - return Right.MatchingParen && Style.SpacesInContainerLiterals && - Right.MatchingParen->Type == TT_ArrayInitializerLSquare; + return Right.MatchingParen && + ((Style.SpacesInContainerLiterals && + Right.MatchingParen->Type == TT_ArrayInitializerLSquare) || + (Style.SpacesInSquareBrackets && + Right.MatchingParen->Type == TT_ArraySubscriptLSquare)); if (Right.is(tok::l_square) && Right.Type != TT_ObjCMethodExpr && Right.Type != TT_LambdaLSquare && Left.isNot(tok::numeric_constant) && Left.Type != TT_DictLiteral) |