r221823 - [Objective-C++ IRGen] do not generate .cxx_construct
Fariborz Jahanian
fjahanian at apple.com
Wed Nov 12 14:37:44 PST 2014
Author: fjahanian
Date: Wed Nov 12 16:37:43 2014
New Revision: 221823
URL: http://llvm.org/viewvc/llvm-project?rev=221823&view=rev
Log:
[Objective-C++ IRGen] do not generate .cxx_construct
for class that contains trivially-constructible struct ivar.
rdar://18950072
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenObjCXX/arc-cxx11-member-init.mm
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=221823&r1=221822&r2=221823&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Nov 12 16:37:43 2014
@@ -3005,6 +3005,19 @@ static bool needsDestructMethod(ObjCImpl
return false;
}
+static bool AllTrivialInitializers(CodeGenModule &CGM,
+ ObjCImplementationDecl *D) {
+ CodeGenFunction CGF(CGM);
+ for (ObjCImplementationDecl::init_iterator B = D->init_begin(),
+ E = D->init_end(); B != E; ++B) {
+ CXXCtorInitializer *CtorInitExp = *B;
+ Expr *Init = CtorInitExp->getInit();
+ if (!CGF.isTrivialInitializer(Init))
+ return false;
+ }
+ return true;
+}
+
/// EmitObjCIvarInitializations - Emit information for ivar initialization
/// for an implementation.
void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) {
@@ -3025,7 +3038,8 @@ void CodeGenModule::EmitObjCIvarInitiali
// If the implementation doesn't have any ivar initializers, we don't need
// a .cxx_construct.
- if (D->getNumIvarInitializers() == 0)
+ if (D->getNumIvarInitializers() == 0 ||
+ AllTrivialInitializers(*this, D))
return;
IdentifierInfo *II = &getContext().Idents.get(".cxx_construct");
Modified: cfe/trunk/test/CodeGenObjCXX/arc-cxx11-member-init.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-cxx11-member-init.mm?rev=221823&r1=221822&r2=221823&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/arc-cxx11-member-init.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/arc-cxx11-member-init.mm Wed Nov 12 16:37:43 2014
@@ -30,3 +30,16 @@ class XClipboardDataSet
// CHECK: [[THREE:%.*]] = bitcast i8* [[CALL]] to [[T:%.*]]*
// CHECK: store [[T]]* [[THREE]], [[T]]** [[mClipData]], align 8
+// rdar://18950072
+struct Butt { };
+
+__attribute__((objc_root_class))
+ at interface Foo {
+ Butt x;
+ Butt y;
+ Butt z;
+}
+ at end
+ at implementation Foo
+ at end
+// CHECK-NOTE: define internal i8* @"\01-[Foo .cxx_construct
More information about the cfe-commits
mailing list