diff options
author | Krasimir Georgiev <krasimir@google.com> | 2020-01-17 13:26:24 +0100 |
---|---|---|
committer | Hans Wennborg <hans@chromium.org> | 2020-03-02 11:19:33 +0100 |
commit | 99e5b2ff9df5ca4c7fe13b63f60d953058cd9ca3 (patch) | |
tree | 22ef6f07925ad4cc88170da012679042ac21fe0e /clang/unittests/Format/FormatTest.cpp | |
parent | 6b16ce944fef5f3b30b7dcc001b3af478e038668 (diff) | |
download | bcm5719-llvm-99e5b2ff9df5ca4c7fe13b63f60d953058cd9ca3.tar.gz bcm5719-llvm-99e5b2ff9df5ca4c7fe13b63f60d953058cd9ca3.zip |
clang-format: fix spacing in `operator const char*()`
Summary:
Revision a75f8d98d7ac9e557b238a229a9a2647c71feed1 fixed spacing for operators,
but caused the const and non-const versions to diverge:
```
// With Style.PointerAlignment = FormatStyle::PAS_Left:
struct A {
operator char*() { return ""; }
operator const char *() const { return ""; }
};
```
The code was checking if the type specifier was directly preceded by `operator`.
However there could be comments and `const/volatile` in between.
Reviewers: mprobst
Reviewed By: mprobst
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D72911
(cherry picked from commit 33463cfba2be7c8d6c08e666123cc34f114a1f3e)
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index c47e2e9a116..a5a26b5c1e8 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -15008,6 +15008,9 @@ TEST_F(FormatTest, OperatorSpacing) { Style.PointerAlignment = FormatStyle::PAS_Left; verifyFormat("Foo::operator*();", Style); verifyFormat("Foo::operator void*();", Style); + verifyFormat("Foo::operator/*comment*/ void*();", Style); + verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style); + verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style); verifyFormat("Foo::operator()(void*);", Style); verifyFormat("Foo::operator*(void*);", Style); verifyFormat("Foo::operator*();", Style); @@ -15015,6 +15018,9 @@ TEST_F(FormatTest, OperatorSpacing) { verifyFormat("Foo::operator&();", Style); verifyFormat("Foo::operator void&();", Style); + verifyFormat("Foo::operator/*comment*/ void&();", Style); + verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style); + verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style); verifyFormat("Foo::operator()(void&);", Style); verifyFormat("Foo::operator&(void&);", Style); verifyFormat("Foo::operator&();", Style); @@ -15022,6 +15028,9 @@ TEST_F(FormatTest, OperatorSpacing) { verifyFormat("Foo::operator&&();", Style); verifyFormat("Foo::operator void&&();", Style); + verifyFormat("Foo::operator/*comment*/ void&&();", Style); + verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style); + verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style); verifyFormat("Foo::operator()(void&&);", Style); verifyFormat("Foo::operator&&(void&&);", Style); verifyFormat("Foo::operator&&();", Style); |