From 2ad0aba610052c5262c382b428079d3e7d3e3987 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 28 Oct 2014 17:06:04 +0000 Subject: [PATCH] clang-format: Improve function declaration detection. Before: ReturnType MACRO FunctionName() {} After: ReturnType MACRO FunctionName() {} This fixes llvm.org/PR21404. I wonder what the motivation for that if-condition was. But as no test breaks, ... llvm-svn: 220801 --- clang/lib/Format/TokenAnnotator.cpp | 3 +-- clang/unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 0cc37b1..ff0af5a 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1263,8 +1263,7 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) { // function declaration. static bool isFunctionDeclarationName(const FormatToken &Current) { if (Current.Type != TT_StartOfName || - Current.NestingLevel != 0 || - Current.Previous->Type == TT_StartOfName) + Current.NestingLevel != 0) return false; const FormatToken *Next = Current.Next; for (; Next; Next = Next->Next) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 40231ad..37bd517 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5269,6 +5269,8 @@ TEST_F(FormatTest, BreaksLongDeclarations) { "LoooooooooooooooooooooooooooooooongFunctionDeclaration();"); verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType\n" "LooooooooooooooooooooooooooooooooooongFunctionDefinition() {}"); + verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType MACRO\n" + "LooooooooooooooooooooooooooooooooooongFunctionDefinition() {}"); verifyFormat("LoooooooooooooooooooooooooooooooooooooooongReturnType const\n" "LooooooooooooooooooooooooooooooooooongFunctionDefinition() {}"); verifyFormat("decltype(LoooooooooooooooooooooooooooooooooooooooongName)\n" -- 2.7.4