Skip to content

Commit dbc3ea4

Browse files
committed
Address review requests
1 parent 54b8f88 commit dbc3ea4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4006,9 +4006,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
40064006
const auto AddSpace = [&](FormatStyle::SpacesInParensCustomStyle Option) {
40074007
if (Option == FormatStyle::SIPCS_Always)
40084008
return true;
4009-
if (Option == FormatStyle::SIPCS_NonConsecutive) {
4010-
if (NotConsecutiveParens(LeftParen, RightParen))
4011-
return true;
4009+
if (Option == FormatStyle::SIPCS_NonConsecutive &&
4010+
NotConsecutiveParens(LeftParen, RightParen)) {
4011+
return true;
40124012
}
40134013
return false;
40144014
};

clang/unittests/Format/FormatTest.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17078,22 +17078,24 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1707817078
verifyFormat("SomeType *__attribute__( ( attr ) ) *a = NULL;", Spaces);
1707917079
verifyFormat("void __attribute__( ( naked ) ) foo(int bar)", Spaces);
1708017080
verifyFormat("void f() __attribute__( ( asdf ) );", Spaces);
17081+
1708117082
Spaces.SpacesInParensOptions.InAttributeSpecifiers =
1708217083
FormatStyle::SIPCS_NonConsecutive;
1708317084
verifyFormat("SomeType *__attribute__(( attr )) *a = NULL;", Spaces);
1708417085
verifyFormat("void __attribute__(( naked )) foo(int bar)", Spaces);
1708517086
verifyFormat("void f() __attribute__(( asdf ));", Spaces);
17086-
Spaces.SpacesInParensOptions.InAttributeSpecifiers = FormatStyle::SIPCS_Never;
1708717087

1708817088
Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
1708917089
Spaces.SpacesInParensOptions = {};
1709017090
Spaces.SpacesInParensOptions.InCStyleCasts = FormatStyle::SIPCS_Always;
1709117091
verifyFormat("x = ( int32 )y;", Spaces);
1709217092
verifyFormat("y = (( int (*)(int) )foo)(x);", Spaces);
17093+
1709317094
Spaces.SpacesInParensOptions.InCStyleCasts =
1709417095
FormatStyle::SIPCS_NonConsecutive;
1709517096
verifyFormat("x = ( int32 )y;", Spaces);
1709617097
verifyFormat("y = ((int (*)(int))foo)(x);", Spaces);
17098+
1709717099
Spaces.SpacesInParensOptions.InCStyleCasts = FormatStyle::SIPCS_Never;
1709817100
verifyFormat("x = (int32)y;", Spaces);
1709917101
verifyFormat("y = ((int (*)(int))foo)(x);", Spaces);
@@ -17133,6 +17135,7 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1713317135
" break;\n"
1713417136
"}",
1713517137
Spaces);
17138+
1713617139
Spaces.SpacesInParensOptions.InConditionalStatements =
1713717140
FormatStyle::SIPCS_NonConsecutive;
1713817141
verifyFormat("while ((bool)1)\n"
@@ -17166,6 +17169,7 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1716617169
" break;\n"
1716717170
"}",
1716817171
Spaces);
17172+
1716917173
Spaces.SpacesInParensOptions.InConditionalStatements =
1717017174
FormatStyle::SIPCS_Never;
1717117175
verifyFormat("while ((bool)1)\n"
@@ -17208,12 +17212,14 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1720817212
verifyFormat("decltype( ( foo() ) ) a = foo();", Spaces);
1720917213
verifyFormat("decltype( ( bar( 10 ) ) ) a = bar( 11 );", Spaces);
1721017214
verifyFormat("x = foo( ( a * ( b - c ) ) );", Spaces);
17215+
1721117216
Spaces.SpacesInParensOptions.Other = FormatStyle::SIPCS_NonConsecutive;
1721217217
verifyFormat("decltype( x ) y = 42;", Spaces);
1721317218
verifyFormat("decltype(( x )) y = z;", Spaces);
1721417219
verifyFormat("decltype((foo())) a = foo();", Spaces);
1721517220
verifyFormat("decltype((bar( 10 ))) a = bar( 11 );", Spaces);
1721617221
verifyFormat("x = foo((a * ( b - c )));", Spaces);
17222+
1721717223
Spaces.SpacesInParensOptions.Other = FormatStyle::SIPCS_Never;
1721817224
verifyFormat("decltype(x) y = 42;", Spaces);
1721917225
verifyFormat("decltype((x)) y = z;", Spaces);

0 commit comments

Comments
 (0)