r203777 - clang-format: Prevent ObjC code from confusing the braced-init detection
Daniel Jasper
djasper at google.com
Thu Mar 13 03:11:18 PDT 2014
Author: djasper
Date: Thu Mar 13 05:11:17 2014
New Revision: 203777
URL: http://llvm.org/viewvc/llvm-project?rev=203777&view=rev
Log:
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();
}
}
});
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=203777&r1=203776&r2=203777&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Mar 13 05:11:17 2014
@@ -357,6 +357,7 @@ void UnwrappedLineParser::calculateBrace
LBraceStack.pop_back();
}
break;
+ case tok::at:
case tok::semi:
case tok::kw_if:
case tok::kw_while:
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=203777&r1=203776&r2=203777&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Mar 13 05:11:17 2014
@@ -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) {
More information about the cfe-commits
mailing list