diff options
| author | Daniel Jasper <djasper@google.com> | 2013-09-27 08:29:16 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-09-27 08:29:16 +0000 |
| commit | f3167903b84fc9f7f6350b758c6ab9f4a7b12874 (patch) | |
| tree | a6b2eff964c6d029a19eeed951fcdbad922f69d3 /clang | |
| parent | 68c880b5f9f95c1225338905ae63a5487b118f15 (diff) | |
| download | bcm5719-llvm-f3167903b84fc9f7f6350b758c6ab9f4a7b12874.tar.gz bcm5719-llvm-f3167903b84fc9f7f6350b758c6ab9f4a7b12874.zip | |
clang-format: Improve formatting of functions with multiple trailing tokens.
Before:
void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa) override
final;
After:
void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa) override final;
llvm-svn: 191494
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 5 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index e1e4f79d177..992104fe4c2 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -606,7 +606,10 @@ private: } if (Current.Type == TT_Unknown) { - if (isStartOfName(Current)) { + // Line.MightBeFunctionDecl can only be true after the parentheses of a + // function declaration have been found. In this case, 'Current' is a + // trailing token of this declaration and thus cannot be a name. + if (isStartOfName(Current) && !Line.MightBeFunctionDecl) { Contexts.back().FirstStartOfName = &Current; Current.Type = TT_StartOfName; NameFound = true; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index be2a45d1996..d54c0421fc3 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2776,6 +2776,10 @@ TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) { // function-like. verifyFormat("void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;"); + verifyFormat("void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE FINAL;"); + verifyFormat("void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaa) override final;"); // Breaking before function-like trailing annotations is fine to keep them // close to their arguments. |

