summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGObjC.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2016-10-18 19:05:41 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2016-10-18 19:05:41 +0000
commit642f799b0dd907bf96ea20eb2a0ca94932605ca3 (patch)
tree17d3e1b4ff9d94e048693b8019c05e78a7d0503a /clang/lib/CodeGen/CGObjC.cpp
parent1e425c9f24f6617b2bd3ab550d4df42dcff8d57d (diff)
downloadbcm5719-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/lib/CodeGen/CGObjC.cpp')
-rw-r--r--clang/lib/CodeGen/CGObjC.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index db894ce6747..1eb340e8b16 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -1662,7 +1662,8 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
elementLValue = EmitLValue(cast<Expr>(S.getElement()));
EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue);
} else {
- EmitScalarInit(CurrentItem, elementLValue);
+ EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue,
+ /*isInit*/ true);
}
// If we do have an element variable, this assignment is the end of
OpenPOWER on IntegriCloud