Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit fe46d7f

Browse files
committed
Fix formatting of fully qualified names in array subscripts.
Before: a[ ::b::c]; After: a[::b::c]; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258123 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 97b1364 commit fe46d7f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/Format/TokenAnnotator.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
21142114
if (Right.is(tok::coloncolon) && Left.isNot(tok::l_brace))
21152115
return (Left.is(TT_TemplateOpener) &&
21162116
Style.Standard == FormatStyle::LS_Cpp03) ||
2117-
!(Left.isOneOf(tok::identifier, tok::l_paren, tok::r_paren) ||
2117+
!(Left.isOneOf(tok::identifier, tok::l_paren, tok::r_paren,
2118+
tok::l_square) ||
21182119
Left.isOneOf(TT_TemplateCloser, TT_TemplateOpener));
21192120
if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
21202121
return Style.SpacesInAngles;

unittests/Format/FormatTest.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -6133,6 +6133,7 @@ TEST_F(FormatTest, FormatsArrays) {
61336133
"aaaaaaaaaaa aaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaa[0]\n"
61346134
" .aaaaaaa[0]\n"
61356135
" .aaaaaaaaaaaaaaaaaaaaaa();");
6136+
verifyFormat("a[::b::c];");
61366137

61376138
verifyNoCrash("a[,Y?)]", getLLVMStyleWithColumns(10));
61386139

0 commit comments

Comments
 (0)