diff options
| author | Akira Hatanaka <ahatanaka@apple.com> | 2019-03-08 04:45:37 +0000 |
|---|---|---|
| committer | Akira Hatanaka <ahatanaka@apple.com> | 2019-03-08 04:45:37 +0000 |
| commit | 1488ee4bd5418a5536856676c350c9ee64488334 (patch) | |
| tree | e8000965c5d7f7ab08b07c2600482d03b1436fd8 /clang/test/SemaObjCXX | |
| parent | 988332a54a705496b7a2e2bab5d032bf7ad2fce0 (diff) | |
| download | bcm5719-llvm-1488ee4bd5418a5536856676c350c9ee64488334.tar.gz bcm5719-llvm-1488ee4bd5418a5536856676c350c9ee64488334.zip | |
[ObjC] Emit a boxed expression as a compile-time constant if the
expression inside the parentheses is a valid UTF-8 string literal.
Previously clang emitted an expression like @("abc") as a message send
to stringWithUTF8String. This commit makes clang emit the boxed
expression as a compile-time constant instead.
This commit also has the effect of silencing the nullable-to-nonnull
conversion warning clang started emitting after r317727, which
originally motivated this commit (see https://oleb.net/2018/@keypath).
rdar://problem/42684601
Differential Revision: https://reviews.llvm.org/D58729
llvm-svn: 355662
Diffstat (limited to 'clang/test/SemaObjCXX')
| -rw-r--r-- | clang/test/SemaObjCXX/literals.mm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/SemaObjCXX/literals.mm b/clang/test/SemaObjCXX/literals.mm index 6cdd207d57d..b62ed05f159 100644 --- a/clang/test/SemaObjCXX/literals.mm +++ b/clang/test/SemaObjCXX/literals.mm @@ -50,6 +50,9 @@ void x() { + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id<NSCopying> [])keys count:(unsigned long)cnt; @end +@interface NSString +@end + template<typename T> struct ConvertibleTo { operator T(); @@ -185,3 +188,8 @@ id value; void test_dictionary_colon() { id dict = @{ key : value }; } + +void testConstExpr() { + constexpr NSString *t0 = @"abc"; + constexpr NSString *t1 = @("abc"); +} |

