Skip to content

Commit e4b2d9b

Browse files
committed
Address review requests
1 parent d31a403 commit e4b2d9b

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
@@ -4005,9 +4005,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
40054005
const auto AddSpace = [&](FormatStyle::SpacesInParensCustomStyle Option) {
40064006
if (Option == FormatStyle::SIPCS_Always)
40074007
return true;
4008-
if (Option == FormatStyle::SIPCS_NonConsecutive) {
4009-
if (NotConsecutiveParens(LeftParen, RightParen))
4010-
return true;
4008+
if (Option == FormatStyle::SIPCS_NonConsecutive &&
4009+
NotConsecutiveParens(LeftParen, RightParen)) {
4010+
return true;
40114011
}
40124012
return false;
40134013
};

clang/unittests/Format/FormatTest.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17066,22 +17066,24 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1706617066
verifyFormat("SomeType *__attribute__( ( attr ) ) *a = NULL;", Spaces);
1706717067
verifyFormat("void __attribute__( ( naked ) ) foo(int bar)", Spaces);
1706817068
verifyFormat("void f() __attribute__( ( asdf ) );", Spaces);
17069+
1706917070
Spaces.SpacesInParensOptions.InAttributeSpecifiers =
1707017071
FormatStyle::SIPCS_NonConsecutive;
1707117072
verifyFormat("SomeType *__attribute__(( attr )) *a = NULL;", Spaces);
1707217073
verifyFormat("void __attribute__(( naked )) foo(int bar)", Spaces);
1707317074
verifyFormat("void f() __attribute__(( asdf ));", Spaces);
17074-
Spaces.SpacesInParensOptions.InAttributeSpecifiers = FormatStyle::SIPCS_Never;
1707517075

1707617076
Spaces.SpacesInParens = FormatStyle::SIPO_Custom;
1707717077
Spaces.SpacesInParensOptions = {};
1707817078
Spaces.SpacesInParensOptions.InCStyleCasts = FormatStyle::SIPCS_Always;
1707917079
verifyFormat("x = ( int32 )y;", Spaces);
1708017080
verifyFormat("y = (( int (*)(int) )foo)(x);", Spaces);
17081+
1708117082
Spaces.SpacesInParensOptions.InCStyleCasts =
1708217083
FormatStyle::SIPCS_NonConsecutive;
1708317084
verifyFormat("x = ( int32 )y;", Spaces);
1708417085
verifyFormat("y = ((int (*)(int))foo)(x);", Spaces);
17086+
1708517087
Spaces.SpacesInParensOptions.InCStyleCasts = FormatStyle::SIPCS_Never;
1708617088
verifyFormat("x = (int32)y;", Spaces);
1708717089
verifyFormat("y = ((int (*)(int))foo)(x);", Spaces);
@@ -17121,6 +17123,7 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1712117123
" break;\n"
1712217124
"}",
1712317125
Spaces);
17126+
1712417127
Spaces.SpacesInParensOptions.InConditionalStatements =
1712517128
FormatStyle::SIPCS_NonConsecutive;
1712617129
verifyFormat("while ((bool)1)\n"
@@ -17154,6 +17157,7 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1715417157
" break;\n"
1715517158
"}",
1715617159
Spaces);
17160+
1715717161
Spaces.SpacesInParensOptions.InConditionalStatements =
1715817162
FormatStyle::SIPCS_Never;
1715917163
verifyFormat("while ((bool)1)\n"
@@ -17196,12 +17200,14 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) {
1719617200
verifyFormat("decltype( ( foo() ) ) a = foo();", Spaces);
1719717201
verifyFormat("decltype( ( bar( 10 ) ) ) a = bar( 11 );", Spaces);
1719817202
verifyFormat("x = foo( ( a * ( b - c ) ) );", Spaces);
17203+
1719917204
Spaces.SpacesInParensOptions.Other = FormatStyle::SIPCS_NonConsecutive;
1720017205
verifyFormat("decltype( x ) y = 42;", Spaces);
1720117206
verifyFormat("decltype(( x )) y = z;", Spaces);
1720217207
verifyFormat("decltype((foo())) a = foo();", Spaces);
1720317208
verifyFormat("decltype((bar( 10 ))) a = bar( 11 );", Spaces);
1720417209
verifyFormat("x = foo((a * ( b - c )));", Spaces);
17210+
1720517211
Spaces.SpacesInParensOptions.Other = FormatStyle::SIPCS_Never;
1720617212
verifyFormat("decltype(x) y = 42;", Spaces);
1720717213
verifyFormat("decltype((x)) y = z;", Spaces);

0 commit comments

Comments
 (0)