Fix the bug that was breaking self-host, and re-land the static ctor fixes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anders Carlsson 2010-02-05 18:38:45 +00:00
Родитель 16c4f3c7d4
Коммит 2ca4f633b2
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -675,9 +675,20 @@ public:
if (!E->getConstructor()->isTrivial())
return 0;
QualType Ty = E->getType();
// FIXME: We should not have to call getBaseElementType here.
const RecordType *RT =
CGM.getContext().getBaseElementType(Ty)->getAs<RecordType>();
const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
// If the class doesn't have a trivial destructor, we can't emit it as a
// constant expr.
if (!RD->hasTrivialDestructor())
return 0;
// Only copy and default constructors can be trivial.
QualType Ty = E->getType();
if (E->getNumArgs()) {
assert(E->getNumArgs() == 1 && "trivial ctor with > 1 argument");

Просмотреть файл

@ -9,6 +9,8 @@ struct B { B(); ~B(); };
struct C { void *field; };
struct D { ~D(); };
// CHECK: @c = global %struct.C zeroinitializer, align 8
// CHECK: call void @_ZN1AC1Ev(%struct.A* @a)
@ -23,4 +25,7 @@ B b;
// CHECK-NOT: call void @_ZN1CC1Ev(%struct.C* @c)
C c;
// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1DD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @d, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
D d;
// CHECK: define internal void @__cxx_global_initialization() {