<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [Formatter/ObjC] Formatter should not break ObjC string literals inside ObjC array literals"
   href="https://bugs.llvm.org/show_bug.cgi?id=36153">36153</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Formatter/ObjC] Formatter should not break ObjC string literals inside ObjC array literals
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Formatter
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>bhamiltoncx@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Breaking Objective-C string literals inside an NSArray raises
diag::warn_concatenated_nsarray_literal
(<a href="https://github.com/llvm-mirror/clang/blob/de3473e38c50b0bc4f6040187c3345a23819a114/lib/Sema/SemaExprObjC.cpp#L485">https://github.com/llvm-mirror/clang/blob/de3473e38c50b0bc4f6040187c3345a23819a114/lib/Sema/SemaExprObjC.cpp#L485</a>).

We either need to:

1) Work around this using a preprocessor macro (which bypasses the warning), or
2) Don't break Objective-C string literals inside NSArrays

Repro (clang-900.0.39.2, macOS 10.13.3, Xcode 9.2):

% clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

% cat test_nsarray_long_string_literal.m
#import <Foundation/Foundation.h>

int main(int argc, char **argv) {
  NSArray *myArray = @[ @"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ];
}
% clang -c test_nsarray_long_string_literal.m
% clang-format -style="{BasedOnStyle: llvm, ColumnLimit: 40}"
test_nsarray_long_string_literal.m
#import <Foundation/Foundation.h>

int main(int argc, char **argv) {
  NSArray *myArray =
      @[ @"aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
         @"aaaaaaaaa" ];
}
% clang-format -style="{BasedOnStyle: llvm, ColumnLimit: 40}"
test_nsarray_long_string_literal.m | clang -c -x objective-c -    
<stdin>:5:10: warning: concatenated NSString literal for an NSArray expression
- possibly missing a comma [-Wobjc-string-concatenation]
      @[ @"aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
         ^
1 warning generated.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>