r220505 - clang-format: Fix incorrect space after "<".
Daniel Jasper
djasper at google.com
Thu Oct 23 13:22:23 PDT 2014
Author: djasper
Date: Thu Oct 23 15:22:22 2014
New Revision: 220505
URL: http://llvm.org/viewvc/llvm-project?rev=220505&view=rev
Log:
clang-format: Fix incorrect space after "<".
Before:
bool a = 2 <::SomeFunction();
After:
bool a = 2 < ::SomeFunction();
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=220505&r1=220504&r2=220505&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Oct 23 15:22:22 2014
@@ -1701,9 +1701,10 @@ bool TokenAnnotator::spaceRequiredBefore
Right.getPrecedence() == prec::Assignment)
return false;
if (Right.is(tok::coloncolon) && Left.isNot(tok::l_brace))
- return (Left.is(tok::less) && Style.Standard == FormatStyle::LS_Cpp03) ||
- !Left.isOneOf(tok::identifier, tok::greater, tok::l_paren,
- tok::r_paren, tok::less);
+ return (Left.Type == TT_TemplateOpener &&
+ Style.Standard == FormatStyle::LS_Cpp03) ||
+ !(Left.isOneOf(tok::identifier, tok::l_paren, tok::r_paren) ||
+ Left.Type == TT_TemplateCloser || Left.Type == TT_TemplateOpener);
if ((Left.Type == TT_TemplateOpener) != (Right.Type == TT_TemplateCloser))
return Style.SpacesInAngles;
if ((Right.Type == TT_BinaryOperator && !Left.is(tok::l_paren)) ||
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=220505&r1=220504&r2=220505&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Oct 23 15:22:22 2014
@@ -111,6 +111,7 @@ TEST_F(FormatTest, NestedNameSpecifiers)
verifyFormat("vector<::Type> v;");
verifyFormat("::ns::SomeFunction(::ns::SomeOtherFunction())");
verifyFormat("static constexpr bool Bar = decltype(bar())::value;");
+ verifyFormat("bool a = 2 < ::SomeFunction();");
}
TEST_F(FormatTest, OnlyGeneratesNecessaryReplacements) {
More information about the cfe-commits
mailing list