r258123 - Fix formatting of fully qualified names in array subscripts.
Manuel Klimek via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 19 06:05:32 PST 2016
Author: klimek
Date: Tue Jan 19 08:05:32 2016
New Revision: 258123
URL: http://llvm.org/viewvc/llvm-project?rev=258123&view=rev
Log:
Fix formatting of fully qualified names in array subscripts.
Before:
a[ ::b::c];
After:
a[::b::c];
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=258123&r1=258122&r2=258123&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Jan 19 08:05:32 2016
@@ -2114,7 +2114,8 @@ bool TokenAnnotator::spaceRequiredBefore
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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=258123&r1=258122&r2=258123&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jan 19 08:05:32 2016
@@ -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));
More information about the cfe-commits
mailing list