]> granicus.if.org Git - clang/commitdiff
clang-format: Improve function declaration detection.
authorDaniel Jasper <djasper@google.com>
Tue, 28 Oct 2014 17:06:04 +0000 (17:06 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 28 Oct 2014 17:06:04 +0000 (17:06 +0000)
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, ...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220801 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index 0cc37b1574348ba79f1a53ed27e040708b49ffec..ff0af5a08c5bbcbd3e57fc27f74fa8b53188f0e5 100644 (file)
@@ -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) {
index 40231adabc4b41ba54716dfb68a9eb651d15d007..37bd5178674231dc39de8f1010402799b3e75c50 100644 (file)
@@ -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"