diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2016-10-18 19:05:41 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2016-10-18 19:05:41 +0000 |
commit | d698b929bcbc29688d4ee13240fa299a491de623 (patch) | |
tree | 861430ba77916abcdf42084d3316c9055c449858 /test/CodeGenObjCXX | |
parent | 3a5a4d80a509bc2966a7a7a0e7978f45f66b8b1c (diff) |
[CodeGen][ObjC] Do not call objc_storeStrong when initializing a
constexpr variable.
When compiling a constexpr NSString initialized with an objective-c
string literal, CodeGen emits objc_storeStrong on an uninitialized
alloca, which causes a crash.
This patch folds the code in EmitScalarInit into EmitStoreThroughLValue
and fixes the crash by calling objc_retain on the string instead of
using objc_storeStrong.
rdar://problem/28562009
Differential Revision: https://reviews.llvm.org/D25547
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284516 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenObjCXX')
-rw-r--r-- | test/CodeGenObjCXX/arc-constexpr.mm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/CodeGenObjCXX/arc-constexpr.mm b/test/CodeGenObjCXX/arc-constexpr.mm new file mode 100644 index 0000000000..786e2cb8f2 --- /dev/null +++ b/test/CodeGenObjCXX/arc-constexpr.mm @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -o - -std=c++11 %s | FileCheck %s + +// CHECK: %[[TYPE:[a-z0-9]+]] = type opaque +// CHECK: @[[CFSTRING:[a-z0-9_]+]] = private global %struct.__NSConstantString_tag + +// CHECK: define void @_Z5test1v +// CHECK: %[[ALLOCA:[A-Z]+]] = alloca %[[TYPE]]* +// CHECK: %[[V0:[0-9]+]] = call i8* @objc_retain(i8* bitcast (%struct.__NSConstantString_tag* @[[CFSTRING]] +// CHECK: %[[V1:[0-9]+]] = bitcast i8* %[[V0]] to %[[TYPE]]* +// CHECK: store %[[TYPE]]* %[[V1]], %[[TYPE]]** %[[ALLOCA]] +// CHECK: %[[V2:[0-9]+]] = bitcast %[[TYPE]]** %[[ALLOCA]] +// CHECK: call void @objc_storeStrong(i8** %[[V2]], i8* null) + +@class NSString; + +void test1() { + constexpr NSString *S = @"abc"; +} |