Fix formatting of fully qualified names in array subscripts.

Before:
  a[ :🅱️:c];

After:
  a[:🅱️:c];

llvm-svn: 258123
This commit is contained in:
Manuel Klimek 2016-01-19 14:05:32 +00:00
parent 15f89c420b
commit 27f278186d
2 changed files with 3 additions and 1 deletions

View File

@ -2114,7 +2114,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
if (Right.is(tok::coloncolon) && Left.isNot(tok::l_brace))
return (Left.is(TT_TemplateOpener) &&
Style.Standard == FormatStyle::LS_Cpp03) ||
!(Left.isOneOf(tok::identifier, tok::l_paren, tok::r_paren) ||
!(Left.isOneOf(tok::identifier, tok::l_paren, tok::r_paren,
tok::l_square) ||
Left.isOneOf(TT_TemplateCloser, TT_TemplateOpener));
if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
return Style.SpacesInAngles;

View File

@ -6133,6 +6133,7 @@ TEST_F(FormatTest, FormatsArrays) {
"aaaaaaaaaaa aaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaa[0]\n"
" .aaaaaaa[0]\n"
" .aaaaaaaaaaaaaaaaaaaaaa();");
verifyFormat("a[::b::c];");
verifyNoCrash("a[,Y?)]", getLLVMStyleWithColumns(10));