This fixes llvm.org/PR15179.
Before:
class ColorChooserMac : public content::ColorChooser,
public content::WebContentsObserver {
};
After:
class ColorChooserMac : public content::ColorChooser,
public content::WebContentsObserver {
};
llvm-svn: 175147
Previous.Type == TT_CtorInitializerColon) &&
getPrecedence(Previous) != prec::Assignment)
State.Stack.back().LastSpace = State.Column;
+ else if (Previous.Type == TT_InheritanceColon)
+ State.Stack.back().Indent = State.Column;
else if (Previous.ParameterCount > 1 &&
(Previous.is(tok::l_paren) || Previous.is(tok::l_square) ||
Previous.is(tok::l_brace) ||
const AnnotatedToken &Current = *State.NextToken;
assert(State.Stack.size());
+ if (Current.Type == TT_InheritanceColon)
+ State.Stack.back().AvoidBinPacking = true;
if (Current.is(tok::lessless) && State.Stack.back().FirstLessLess == 0)
State.Stack.back().FirstLessLess = State.Column;
if (Current.is(tok::question))
Contexts.back().FirstObjCSelectorName = Tok->Parent;
} else if (Contexts.back().ColonIsForRangeExpr) {
Tok->Type = TT_RangeBasedForLoopColon;
+ } else if (Contexts.size() == 1) {
+ Tok->Type = TT_InheritanceColon;
}
break;
case tok::kw_if:
if (Left.is(tok::coloncolon))
return 500;
- if (Left.Type == TT_RangeBasedForLoopColon)
+ if (Left.Type == TT_RangeBasedForLoopColon ||
+ Left.Type == TT_InheritanceColon)
return 5;
if (Right.is(tok::arrow) || Right.is(tok::period)) {
return true;
if (Right.Type == TT_ConditionalExpr || Right.is(tok::question))
return true;
- if (Left.Type == TT_RangeBasedForLoopColon)
+ if (Right.Type == TT_RangeBasedForLoopColon ||
+ Right.Type == TT_InheritanceColon)
+ return false;
+ if (Left.Type == TT_RangeBasedForLoopColon ||
+ Left.Type == TT_InheritanceColon)
return true;
if (Left.Type == TT_PointerOrReference || Left.Type == TT_TemplateCloser ||
Left.Type == TT_UnaryOperator || Left.Type == TT_ConditionalExpr ||
TT_ConditionalExpr,
TT_CtorInitializerColon,
TT_ImplicitStringLiteral,
+ TT_InheritanceColon,
TT_LineComment,
TT_ObjCArrayLiteral,
TT_ObjCBlockLParen,
TEST_F(FormatTest, FormatsDerivedClass) {
verifyFormat("class A : public B {\n};");
verifyFormat("class A : public ::B {\n};");
+
+ verifyFormat(
+ "class AAAAAAAAAAAAAAAAAAAA : public BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,\n"
+ " public CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC {\n"
+ "};\n");
+ verifyFormat("class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA :\n"
+ " public BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,\n"
+ " public CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC {\n"
+ "};\n");
+ verifyFormat(
+ "class A : public B, public C, public D, public E, public F, public G {\n"
+ "};");
+ verifyFormat("class AAAAAAAAAAAA : public B,\n"
+ " public C,\n"
+ " public D,\n"
+ " public E,\n"
+ " public F,\n"
+ " public G {\n"
+ "};");
}
TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {
" ddd);");
}
+TEST_F(FormatTest, Inheritance) {
+}
+
TEST_F(FormatTest, ConstructorInitializers) {
verifyFormat("Constructor() : Initializer(FitsOnTheLine) {}");
verifyFormat("Constructor() : Inttializer(FitsOnTheLine) {}",