]> granicus.if.org Git - clang/commitdiff
Emit complete-object constructors for abstract classes in kext mode for
authorJohn McCall <rjmccall@apple.com>
Mon, 16 May 2011 23:34:46 +0000 (23:34 +0000)
committerJohn McCall <rjmccall@apple.com>
Mon, 16 May 2011 23:34:46 +0000 (23:34 +0000)
reasons that honestly really, really need to be looked into.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131434 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
test/CodeGenCXX/apple-kext-symbols.cpp [new file with mode: 0644]

index f6fc202eaae230baa9984c728775ef9cd300e4ce..09e0aa63b6d0531aa9e861c031926751f26940bd 100644 (file)
@@ -176,8 +176,9 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
 void CodeGenModule::EmitCXXConstructors(const CXXConstructorDecl *D) {
   // The constructor used for constructing this as a complete class;
   // constucts the virtual bases, then calls the base constructor.
-  if (!D->getParent()->isAbstract()) {
+  if (!D->getParent()->isAbstract() || getLangOptions().AppleKext) {
     // We don't need to emit the complete ctor if the class is abstract.
+    // But kexts somehow manage to violate this assumption.
     EmitGlobal(GlobalDecl(D, Ctor_Complete));
   }
 
diff --git a/test/CodeGenCXX/apple-kext-symbols.cpp b/test/CodeGenCXX/apple-kext-symbols.cpp
new file mode 100644 (file)
index 0000000..f9aeafc
--- /dev/null
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -o - %s | FileCheck %s
+
+// rdar://problem/9429976
+namespace test0 {
+  struct A {
+    A();
+    virtual ~A();
+    virtual void foo() = 0;
+  };
+
+  // CHECK: define void @_ZN5test01AC1Ev(
+  // CHECK: define void @_ZN5test01AC2Ev(
+  A::A() {}
+
+  // CHECK: define void @_ZN5test01AD0Ev(
+  // CHECK: define void @_ZN5test01AD1Ev(
+  // CHECK: define void @_ZN5test01AD2Ev(
+  A::~A() {}
+}
+