[PATCH] D137223: [clang-format] Remove special case for kw_operator when aligning decls
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 2 02:16:49 PDT 2022
owenpan added inline comments.
================
Comment at: clang/unittests/Format/FormatTest.cpp:17939
Alignment);
+ // Ensure operators are not aligned if they're being called, not declared
+ verifyFormat("int main() {\n"
----------------
Add a full stop.
================
Comment at: clang/unittests/Format/FormatTest.cpp:17939-17946
+ // Ensure operators are not aligned if they're being called, not declared
+ verifyFormat("int main() {\n"
+ " int operator()(int a);\n"
+ " double operator+(double a);\n"
+ " operator()(1);\n"
+ " operator+(1.0);\n"
+ "};\n",
----------------
owenpan wrote:
> Add a full stop.
Consider using a test case similar to the examples in https://github.com/llvm/llvm-project/issues/55733 or not adding a test case at all as the added annotator tests will cover it.
================
Comment at: clang/unittests/Format/FormatTest.cpp:17945
+ " operator+(1.0);\n"
+ "};\n",
+ Alignment);
----------------
Remove the newline.
================
Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:441-456
+ Tokens = annotate("int operator+(int);");
+ ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+ EXPECT_TOKEN(Tokens[1], tok::kw_operator, TT_FunctionDeclarationName);
+ EXPECT_TOKEN(Tokens[2], tok::plus, TT_OverloadedOperator);
+ EXPECT_TOKEN(Tokens[3], tok::l_paren, TT_OverloadedOperatorLParen);
+ Tokens = annotate("auto operator=(T&) {}");
+ ASSERT_EQ(Tokens.size(), 10u) << Tokens;
----------------
Instead of adding new tests, you can add checks for `kw_operator` and `TT_FunctionDeclarationName` to the existing ones.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137223/new/
https://reviews.llvm.org/D137223
More information about the cfe-commits
mailing list