diff options
author | Daniel Jasper <djasper@google.com> | 2013-07-09 14:36:48 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-07-09 14:36:48 +0000 |
commit | 6cdec7cf0558797ece82be6e7a1ca76791cf2672 (patch) | |
tree | c3d0f0e26d13d0af344f795a87ec461e82234356 /clang/unittests/Format/FormatTest.cpp | |
parent | 8115e1da91584ff2edd0e1c1bd0310cc4601d177 (diff) | |
download | bcm5719-llvm-6cdec7cf0558797ece82be6e7a1ca76791cf2672.tar.gz bcm5719-llvm-6cdec7cf0558797ece82be6e7a1ca76791cf2672.zip |
Initial support for formatting trailing return types.
This fixes llvm.org/PR15170.
For now, the basic formatting rules are (based on the C++11 standard):
* Surround the "->" with spaces.
* Break before "->".
Also fix typo.
llvm-svn: 185938
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index dda16c52494..0192a0718b3 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2465,6 +2465,16 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) { " const SomeLooooooooogType &a, const SomeLooooooooogType &b);"); } +TEST_F(FormatTest, TrailingReturnType) { + verifyFormat("auto foo() -> int;\n"); + verifyFormat("struct S {\n" + " auto bar() const -> int;\n" + "};"); + verifyFormat("template <size_t Order, typename T>\n" + "auto load_img(const std::string &filename)\n" + " -> alias::tensor<Order, T, mem::tag::cpu> {}"); +} + TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) { verifyFormat("void someLongFunction(\n" " int someLongParameter) const {}", |