diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-09 08:36:49 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-09 08:36:49 +0000 |
commit | 886568dc24eb0a1ccf73bf32d1eafa8fd4008cc6 (patch) | |
tree | 7707b332270a9fb01ea6c2602c9fc11f385928c2 | |
parent | 9c837d05c9e6d6971900d36b1e462ed3666b7487 (diff) |
Fix ObjC block declarations.
Before: int ( ^ Block1) (int, int) = ^ (int i, int j)
After: int (^Block1) (int, int) = ^(int i, int j)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171959 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Format/Format.cpp | 7 | ||||
-rw-r--r-- | test/Index/comment-c-decls.c | 4 | ||||
-rw-r--r-- | test/Index/format-comment-cdecls.c | 4 | ||||
-rw-r--r-- | unittests/Format/FormatTest.cpp | 5 |
4 files changed, 13 insertions, 7 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index e8c6210fae..16e8c2d6c5 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -846,8 +846,9 @@ private: if (Current.Type == TT_Unknown) { if (Current.is(tok::star) || Current.is(tok::amp)) { Current.Type = determineStarAmpUsage(Current, IsRHS); - } else if (Current.is(tok::minus) || Current.is(tok::plus)) { - Current.Type = determinePlusMinusUsage(Current); + } else if (Current.is(tok::minus) || Current.is(tok::plus) || + Current.is(tok::caret)) { + Current.Type = determinePlusMinusCaretUsage(Current); } else if (Current.is(tok::minusminus) || Current.is(tok::plusplus)) { Current.Type = determineIncrementUsage(Current); } else if (Current.is(tok::exclaim)) { @@ -905,7 +906,7 @@ private: return TT_PointerOrReference; } - TokenType determinePlusMinusUsage(const AnnotatedToken &Tok) { + TokenType determinePlusMinusCaretUsage(const AnnotatedToken &Tok) { // At the start of the line, +/- specific ObjectiveC method declarations. if (Tok.Parent == NULL) return TT_ObjCMethodSpecifier; diff --git a/test/Index/comment-c-decls.c b/test/Index/comment-c-decls.c index be45ee205f..f6d3feec81 100644 --- a/test/Index/comment-c-decls.c +++ b/test/Index/comment-c-decls.c @@ -95,10 +95,10 @@ enum e { *\brief block declaration */ int (^Block) (int i, int j); -// CHECK: <Declaration>int ( ^ Block) (int, int)</Declaration> +// CHECK: <Declaration>int (^Block) (int, int)</Declaration> /** *\brief block declaration */ int (^Block1) (int i, int j) = ^(int i, int j) { return i + j; }; -// CHECK: <Declaration>int ( ^ Block1) (int, int) = ^ (int i, int j) {\n}</Declaration> +// CHECK: <Declaration>int (^Block1) (int, int) = ^(int i, int j) {\n}</Declaration> diff --git a/test/Index/format-comment-cdecls.c b/test/Index/format-comment-cdecls.c index b1539fe1cc..31ec95b921 100644 --- a/test/Index/format-comment-cdecls.c +++ b/test/Index/format-comment-cdecls.c @@ -90,10 +90,10 @@ enum e { *\brief block declaration */ int (^Block) (int i, int j); -// CHECK: <Declaration>int ( ^ Block) (int, int)</Declaration> +// CHECK: <Declaration>int (^Block) (int, int)</Declaration> /** *\brief block declaration */ int (^Block1) (int i, int j) = ^(int i, int j) { return i + j; }; -// CHECK: <Declaration>int ( ^ Block1) (int, int) = ^ (int i, int j) {\n}</Declaration> +// CHECK: <Declaration>int (^Block1) (int, int) = ^(int i, int j) {\n}</Declaration> diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 9bf3097a5c..2e6424dd00 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1122,6 +1122,11 @@ TEST_F(FormatTest, FormatForObjectiveCMethodDecls) { "outRange8:(NSRange) out_range8 outRange9:(NSRange) out_range9;")); } +TEST_F(FormatTest, FormatObjCBlocks) { + verifyFormat("int (^Block) (int, int);"); + verifyFormat("int (^Block1) (int, int) = ^(int i, int j)"); +} + TEST_F(FormatTest, ObjCAt) { verifyFormat("@autoreleasepool"); verifyFormat("@catch"); |