summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp9
-rw-r--r--clang/unittests/Format/FormatTestObjC.cpp4
2 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 60ebe56d072..60244924079 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2349,9 +2349,12 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
: Style.SpacesInParentheses;
if (Right.isOneOf(tok::semi, tok::comma))
return false;
- if (Right.is(tok::less) && Line.Type == LT_ObjCDecl &&
- Style.ObjCSpaceBeforeProtocolList)
- return true;
+ if (Right.is(tok::less) && Line.Type == LT_ObjCDecl) {
+ bool IsLightweightGeneric =
+ Right.MatchingParen && Right.MatchingParen->Next &&
+ Right.MatchingParen->Next->is(tok::colon);
+ return !IsLightweightGeneric && Style.ObjCSpaceBeforeProtocolList;
+ }
if (Right.is(tok::less) && Left.is(tok::kw_template))
return Style.SpaceAfterTemplateKeyword;
if (Left.isOneOf(tok::exclaim, tok::tilde))
diff --git a/clang/unittests/Format/FormatTestObjC.cpp b/clang/unittests/Format/FormatTestObjC.cpp
index ded4607334e..9c8f252143f 100644
--- a/clang/unittests/Format/FormatTestObjC.cpp
+++ b/clang/unittests/Format/FormatTestObjC.cpp
@@ -299,13 +299,13 @@ TEST_F(FormatTestObjC, FormatObjCInterface) {
"+ (id)init;\n"
"@end");
- verifyFormat("@interface Foo <Baz : Blech> : Bar <Baz, Quux> {\n"
+ verifyFormat("@interface Foo<Baz : Blech> : Bar <Baz, Quux> {\n"
" int _i;\n"
"}\n"
"+ (id)init;\n"
"@end");
- verifyFormat("@interface Foo <Bar : Baz <Blech>> : Xyzzy <Corge> {\n"
+ verifyFormat("@interface Foo<Bar : Baz <Blech>> : Xyzzy <Corge> {\n"
" int _i;\n"
"}\n"
"+ (id)init;\n"
OpenPOWER on IntegriCloud