diff --git a/clang/lib/Format/UnwrappedLineFormatter.h b/clang/lib/Format/UnwrappedLineFormatter.h index 35626338e38d..d7e1f263c562 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.h +++ b/clang/lib/Format/UnwrappedLineFormatter.h @@ -105,7 +105,9 @@ private: Style.Language == FormatStyle::LK_JavaScript) return 0; if (RootToken.isAccessSpecifier(false) || - RootToken.isObjCAccessSpecifier() || RootToken.is(Keywords.kw_signals)) + RootToken.isObjCAccessSpecifier() || + (RootToken.is(Keywords.kw_signals) && RootToken.Next && + RootToken.Next->is(tok::colon))) return Style.AccessModifierOffset; return 0; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 000f87ce40cd..9b5536178517 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1939,6 +1939,9 @@ TEST_F(FormatTest, UnderstandsAccessSpecifiers) { // Don't interpret 'signals' the wrong way. verifyFormat("signals.set();"); verifyFormat("for (Signals signals : f()) {\n}"); + verifyFormat("{\n" + " signals.set(); // This needs indentation.\n" + "}"); } TEST_F(FormatTest, SeparatesLogicalBlocks) {