This revision was automatically updated to reflect the committed changes. Closed by commit rGac67414618df: [clang-format] Fix the bug that joins template closer and > or >> (authored by owenpan).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66332/new/ https://reviews.llvm.org/D66332 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -6618,7 +6618,10 @@ 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;"); Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -919,6 +919,8 @@ 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 ||
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -6618,7 +6618,10 @@ 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;"); Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -919,6 +919,8 @@ 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 ||
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits