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 | 642f799b0dd907bf96ea20eb2a0ca94932605ca3 (patch) | |
tree | 17d3e1b4ff9d94e048693b8019c05e78a7d0503a /clang/test/CodeGenObjCXX/arc-constexpr.mm | |
parent | 1e425c9f24f6617b2bd3ab550d4df42dcff8d57d (diff) | |
download | bcm5719-llvm-642f799b0dd907bf96ea20eb2a0ca94932605ca3.tar.gz bcm5719-llvm-642f799b0dd907bf96ea20eb2a0ca94932605ca3.zip |
[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
llvm-svn: 284516
Diffstat (limited to 'clang/test/CodeGenObjCXX/arc-constexpr.mm')
-rw-r--r-- | clang/test/CodeGenObjCXX/arc-constexpr.mm | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjCXX/arc-constexpr.mm b/clang/test/CodeGenObjCXX/arc-constexpr.mm new file mode 100644 index 00000000000..786e2cb8f2c --- /dev/null +++ b/clang/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"; +} |