[CodeGen][ObjC] Do not call objc_storeStrong when initializing a
authorAkira Hatanaka <ahatanaka@apple.com>
Tue, 18 Oct 2016 19:05:41 +0000 (19:05 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Tue, 18 Oct 2016 19:05:41 +0000 (19:05 +0000)
commit642f799b0dd907bf96ea20eb2a0ca94932605ca3
tree17d3e1b4ff9d94e048693b8019c05e78a7d0503a
parent1e425c9f24f6617b2bd3ab550d4df42dcff8d57d
[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
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGObjC.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGenObjCXX/arc-constexpr.mm [new file with mode: 0644]