[llvm-bugs] [Bug 36153] New: [Formatter/ObjC] Formatter should not break ObjC string literals inside ObjC array literals
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 30 09:05:44 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36153
Bug ID: 36153
Summary: [Formatter/ObjC] Formatter should not break ObjC
string literals inside ObjC array literals
Product: clang
Version: trunk
Hardware: Macintosh
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: bhamiltoncx at gmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Breaking Objective-C string literals inside an NSArray raises
diag::warn_concatenated_nsarray_literal
(https://github.com/llvm-mirror/clang/blob/de3473e38c50b0bc4f6040187c3345a23819a114/lib/Sema/SemaExprObjC.cpp#L485).
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180130/74eaee6d/attachment.html>
More information about the llvm-bugs
mailing list