From e385112444b7202cc7869825eb66efb6fed70940 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 14 Mar 2014 15:40:54 +0000 Subject: [PATCH] =?utf8?q?Objective-C++=20IRGen.=20Due=20to=20change=20to?= =?utf8?q?=20AST=20for=20initialization=20of=20c++11=E2=80=99s=20data=20me?= =?utf8?q?mbers=20by=20addition=20of=20CXXDefaultInitExpr=20node=20to=20th?= =?utf8?q?e=20initializer=20expression,=20it=20has=20broken=20treatment=20?= =?utf8?q?of=20arc=20code=20for=20such=20initializations.=20Reviewed=20by?= =?utf8?q?=20John=20McCall.=20//=20rdar://16299964?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203935 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDecl.cpp | 5 +++- test/CodeGenObjCXX/arc-cxx11-member-init.mm | 32 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/CodeGenObjCXX/arc-cxx11-member-init.mm diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index d0380a025d..1f0dd8535a 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -571,7 +571,10 @@ void CodeGenFunction::EmitScalarInit(const Expr *init, EmitStoreThroughLValue(RValue::get(value), lvalue, true); return; } - + + if (const CXXDefaultInitExpr *DIE = dyn_cast(init)) + init = DIE->getExpr(); + // If we're emitting a value with lifetime, we have to do the // initialization *before* we leave the cleanup scopes. if (const ExprWithCleanups *ewc = dyn_cast(init)) { diff --git a/test/CodeGenObjCXX/arc-cxx11-member-init.mm b/test/CodeGenObjCXX/arc-cxx11-member-init.mm new file mode 100644 index 0000000000..213e7a1b7b --- /dev/null +++ b/test/CodeGenObjCXX/arc-cxx11-member-init.mm @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -std=c++11 -emit-llvm -o - %s | FileCheck %s +// rdar://16299964 + +@interface NSObject ++ (id)new; +@end + +@interface NSMutableDictionary : NSObject +@end + +class XClipboardDataSet +{ + NSMutableDictionary* mClipData = [NSMutableDictionary new]; +}; + +@interface AppDelegate @end + +@implementation AppDelegate +- (void)applicationDidFinishLaunching +{ + XClipboardDataSet clip; +} +@end + +// CHECK: [[mClipData:%.*]] = getelementptr inbounds %class.XClipboardDataSet* +// CHECK: [[ZERO:%.*]] = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_" +// CHECK: [[ONE:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_" +// CHECK: [[TWO:%.*]] = bitcast %struct._class_t* [[ZERO]] to i8* +// CHECK: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* [[TWO]], i8* [[ONE]]) +// CHECK: [[THREE:%.*]] = bitcast i8* [[CALL]] to [[T:%.*]]* +// CHECK: store [[T]]* [[THREE]], [[T]]** [[mClipData]], align 8 + -- 2.40.0