[PATCH] D11235: clang-format: Fix breaking before nested 'operator' in function declarations
Birunthan Mohanathas
birunthan at mohanathas.com
Wed Jul 15 12:07:54 PDT 2015
poiru created this revision.
poiru added a reviewer: djasper.
poiru added a subscriber: cfe-commits.
Herald added a subscriber: klimek.
http://reviews.llvm.org/D11235
Files:
lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp
Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -3707,6 +3707,11 @@
"SomeClasssssssssssssssssssssssssssssssssssssss::\n"
" bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(Cccccccccccccc cccccccccc);",
getGoogleStyle());
+ verifyFormat(
+ "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ "SomeClasssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss::\n"
+ " operator+=(Cccccccccccccc cccccccccc);",
+ getGoogleStyle());
// However, there are exceptions, if a sufficient amount of lines can be
// saved.
Index: lib/Format/ContinuationIndenter.cpp
===================================================================
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -597,7 +597,9 @@
TT_AttributeParen, TT_FunctionAnnotationRParen, TT_JavaAnnotation,
TT_LeadingJavaAnnotation))) ||
(!Style.IndentWrappedFunctionNames &&
- NextNonComment->isOneOf(tok::kw_operator, TT_FunctionDeclarationName)))
+ (NextNonComment->is(TT_FunctionDeclarationName) ||
+ (NextNonComment->is(tok::kw_operator) &&
+ !NextNonComment->Previous->is(tok::coloncolon)))))
return std::max(State.Stack.back().LastSpace, State.Stack.back().Indent);
if (NextNonComment->is(TT_SelectorName)) {
if (!State.Stack.back().ObjCSelectorNameFound) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11235.29813.patch
Type: text/x-patch
Size: 1489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150715/4fcdcbd8/attachment.bin>
More information about the cfe-commits
mailing list