]> granicus.if.org Git - clang/commitdiff
clang-format: Fix incorrect function annotation detection.
authorDaniel Jasper <djasper@google.com>
Wed, 6 Apr 2016 13:58:09 +0000 (13:58 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 6 Apr 2016 13:58:09 +0000 (13:58 +0000)
Before:
  MACRO(
      abc).function() // wrap
      << abc;

After:
  MACRO(abc).function() // wrap
      << abc;

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

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

index ff0b5c19ba736808762d1bae5cfc40c9b26cae13..2f3bb3a8c7b4145af1a291bcec7d06076e9ada07 100644 (file)
@@ -1002,7 +1002,8 @@ private:
         Current.Type = TT_CastRParen;
       if (Current.MatchingParen && Current.Next &&
           !Current.Next->isBinaryOperator() &&
-          !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace))
+          !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
+                                 tok::period, tok::arrow, tok::coloncolon))
         if (FormatToken *BeforeParen = Current.MatchingParen->Previous)
           if (BeforeParen->is(tok::identifier) &&
               BeforeParen->TokenText == BeforeParen->TokenText.upper() &&
index 1107718348a4741dd700f352cbd90cd30bbbac15..723e05f224dbc2f907d856e58f6f46e341b37d89 100644 (file)
@@ -3997,6 +3997,12 @@ TEST_F(FormatTest, FunctionAnnotations) {
                "                << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
   verifyFormat("TEST_F(ThisIsATestFixtureeeeeeeeeeeee,\n"
                "       ThisIsATestWithAReallyReallyReallyReallyLongName) {}");
+  verifyFormat("MACRO(abc).function() // wrap\n"
+               "    << abc;");
+  verifyFormat("MACRO(abc)->function() // wrap\n"
+               "    << abc;");
+  verifyFormat("MACRO(abc)::function() // wrap\n"
+               "    << abc;");
 }
 
 TEST_F(FormatTest, BreaksDesireably) {