From f84d646002482eca7e57cadfccfbc8599d681349 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 6 May 2015 19:21:23 +0000 Subject: [PATCH] clang-format: Don't indent 'signals' as access specifier if it isn't one Before: { signals.set(0); } After: { signals.set(0); } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236630 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineFormatter.h | 4 +++- unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Format/UnwrappedLineFormatter.h b/lib/Format/UnwrappedLineFormatter.h index 35626338e3..d7e1f263c5 100644 --- a/lib/Format/UnwrappedLineFormatter.h +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 000f87ce40..9b55361785 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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) { -- 2.40.0