From 7c2be9f48e0b4f498e50ea4f5df00aff8a105c64 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 13 Mar 2014 10:11:17 +0000 Subject: [PATCH] clang-format: Prevent ObjC code from confusing the braced-init detection This was leading to bad formatting, e.g.: Before: f(^{ @autoreleasepool { if (a) { g(); } } }); After: f(^{ @autoreleasepool { if (a) { g(); } } }); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203777 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 1 + unittests/Format/FormatTest.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index daf185be51..a3087ed984 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -357,6 +357,7 @@ void UnwrappedLineParser::calculateBraceTypes() { LBraceStack.pop_back(); } break; + case tok::at: case tok::semi: case tok::kw_if: case tok::kw_while: diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 44e8bf849d..5d4c1172c1 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -8062,6 +8062,14 @@ TEST_F(FormatTest, FormatsBlocks) { " // ...\n" " int i;\n" " }];"); + + verifyFormat("f(^{\n" + " @autoreleasepool {\n" + " if (a) {\n" + " g();\n" + " }\n" + " }\n" + "});"); } TEST_F(FormatTest, SupportsCRLF) { -- 2.40.0