Skip to content

Commit

Permalink
[clang-format] Fix the bug that joins template closer and > or >>
Browse files Browse the repository at this point in the history
Also fixes a buggy test case.

See PR42404

Differential Revision: https://reviews.llvm.org/D66332

llvm-svn: 369157
  • Loading branch information
owenca committed Aug 16, 2019
1 parent 8341a84 commit ac67414
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions clang/lib/Format/TokenAnnotator.cpp
Expand Up @@ -919,6 +919,8 @@ class AnnotatingParser {
case tok::greater:
if (Style.Language != FormatStyle::LK_TextProto)
Tok->Type = TT_BinaryOperator;
if (Tok->Previous && Tok->Previous->is(TT_TemplateCloser))
Tok->SpacesRequiredBefore = 1;
break;
case tok::kw_operator:
if (Style.Language == FormatStyle::LK_TextProto ||
Expand Down
5 changes: 4 additions & 1 deletion clang/unittests/Format/FormatTest.cpp
Expand Up @@ -6618,7 +6618,10 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
EXPECT_EQ("auto x = [] { A<A<A<A>>> a; };",
format("auto x=[]{A<A<A<A> >> a;};", getGoogleStyle()));

verifyFormat("A<A>> a;", getChromiumStyle(FormatStyle::LK_Cpp));
verifyFormat("A<A<int>> a;", getChromiumStyle(FormatStyle::LK_Cpp));

verifyFormat("int i = a<1> >> 1;");
verifyFormat("bool b = a<1> > 1;");

verifyFormat("test >> a >> b;");
verifyFormat("test << a >> b;");
Expand Down

0 comments on commit ac67414

Please sign in to comment.