summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp13
2 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index e9a78d8f661..bcd50a88bcd 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1902,7 +1902,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
return Line.Type == LT_ObjCDecl || Left.is(tok::semi) ||
(Style.SpaceBeforeParens != FormatStyle::SBPO_Never &&
(Left.isOneOf(tok::kw_if, tok::pp_elif, tok::kw_for, tok::kw_while,
- tok::kw_switch, tok::kw_case, TT_ForEachMacro) ||
+ tok::kw_switch, tok::kw_case, TT_ForEachMacro,
+ TT_ObjCForIn) ||
(Left.isOneOf(tok::kw_try, Keywords.kw___except, tok::kw_catch,
tok::kw_new, tok::kw_delete) &&
(!Left.Previous || Left.Previous->isNot(tok::period))))) ||
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 5f94c21f3cc..3cf181ed484 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7446,6 +7446,19 @@ TEST_F(FormatTest, ObjCSnippets) {
"@import baz;");
}
+TEST_F(FormatTest, ObjCForIn) {
+ verifyFormat("- (void)test {\n"
+ " for (NSString *n in arrayOfStrings) {\n"
+ " foo(n);\n"
+ " }\n"
+ "}");
+ verifyFormat("- (void)test {\n"
+ " for (NSString *n in (__bridge NSArray *)arrayOfStrings) {\n"
+ " foo(n);\n"
+ " }\n"
+ "}");
+}
+
TEST_F(FormatTest, ObjCLiterals) {
verifyFormat("@\"String\"");
verifyFormat("@1");
OpenPOWER on IntegriCloud