[PATCH] D66332: [clang-format] Fix the bug that joins template closer and > or >>
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 16 14:49:46 PDT 2019
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 ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66332.215681.patch
Type: text/x-patch
Size: 1170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190816/6de60715/attachment.bin>
More information about the cfe-commits
mailing list