[PATCH] D148024: [clang-format] Don't modify template arguments on the LHS of assignment
Emilia Dreamer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 11 14:36:40 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5dc94b3356bd: [clang-format] Don't modify template arguments on the LHS of assignment (authored by rymiel).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148024/new/
https://reviews.llvm.org/D148024
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp
Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===================================================================
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -270,6 +270,18 @@
ASSERT_EQ(Tokens.size(), 19u) << Tokens;
EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_FunctionTypeLParen);
EXPECT_TOKEN(Tokens[7], tok::star, TT_PointerOrReference);
+
+ Tokens = annotate("Foo<A && B> a = {};");
+ ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+ EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_BinaryOperator);
+
+ Tokens = annotate("Foo<A &&> a = {};");
+ ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+ EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_PointerOrReference);
+
+ Tokens = annotate("template <enable_if_t<foo && !bar>* = nullptr> void f();");
+ ASSERT_EQ(Tokens.size(), 19u) << Tokens;
+ EXPECT_TOKEN(Tokens[5], tok::ampamp, TT_BinaryOperator);
}
TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1819,7 +1819,7 @@
Previous && Previous->Previous &&
!Previous->Previous->isOneOf(tok::comma, tok::semi);
Previous = Previous->Previous) {
- if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
+ if (Previous->isOneOf(tok::r_square, tok::r_paren, tok::greater)) {
Previous = Previous->MatchingParen;
if (!Previous)
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148024.512586.patch
Type: text/x-patch
Size: 1589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230411/139b4dfd/attachment.bin>
More information about the cfe-commits
mailing list