r236630 - clang-format: Don't indent 'signals' as access specifier if it isn't one
Daniel Jasper
djasper at google.com
Wed May 6 12:21:24 PDT 2015
Author: djasper
Date: Wed May 6 14:21:23 2015
New Revision: 236630
URL: http://llvm.org/viewvc/llvm-project?rev=236630&view=rev
Log:
clang-format: Don't indent 'signals' as access specifier if it isn't one
Before:
{
signals.set(0);
}
After:
{
signals.set(0);
}
Modified:
cfe/trunk/lib/Format/UnwrappedLineFormatter.h
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineFormatter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineFormatter.h?rev=236630&r1=236629&r2=236630&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.h (original)
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.h Wed May 6 14:21:23 2015
@@ -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;
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=236630&r1=236629&r2=236630&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 6 14:21:23 2015
@@ -1939,6 +1939,9 @@ TEST_F(FormatTest, UnderstandsAccessSpec
// 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) {
More information about the cfe-commits
mailing list