diff options
author | Daniel Jasper <djasper@google.com> | 2014-03-13 10:11:17 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-03-13 10:11:17 +0000 |
commit | ac7e34e778e84ed4105d098811f67a9646549059 (patch) | |
tree | 3906fb2eabd5e3f403ae770c7d370b7da9a0b7c5 /clang | |
parent | e8bd672d31bf69c836e2b07c4df9268a755c392f (diff) | |
download | bcm5719-llvm-ac7e34e778e84ed4105d098811f67a9646549059.tar.gz bcm5719-llvm-ac7e34e778e84ed4105d098811f67a9646549059.zip |
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();
}
}
});
llvm-svn: 203777
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 1 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index daf185be519..a3087ed9845 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 44e8bf849d3..5d4c1172c13 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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) { |