r324364 - [clang-format] Add more tests for Objective-C 2.0 generic alignment
Ben Hamilton via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 6 10:01:47 PST 2018
Author: benhamilton
Date: Tue Feb 6 10:01:47 2018
New Revision: 324364
URL: http://llvm.org/viewvc/llvm-project?rev=324364&view=rev
Log:
[clang-format] Add more tests for Objective-C 2.0 generic alignment
Summary:
In r236412, @djasper added a comment:
// FIXME: We likely want to do this for more combinations of brackets.
// Verify that it is wanted for ObjC, too.
In D42650, @stephanemoore asked me to confirm this.
This followup to D42650 adds more tests to verify the relative
alignment behavior for Objective-C 2.0 generics passed to functions
and removes the second half of the FIXME comment.
Test Plan:
make -j12 FormatTests && \
./tools/clang/unittests/Format/FormatTests --gtest_filter=FormatTestObjC.\*
Reviewers: stephanemoore, jolesiak, djasper
Reviewed By: jolesiak
Subscribers: klimek, cfe-commits, djasper, stephanemoore, krasimir
Differential Revision: https://reviews.llvm.org/D42864
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=324364&r1=324363&r2=324364&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue Feb 6 10:01:47 2018
@@ -1211,7 +1211,6 @@ void ContinuationIndenter::moveStatePast
// void SomeFunction(vector< // break
// int> v);
// FIXME: We likely want to do this for more combinations of brackets.
- // Verify that it is wanted for ObjC, too.
if (Current.is(tok::less) && Current.ParentBracket == tok::l_paren) {
NewIndent = std::max(NewIndent, State.Stack.back().Indent);
LastSpace = std::max(LastSpace, State.Stack.back().Indent);
Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=324364&r1=324363&r2=324364&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Tue Feb 6 10:01:47 2018
@@ -189,6 +189,17 @@ TEST_F(FormatTestObjC, FormatObjCAutorel
"}\n");
}
+TEST_F(FormatTestObjC, FormatObjCGenerics) {
+ Style.ColumnLimit = 40;
+ verifyFormat("int aaaaaaaaaaaaaaaa(\n"
+ " NSArray<aaaaaaaaaaaaaaaaaa *>\n"
+ " aaaaaaaaaaaaaaaaa);\n");
+ verifyFormat("int aaaaaaaaaaaaaaaa(\n"
+ " NSArray<aaaaaaaaaaaaaaaaaaa<\n"
+ " aaaaaaaaaaaaaaaa *> *>\n"
+ " aaaaaaaaaaaaaaaaa);\n");
+}
+
TEST_F(FormatTestObjC, FormatObjCInterface) {
verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n"
"@public\n"
More information about the cfe-commits
mailing list