diff options
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. |

