[PATCH] D114519: [clang-format] [PR52595] clang-format does not recognize rvalue references to array
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 25 03:10:33 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc94667a810e4: [clang-format] [PR52595] clang-format does not recognize rvalue references to… (authored by MyDeveloperDay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114519/new/
https://reviews.llvm.org/D114519
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
@@ -9670,6 +9670,9 @@
verifyFormat("void f() { a->operator()(a & a); }");
verifyFormat("void f() { a.operator()(*a & *a); }");
verifyFormat("void f() { a->operator()(*a * *a); }");
+
+ verifyFormat("int operator()(T (&&)[N]) { return 1; }");
+ verifyFormat("int operator()(T (&)[N]) { return 0; }");
}
TEST_F(FormatTest, UnderstandsAttributes) {
@@ -21876,6 +21879,7 @@
verifyFormat("Foo::operator&(void &);", Style);
verifyFormat("Foo::operator&();", Style);
verifyFormat("operator&(int (&)(), class Foo);", Style);
+ verifyFormat("operator&&(int (&)(), class Foo);", Style);
verifyFormat("Foo::operator&&();", Style);
verifyFormat("Foo::operator**();", Style);
@@ -21884,7 +21888,7 @@
verifyFormat("Foo::operator()(void &&);", Style);
verifyFormat("Foo::operator&&(void &&);", Style);
verifyFormat("Foo::operator&&();", Style);
- verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+ verifyFormat("operator&&(int (&&)(), class Foo);", Style);
verifyFormat("operator const nsTArrayRight<E> &()", Style);
verifyFormat("[[nodiscard]] operator const nsTArrayRight<E, Allocator> &()",
Style);
@@ -21935,6 +21939,8 @@
verifyFormat("Foo::operator&(void&);", Style);
verifyFormat("Foo::operator&();", Style);
verifyFormat("operator&(int (&)(), class Foo);", Style);
+ verifyFormat("operator&(int (&&)(), class Foo);", Style);
+ verifyFormat("operator&&(int (&&)(), class Foo);", Style);
verifyFormat("Foo::operator&&();", Style);
verifyFormat("Foo::operator void&&();", Style);
@@ -21945,7 +21951,7 @@
verifyFormat("Foo::operator()(void&&);", Style);
verifyFormat("Foo::operator&&(void&&);", Style);
verifyFormat("Foo::operator&&();", Style);
- verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+ verifyFormat("operator&&(int (&&)(), class Foo);", Style);
verifyFormat("operator const nsTArrayLeft<E>&()", Style);
verifyFormat("[[nodiscard]] operator const nsTArrayLeft<E, Allocator>&()",
Style);
@@ -21986,7 +21992,7 @@
verifyFormat("Foo::operator()(void &&);", Style);
verifyFormat("Foo::operator&&(void &&);", Style);
verifyFormat("Foo::operator&&();", Style);
- verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+ verifyFormat("operator&&(int (&&)(), class Foo);", Style);
}
TEST_F(FormatTest, OperatorPassedAsAFunctionPtr) {
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -317,7 +317,7 @@
// void (^ObjCBlock)(void);
bool MightBeFunctionType = !Contexts[Contexts.size() - 2].IsExpression;
bool ProbablyFunctionType =
- CurrentToken->isOneOf(tok::star, tok::amp, tok::caret);
+ CurrentToken->isOneOf(tok::star, tok::amp, tok::ampamp, tok::caret);
bool HasMultipleLines = false;
bool HasMultipleParametersOnALine = false;
bool MightBeObjCForRangeLoop =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114519.389713.patch
Type: text/x-patch
Size: 3193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211125/a5f8e6ae/attachment.bin>
More information about the cfe-commits
mailing list