]> granicus.if.org Git - clang/commitdiff
[clang-format] Add more tests for Objective-C 2.0 generic alignment
authorBen Hamilton <benhamilton@google.com>
Tue, 6 Feb 2018 18:01:47 +0000 (18:01 +0000)
committerBen Hamilton <benhamilton@google.com>
Tue, 6 Feb 2018 18:01:47 +0000 (18:01 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324364 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTestObjC.cpp

index 00f79ad17dbd1f93299ebf75f20f482b285616ab..717ebb8a81084b3a9d5324ed66a96f6f493fb62b 100644 (file)
@@ -1211,7 +1211,6 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
     // 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);
index d9805859f66352deafc20a64242c87f4aaee067a..16a4390203c80237531f1ce570ee9288f7c78b10 100644 (file)
@@ -189,6 +189,17 @@ TEST_F(FormatTestObjC, FormatObjCAutoreleasepool) {
                "}\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"