diff options
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index ea03ee1c3cc..eacb389400b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4977,6 +4977,29 @@ TEST_F(FormatTest, TrailingReturnType) { verifyFormat("void f() { auto a = b->c(); }"); } +TEST_F(FormatTest, DeductionGuides) { + verifyFormat("template <class T> A(const T &, const T &) -> A<T &>;"); + verifyFormat("template <class T> explicit A(T &, T &&) -> A<T>;"); + verifyFormat("template <class... Ts> S(Ts...) -> S<Ts...>;"); + verifyFormat( + "template <class... T>\n" + "array(T &&... t) -> array<std::common_type_t<T...>, sizeof...(T)>;"); + verifyFormat("template <class T> A() -> A<decltype(p->foo<3>())>;"); + verifyFormat("template <class T> A() -> A<decltype(foo<traits<1>>)>;"); + verifyFormat("template <class T> A() -> A<sizeof(p->foo<1>)>;"); + verifyFormat("template <class T> A() -> A<(3 < 2)>;"); + verifyFormat("template <class T> A() -> A<((3) < (2))>;"); + verifyFormat("template <class T> x() -> x<1>;"); + verifyFormat("template <class T> explicit x(T &) -> x<1>;"); + + // Ensure not deduction guides. + verifyFormat("c()->f<int>();"); + verifyFormat("x()->foo<1>;"); + verifyFormat("x = p->foo<3>();"); + verifyFormat("x()->x<1>();"); + verifyFormat("x()->x<1>;"); +} + TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) { // Avoid breaking before trailing 'const' or other trailing annotations, if // they are not function-like. |