diff options
author | Daniel Jasper <djasper@google.com> | 2014-08-01 13:03:05 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-08-01 13:03:05 +0000 |
commit | dcf37fbec5432495ab0f9966343ac18f8e8dff2e (patch) | |
tree | 85149797189b934ca5a13aab955431ad53c92a33 | |
parent | 4bfa0de5b07d3d104e3c14a550cf5c354ffc3739 (diff) | |
download | bcm5719-llvm-dcf37fbec5432495ab0f9966343ac18f8e8dff2e.tar.gz bcm5719-llvm-dcf37fbec5432495ab0f9966343ac18f8e8dff2e.zip |
clang-format: Add a space in ObjC protocols.
Before:
@interface Foo (HackStuff)<MyProtocol>
After:
@interface Foo (HackStuff) <MyProtocol>
llvm-svn: 214508
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 9 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 6f77ae3d29b..0d7e6bfbcb8 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1480,7 +1480,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, if (Right.isOneOf(tok::semi, tok::comma)) return false; if (Right.is(tok::less) && - (Left.is(tok::kw_template) || + (Left.isOneOf(tok::kw_template, tok::r_paren) || (Line.Type == LT_ObjCDecl && Style.ObjCSpaceBeforeProtocolList))) return true; if (Left.is(tok::arrow) || Right.is(tok::arrow)) @@ -1509,13 +1509,14 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, ((Left.Type != TT_PointerOrReference) && Left.isNot(tok::l_paren) && Style.PointerAlignment != FormatStyle::PAS_Left); if (Right.Type == TT_FunctionTypeLParen && Left.isNot(tok::l_paren) && - (Left.Type != TT_PointerOrReference || Style.PointerAlignment != FormatStyle::PAS_Right)) + (Left.Type != TT_PointerOrReference || + Style.PointerAlignment != FormatStyle::PAS_Right)) return true; if (Left.Type == TT_PointerOrReference) return Right.Tok.isLiteral() || Right.Type == TT_BlockComment || ((Right.Type != TT_PointerOrReference) && - Right.isNot(tok::l_paren) && Style.PointerAlignment != FormatStyle::PAS_Right && - Left.Previous && + Right.isNot(tok::l_paren) && + Style.PointerAlignment != FormatStyle::PAS_Right && Left.Previous && !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon)); if (Right.is(tok::star) && Left.is(tok::l_paren)) return false; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index bebd8d67d49..b175d2a2ecb 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6119,7 +6119,7 @@ TEST_F(FormatTest, FormatObjCInterface) { "+ (id)init;\n" "@end"); - verifyGoogleFormat("@interface Foo (HackStuff)<MyProtocol>\n" + verifyGoogleFormat("@interface Foo (HackStuff) <MyProtocol>\n" "+ (id)init;\n" "@end"); @@ -6161,7 +6161,7 @@ TEST_F(FormatTest, FormatObjCInterface) { FormatStyle OnePerLine = getGoogleStyle(); OnePerLine.BinPackParameters = false; - verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ()<\n" + verifyFormat("@interface aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa () <\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" |