[cfe-commits] r78623 - in /cfe/trunk/lib: AST/DeclCXX.cpp CodeGen/CGCXX.cpp CodeGen/CodeGenModule.cpp
Fariborz Jahanian
fjahanian at apple.com
Mon Aug 10 16:56:17 PDT 2009
Author: fjahanian
Date: Mon Aug 10 18:56:17 2009
New Revision: 78623
URL: http://llvm.org/viewvc/llvm-project?rev=78623&view=rev
Log:
Support for anonymous union in ctor's initializer and
bunch of FIXMEs for their is-gen.
Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=78623&r1=78622&r2=78623&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Aug 10 18:56:17 2009
@@ -583,7 +583,7 @@
if (Member->isBaseInitializer())
AllBaseFields[Member->getBaseClass()->getAs<RecordType>()] = Member;
else
- AllBaseFields[Member->getMember()] = Member;
+ AllBaseFields[Member->getMember()] = Member;
}
// Push virtual bases before others.
@@ -635,7 +635,23 @@
// non-static data members.
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
E = ClassDecl->field_end(); Field != E; ++Field) {
- if (CXXBaseOrMemberInitializer *Value = AllBaseFields.lookup(*Field)) {
+ if ((*Field)->isAnonymousStructOrUnion()) {
+ if (const RecordType *FieldClassType =
+ Field->getType()->getAs<RecordType>()) {
+ CXXRecordDecl *FieldClassDecl
+ = cast<CXXRecordDecl>(FieldClassType->getDecl());
+ for(RecordDecl::field_iterator FA = FieldClassDecl->field_begin(),
+ EA = FieldClassDecl->field_end(); FA != EA; FA++) {
+ if (CXXBaseOrMemberInitializer *Value = AllBaseFields.lookup(*FA)) {
+ AllToInit.push_back(Value);
+ break;
+ }
+ }
+ }
+ continue;
+ }
+ if (CXXBaseOrMemberInitializer *Value =
+ AllBaseFields.lookup(*Field)) {
AllToInit.push_back(Value);
continue;
}
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=78623&r1=78622&r2=78623&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Aug 10 18:56:17 2009
@@ -855,7 +855,8 @@
// FIXME. How about copying arrays!
assert(!getContext().getAsArrayType(FieldType) &&
"FIXME. Copying arrays NYI");
-
+ assert(!Field->isAnonymousStructOrUnion() &&
+ "FIXME. anonymous data member NYI in copy constructor synthesis");
if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
@@ -904,7 +905,12 @@
QualType FieldType = getContext().getCanonicalType((Field)->getType());
assert(!getContext().getAsArrayType(FieldType)
&& "FIXME. Field arrays initialization unsupported");
-
+ DeclContext *Ctx = Field->getDeclContext();
+ RecordDecl *Record = cast<RecordDecl>(Ctx);
+ assert(!Record->isAnonymousStructOrUnion() &&
+ "FIXME. anonymous union initializer NYI in default constructor");
+ (void)Record;
+
LoadOfThis = LoadCXXThis();
LValue LHS = EmitLValueForField(LoadOfThis, Field, false, 0);
if (FieldType->getAs<RecordType>()) {
@@ -921,10 +927,7 @@
assert(Member->getNumArgs() == 1 && "Initializer count must be 1 only");
Expr *RhsExpr = *Member->arg_begin();
llvm::Value *RHS = EmitScalarExpr(RhsExpr, true);
- if (LHS.isBitfield())
- EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, FieldType, 0);
- else
- EmitStoreThroughLValue(RValue::get(RHS), LHS, FieldType);
+ EmitStoreThroughLValue(RValue::get(RHS), LHS, FieldType);
}
}
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=78623&r1=78622&r2=78623&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Aug 10 18:56:17 2009
@@ -699,6 +699,8 @@
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
FieldEnd = ClassDecl->field_end();
Field != FieldEnd; ++Field) {
+ assert(!(*Field)->isAnonymousStructOrUnion() &&
+ "FIXME. Anonymous union NYI - DeferredCopyConstructorToEmit");
QualType FieldType = Context.getCanonicalType((*Field)->getType());
if (const ArrayType *Array = Context.getAsArrayType(FieldType))
FieldType = Array->getElementType();
More information about the cfe-commits
mailing list