diff options
| author | Paul Hoad <mydeveloperday@gmail.com> | 2019-04-06 10:13:04 +0000 |
|---|---|---|
| committer | Paul Hoad <mydeveloperday@gmail.com> | 2019-04-06 10:13:04 +0000 |
| commit | 1db96ac88b6d076c0cbca1e39c529f93323cf8da (patch) | |
| tree | 7517e4a0186b1ed8fe43e998f7dd157f64969290 /clang/unittests/Format/FormatTest.cpp | |
| parent | 5182302a3766b2bcb55b17e9a20b215054017c05 (diff) | |
| download | bcm5719-llvm-1db96ac88b6d076c0cbca1e39c529f93323cf8da.tar.gz bcm5719-llvm-1db96ac88b6d076c0cbca1e39c529f93323cf8da.zip | |
[clang-format] BreakAfterReturnType ignored on functions with numeric template parameters
Summary:
Addresses PR40696 - https://bugs.llvm.org/show_bug.cgi?id=40696
The BreakAfterReturnType didn't work if it had a single arguments which was a template with an integer template parameter
```
int foo(A<8> a) { return a; }
```
When run with the Mozilla style. would not break after the `int`
```
int TestFn(A<8> a)
{
return a;
}
```
This revision resolves this issue by allowing numeric constants to be considered function parameters if if seen inside `<>`
Reviewers: djasper, klimek, JonasToth, krasimir, reuk, alexfh
Reviewed By: klimek
Subscribers: cfe-commits, llvm-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59309
llvm-svn: 357837
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 7859f96a9af..110d60a5a86 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5709,6 +5709,42 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) { "}\n" "template <class T> T *f(T &c);\n", // No break here. Style); + verifyFormat("int\n" + "foo(A<bool> a)\n" + "{\n" + " return a;\n" + "}\n", + Style); + verifyFormat("int\n" + "foo(A<8> a)\n" + "{\n" + " return a;\n" + "}\n", + Style); + verifyFormat("int\n" + "foo(A<B<bool>, 8> a)\n" + "{\n" + " return a;\n" + "}\n", + Style); + verifyFormat("int\n" + "foo(A<B<8>, bool> a)\n" + "{\n" + " return a;\n" + "}\n", + Style); + verifyFormat("int\n" + "foo(A<B<bool>, bool> a)\n" + "{\n" + " return a;\n" + "}\n", + Style); + verifyFormat("int\n" + "foo(A<B<8>, 8> a)\n" + "{\n" + " return a;\n" + "}\n", + Style); } TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) { |

