[PATCH] D70305: clang-format: fix regression in middle pointer alignment
Francois Ferrand via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 15 05:06:30 PST 2019
Typz created this revision.
Typz added reviewers: MyDeveloperDay, klimek, sammccall.
Herald added a project: clang.
a75f8d98d7ac <https://reviews.llvm.org/rGa75f8d98d7ac9e557b238a229a9a2647c71feed1> introduced a regression with Middle pointer alignment,
which this patch fixes.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70305
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
@@ -14843,6 +14843,28 @@
verifyFormat("Foo::operator&&(void&&);", Style);
verifyFormat("Foo::operator&&();", Style);
verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+
+ Style.PointerAlignment = FormatStyle::PAS_Middle;
+ verifyFormat("Foo::operator*();", Style);
+ verifyFormat("Foo::operator void *();", Style);
+ verifyFormat("Foo::operator()(void *);", Style);
+ verifyFormat("Foo::operator*(void *);", Style);
+ verifyFormat("Foo::operator*();", Style);
+ verifyFormat("operator*(int (*)(), class Foo);", Style);
+
+ verifyFormat("Foo::operator&();", Style);
+ verifyFormat("Foo::operator void &();", Style);
+ verifyFormat("Foo::operator()(void &);", Style);
+ verifyFormat("Foo::operator&(void &);", Style);
+ verifyFormat("Foo::operator&();", Style);
+ verifyFormat("operator&(int (&)(), class Foo);", Style);
+
+ verifyFormat("Foo::operator&&();", Style);
+ verifyFormat("Foo::operator void &&();", Style);
+ verifyFormat("Foo::operator()(void &&);", Style);
+ verifyFormat("Foo::operator&&(void &&);", Style);
+ verifyFormat("Foo::operator&&();", Style);
+ verifyFormat("operator&&(int(&&)(), class Foo);", Style);
}
} // namespace
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2694,7 +2694,7 @@
// Space between the type and the *
// operator void*(), operator char*(), operator Foo*() dependant
// on PointerAlignment style.
- return (Style.PointerAlignment == FormatStyle::PAS_Right);
+ return (Style.PointerAlignment != FormatStyle::PAS_Left);
const auto SpaceRequiredForArrayInitializerLSquare =
[](const FormatToken &LSquareTok, const FormatStyle &Style) {
return Style.SpacesInContainerLiterals ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70305.229516.patch
Type: text/x-patch
Size: 2042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191115/bd4224f6/attachment-0001.bin>
More information about the cfe-commits
mailing list