clang-format: Fix incorrect space after "<".

Before:
  bool a = 2 <::SomeFunction();

After:
  bool a = 2 < ::SomeFunction();

llvm-svn: 220505
This commit is contained in:
Daniel Jasper 2014-10-23 20:22:22 +00:00
parent 078be601cf
commit f322eb5c45
2 changed files with 5 additions and 3 deletions

View File

@ -1701,9 +1701,10 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
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)) ||

View File

@ -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) {