r265540 - clang-format: Fix incorrect function annotation detection.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 6 06:58:10 PDT 2016
Author: djasper
Date: Wed Apr 6 08:58:09 2016
New Revision: 265540
URL: http://llvm.org/viewvc/llvm-project?rev=265540&view=rev
Log:
clang-format: Fix incorrect function annotation detection.
Before:
MACRO(
abc).function() // wrap
<< abc;
After:
MACRO(abc).function() // wrap
<< abc;
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Apr 6 08:58:09 2016
@@ -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() &&
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Apr 6 08:58:09 2016
@@ -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) {
More information about the cfe-commits
mailing list