This revision was automatically updated to reflect the committed changes. Closed by commit rL329917: [clang-format] Don't insert space between ObjC class and lightweight generic (authored by benhamilton, committed by ). Herald added a subscriber: llvm-commits.
Repository: rL LLVM https://reviews.llvm.org/D45498 Files: cfe/trunk/lib/Format/TokenAnnotator.cpp cfe/trunk/unittests/Format/FormatTestObjC.cpp Index: cfe/trunk/lib/Format/TokenAnnotator.cpp =================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -2349,9 +2349,12 @@ : 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)) Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTestObjC.cpp +++ cfe/trunk/unittests/Format/FormatTestObjC.cpp @@ -299,13 +299,13 @@ "+ (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"
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp =================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -2349,9 +2349,12 @@ : 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)) Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTestObjC.cpp +++ cfe/trunk/unittests/Format/FormatTestObjC.cpp @@ -299,13 +299,13 @@ "+ (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"
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits