Changeset View
Changeset View
Standalone View
Standalone View
clang/unittests/Format/FormatTest.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 6,273 Lines • ▼ Show 20 Lines | verifyFormat("void\n" | ||||
"A::operator void &() {}\n" | "A::operator void &() {}\n" | ||||
"void\n" | "void\n" | ||||
"A::operator void &&() {}\n" | "A::operator void &&() {}\n" | ||||
"void\n" | "void\n" | ||||
"A::operator char *() {}\n" | "A::operator char *() {}\n" | ||||
"void\n" | "void\n" | ||||
"A::operator[]() {}\n" | "A::operator[]() {}\n" | ||||
"void\n" | "void\n" | ||||
"A::operator!() {}\n", | "A::operator!() {}\n" | ||||
"void\n" | |||||
"A::operator**() {}\n" | |||||
"void\n" | |||||
"A::operator<Foo> *() {}\n" | |||||
"void\n" | |||||
"A::operator<Foo> **() {}\n" | |||||
"void\n" | |||||
"A::operator<Foo> &() {}\n" | |||||
"void\n" | |||||
"A::operator void **() {}\n", | |||||
Style); | Style); | ||||
verifyFormat("constexpr auto\n" | verifyFormat("constexpr auto\n" | ||||
"operator()() const -> reference {}\n" | "operator()() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator>>() const -> reference {}\n" | "operator>>() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator+() const -> reference {}\n" | "operator+() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator*() const -> reference {}\n" | "operator*() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator->() const -> reference {}\n" | "operator->() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator++() const -> reference {}\n" | "operator++() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator void *() const -> reference {}\n" | "operator void *() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator void **() const -> reference {}\n" | |||||
"constexpr auto\n" | |||||
"operator void *() const -> reference {}\n" | |||||
"constexpr auto\n" | |||||
"operator void &() const -> reference {}\n" | "operator void &() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator void &&() const -> reference {}\n" | "operator void &&() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator char *() const -> reference {}\n" | "operator char *() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
"operator!() const -> reference {}\n" | "operator!() const -> reference {}\n" | ||||
"constexpr auto\n" | "constexpr auto\n" | ||||
▲ Show 20 Lines • Show All 9,316 Lines • ▼ Show 20 Lines | verifyFormat("#if defined(while)\n" | ||||
"#endif // while"); | "#endif // while"); | ||||
} | } | ||||
TEST_F(FormatTest, OperatorSpacing) { | TEST_F(FormatTest, OperatorSpacing) { | ||||
FormatStyle Style = getLLVMStyle(); | FormatStyle Style = getLLVMStyle(); | ||||
Style.PointerAlignment = FormatStyle::PAS_Right; | Style.PointerAlignment = FormatStyle::PAS_Right; | ||||
verifyFormat("Foo::operator*();", Style); | verifyFormat("Foo::operator*();", Style); | ||||
verifyFormat("Foo::operator void *();", Style); | verifyFormat("Foo::operator void *();", Style); | ||||
verifyFormat("Foo::operator void **();", Style); | |||||
verifyFormat("Foo::operator()(void *);", Style); | verifyFormat("Foo::operator()(void *);", Style); | ||||
verifyFormat("Foo::operator*(void *);", Style); | verifyFormat("Foo::operator*(void *);", Style); | ||||
verifyFormat("Foo::operator*();", Style); | verifyFormat("Foo::operator*();", Style); | ||||
verifyFormat("Foo::operator**();", Style); | |||||
verifyFormat("Foo::operator&();", Style); | |||||
verifyFormat("Foo::operator<int> *();", Style); | |||||
verifyFormat("Foo::operator<Foo> *();", Style); | |||||
verifyFormat("Foo::operator<int> **();", Style); | |||||
verifyFormat("Foo::operator<Foo> **();", Style); | |||||
verifyFormat("Foo::operator<int> &();", Style); | |||||
verifyFormat("Foo::operator<Foo> &();", Style); | |||||
verifyFormat("Foo::operator<int> &&();", Style); | |||||
verifyFormat("Foo::operator<Foo> &&();", Style); | |||||
verifyFormat("operator*(int (*)(), class Foo);", Style); | verifyFormat("operator*(int (*)(), class Foo);", Style); | ||||
verifyFormat("Foo::operator&();", Style); | verifyFormat("Foo::operator&();", Style); | ||||
verifyFormat("Foo::operator void &();", Style); | verifyFormat("Foo::operator void &();", Style); | ||||
verifyFormat("Foo::operator()(void &);", Style); | verifyFormat("Foo::operator()(void &);", Style); | ||||
verifyFormat("Foo::operator&(void &);", Style); | verifyFormat("Foo::operator&(void &);", Style); | ||||
verifyFormat("Foo::operator&();", 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); | ||||
verifyFormat("Foo::operator**();", Style); | |||||
verifyFormat("Foo::operator void &&();", Style); | verifyFormat("Foo::operator void &&();", Style); | ||||
verifyFormat("Foo::operator()(void &&);", Style); | verifyFormat("Foo::operator()(void &&);", Style); | ||||
verifyFormat("Foo::operator&&(void &&);", Style); | verifyFormat("Foo::operator&&(void &&);", Style); | ||||
verifyFormat("Foo::operator&&();", 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); | |||||
verifyFormat("operator void **()", Style); | |||||
verifyFormat("operator const FooRight<Object> &()", Style); | |||||
verifyFormat("operator const FooRight<Object> *()", Style); | |||||
verifyFormat("operator const FooRight<Object> **()", Style); | |||||
Style.PointerAlignment = FormatStyle::PAS_Left; | Style.PointerAlignment = FormatStyle::PAS_Left; | ||||
verifyFormat("Foo::operator*();", Style); | verifyFormat("Foo::operator*();", Style); | ||||
verifyFormat("Foo::operator**();", Style); | |||||
verifyFormat("Foo::operator void*();", Style); | verifyFormat("Foo::operator void*();", Style); | ||||
verifyFormat("Foo::operator void**();", Style); | |||||
verifyFormat("Foo::operator/*comment*/ void*();", Style); | verifyFormat("Foo::operator/*comment*/ void*();", Style); | ||||
verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style); | verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style); | ||||
verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style); | verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style); | ||||
verifyFormat("Foo::operator()(void*);", Style); | verifyFormat("Foo::operator()(void*);", Style); | ||||
verifyFormat("Foo::operator*(void*);", Style); | verifyFormat("Foo::operator*(void*);", Style); | ||||
verifyFormat("Foo::operator*();", Style); | verifyFormat("Foo::operator*();", Style); | ||||
verifyFormat("Foo::operator<int>*();", Style); | |||||
verifyFormat("Foo::operator<Foo>*();", Style); | |||||
verifyFormat("Foo::operator<int>**();", Style); | |||||
verifyFormat("Foo::operator<Foo>**();", Style); | |||||
verifyFormat("Foo::operator<int>&();", Style); | |||||
verifyFormat("Foo::operator<Foo>&();", Style); | |||||
verifyFormat("Foo::operator<int>&&();", Style); | |||||
verifyFormat("Foo::operator<Foo>&&();", Style); | |||||
verifyFormat("operator*(int (*)(), class Foo);", Style); | verifyFormat("operator*(int (*)(), class Foo);", Style); | ||||
verifyFormat("Foo::operator&();", Style); | verifyFormat("Foo::operator&();", Style); | ||||
verifyFormat("Foo::operator void&();", Style); | verifyFormat("Foo::operator void&();", Style); | ||||
verifyFormat("Foo::operator/*comment*/ void&();", Style); | verifyFormat("Foo::operator/*comment*/ void&();", Style); | ||||
verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style); | verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style); | ||||
verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style); | verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style); | ||||
verifyFormat("Foo::operator()(void&);", Style); | verifyFormat("Foo::operator()(void&);", Style); | ||||
verifyFormat("Foo::operator&(void&);", Style); | verifyFormat("Foo::operator&(void&);", Style); | ||||
verifyFormat("Foo::operator&();", 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); | ||||
verifyFormat("Foo::operator void&&();", Style); | verifyFormat("Foo::operator void&&();", Style); | ||||
verifyFormat("Foo::operator/*comment*/ void&&();", Style); | verifyFormat("Foo::operator/*comment*/ void&&();", Style); | ||||
verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style); | verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style); | ||||
verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style); | verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style); | ||||
verifyFormat("Foo::operator()(void&&);", Style); | verifyFormat("Foo::operator()(void&&);", Style); | ||||
verifyFormat("Foo::operator&&(void&&);", Style); | verifyFormat("Foo::operator&&(void&&);", Style); | ||||
verifyFormat("Foo::operator&&();", 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); | |||||
verifyFormat("operator void**()", Style); | |||||
verifyFormat("operator const FooLeft<Object>&()", Style); | |||||
verifyFormat("operator const FooLeft<Object>*()", Style); | |||||
verifyFormat("operator const FooLeft<Object>**()", Style); | |||||
// PR45107 | // PR45107 | ||||
verifyFormat("operator Vector<String>&();", Style); | verifyFormat("operator Vector<String>&();", Style); | ||||
verifyFormat("operator const Vector<String>&();", Style); | |||||
verifyFormat("operator foo::Bar*();", Style); | verifyFormat("operator foo::Bar*();", Style); | ||||
verifyFormat("operator const Foo<X>::Bar<Y>*();", Style); | verifyFormat("operator const Foo<X>::Bar<Y>*();", Style); | ||||
verifyFormat("operator/*a*/ const /*b*/ Foo /*c*/<X> /*d*/ ::Bar<Y>*();", | verifyFormat("operator/*a*/ const /*b*/ Foo /*c*/<X> /*d*/ ::Bar<Y>*();", | ||||
Style); | Style); | ||||
Style.PointerAlignment = FormatStyle::PAS_Middle; | Style.PointerAlignment = FormatStyle::PAS_Middle; | ||||
verifyFormat("Foo::operator*();", Style); | verifyFormat("Foo::operator*();", Style); | ||||
verifyFormat("Foo::operator void *();", Style); | verifyFormat("Foo::operator void *();", Style); | ||||
Show All 23 Lines |