[cfe-commits] r90840 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenCXX/copy-constructor-synthesis-2.cpp
Eli Friedman
eli.friedman at gmail.com
Mon Dec 7 22:46:18 PST 2009
Author: efriedma
Date: Tue Dec 8 00:46:18 2009
New Revision: 90840
URL: http://llvm.org/viewvc/llvm-project?rev=90840&view=rev
Log:
Fix for PR5707: make sure implicit copy constructors initialize the vtable
pointer.
Added:
cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=90840&r1=90839&r2=90840&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Tue Dec 8 00:46:18 2009
@@ -1572,6 +1572,8 @@
EmitAggregateCopy(LHS.getAddress(), RHS.getAddress(), Field->getType());
}
}
+
+ InitializeVtablePtrs(ClassDecl);
FinishFunction();
}
@@ -1812,6 +1814,10 @@
PopCXXTemporary();
}
+ InitializeVtablePtr(ClassDecl);
+}
+
+void CodeGenFunction::InitializeVtablePtrs(const CXXRecordDecl *ClassDecl) {
if (!ClassDecl->isDynamicClass())
return;
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=90840&r1=90839&r2=90840&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Dec 8 00:46:18 2009
@@ -468,6 +468,8 @@
void EmitCtorPrologue(const CXXConstructorDecl *CD, CXXCtorType Type);
+ void InitializeVtablePtrs(const CXXRecordDecl *ClassDecl);
+
void SynthesizeCXXCopyConstructor(const CXXConstructorDecl *Ctor,
CXXCtorType Type,
llvm::Function *Fn,
Added: cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis-2.cpp?rev=90840&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis-2.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/copy-constructor-synthesis-2.cpp Tue Dec 8 00:46:18 2009
@@ -0,0 +1,7 @@
+// RUN: clang-cc -emit-llvm -o - %s | FileCheck %s
+
+struct A { virtual void a(); };
+A x(A& y) { return y; }
+
+// CHECK: define linkonce_odr void @_ZN1AC1ERKS_(
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1A, i64 0, i64 2)
More information about the cfe-commits
mailing list