diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2019-09-27 09:24:58 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2019-09-27 09:24:58 +0000 |
commit | c5343e721ba7500513ee2887bfba5395285669c1 (patch) | |
tree | 1922827dcaeea2846f0c55c12ea1540dccdb78f1 /clang/unittests/Format/FormatTest.cpp | |
parent | 0956480459f75a0ac61400cc32a524b28abbb1c1 (diff) | |
download | bcm5719-llvm-c5343e721ba7500513ee2887bfba5395285669c1.tar.gz bcm5719-llvm-c5343e721ba7500513ee2887bfba5395285669c1.zip |
[clang-format] Reference qualifiers in member templates causing extra indentation
The following code
```
struct f {
template <class T>
void bar() && noexcept {}
};
```
will be formatted to the following with LLVM style, and
`AlwaysBreakTemplateDeclarations: Yes`
```
struct f {
template <class T>
void bar() && noexcept {}
};
```
The indentation of the `void bar()` line is wrong.
Patch by Andreas Wass (AndWass)!
Differential Revision: https://reviews.llvm.org/D68072
llvm-svn: 373056
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 581d15672ba..ecb3dddfdf8 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -14373,6 +14373,41 @@ TEST_F(FormatTest, AmbersandInLamda) { verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle); } +TEST_F(FormatTest, RefQualifiedTemplateMember) { + FormatStyle AlignStyle = getLLVMStyle(); + AlignStyle.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes; + + verifyFormat("struct f {\n" + " template <class T>\n" + " int &foo() & noexcept {}\n" + "};", + AlignStyle); + + verifyFormat("struct f {\n" + " template <class T>\n" + " int &foo() && noexcept {}\n" + "};", + AlignStyle); + + verifyFormat("struct f {\n" + " template <class T>\n" + " int &foo() const & noexcept {}\n" + "};", + AlignStyle); + + verifyFormat("struct f {\n" + " template <class T>\n" + " int &foo() const & noexcept {}\n" + "};", + AlignStyle); + + verifyFormat("struct f {\n" + " template <class T>\n" + " auto foo() && noexcept -> int & {}\n" + "};", + AlignStyle); +} + } // end namespace } // end namespace format } // end namespace clang |