forked from OSchip/llvm-project
clang-format: Fix bad line break with pointers to members.
Before: void f() { (a->* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(aaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb); } After: void f() { (a->*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)( aaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb); } Also add missing test case. llvm-svn: 186583
This commit is contained in:
parent
be0474c047
commit
998cabcff4
|
@ -1267,7 +1267,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
|
|||
Left.Previous->is(tok::kw___attribute))
|
||||
return false;
|
||||
if (Left.is(tok::l_paren) && (Left.Previous->Type == TT_BinaryOperator ||
|
||||
Left.Previous->is(tok::r_paren)))
|
||||
Left.Previous->Type == TT_CastRParen))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -3335,6 +3335,10 @@ TEST_F(FormatTest, UnderstandsPointersToMembers) {
|
|||
" ((*a).*f)();\n"
|
||||
" a.*x;\n"
|
||||
"}");
|
||||
verifyFormat("void f() {\n"
|
||||
" (a->*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(\n"
|
||||
" aaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);\n"
|
||||
"}");
|
||||
FormatStyle Style = getLLVMStyle();
|
||||
Style.PointerBindsToType = true;
|
||||
verifyFormat("typedef bool* (Class::*Member)() const;", Style);
|
||||
|
@ -3633,6 +3637,11 @@ TEST_F(FormatTest, FormatsCasts) {
|
|||
verifyFormat("my_int a = (my_int)++ a;");
|
||||
verifyFormat("my_int a = (my_int) + 2;");
|
||||
|
||||
// Don't break after a cast's
|
||||
verifyFormat("int aaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
|
||||
" (aaaaaaaaaaaaaaaaaaaaaaaaaa *)(aaaaaaaaaaaaaaaaaaaaaa +\n"
|
||||
" bbbbbbbbbbbbbbbbbbbbbb);");
|
||||
|
||||
// These are not casts.
|
||||
verifyFormat("void f(int *) {}");
|
||||
verifyFormat("f(foo)->b;");
|
||||
|
|
Loading…
Reference in New Issue