From: Daniel Jasper Date: Wed, 6 Apr 2016 13:58:09 +0000 (+0000) Subject: clang-format: Fix incorrect function annotation detection. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80197c36b2df22b4605c7621c6dcdd5e5fbf7bff;p=clang clang-format: Fix incorrect function annotation detection. 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 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index ff0b5c19ba..2f3bb3a8c7 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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() && diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 1107718348..723e05f224 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) {