[cfe-commits] r102842 - in /cfe/trunk/lib: CodeGen/CGClass.cpp Sema/SemaDeclCXX.cpp
Anders Carlsson
andersca at mac.com
Sat May 1 09:39:02 PDT 2010
Author: andersca
Date: Sat May 1 11:39:01 2010
New Revision: 102842
URL: http://llvm.org/viewvc/llvm-project?rev=102842&view=rev
Log:
When defining implicit copy constructors, use SetBaseOrMemberInitializers to initialize the bases.
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=102842&r1=102841&r2=102842&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Sat May 1 11:39:01 2010
@@ -692,18 +692,6 @@
llvm::Value *SrcPtr =
Builder.CreateLoad(GetAddrOfLocalVar(Args[SrcArgIndex].first));
- for (CXXRecordDecl::base_class_const_iterator Base = ClassDecl->bases_begin();
- Base != ClassDecl->bases_end(); ++Base) {
- // FIXME. copy constrution of virtual base NYI
- if (Base->isVirtual())
- continue;
-
- CXXRecordDecl *BaseClassDecl
- = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
- EmitClassMemberwiseCopy(ThisPtr, SrcPtr, ClassDecl, BaseClassDecl,
- Base->getType());
- }
-
for (CXXRecordDecl::field_iterator I = ClassDecl->field_begin(),
E = ClassDecl->field_end(); I != E; ++I) {
const FieldDecl *Field = *I;
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=102842&r1=102841&r2=102842&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat May 1 11:39:01 2010
@@ -1503,7 +1503,10 @@
SourceLocation(), ParamType, 0);
// Cast to the base class to avoid ambiguities.
- SemaRef.ImpCastExprToType(CopyCtorArg, BaseSpec->getType(),
+ QualType ArgTy =
+ SemaRef.Context.getQualifiedType(BaseSpec->getType().getUnqualifiedType(),
+ ParamType.getQualifiers());
+ SemaRef.ImpCastExprToType(CopyCtorArg, ArgTy,
CastExpr::CK_UncheckedDerivedToBase,
/*isLvalue=*/true,
CXXBaseSpecifierArray(BaseSpec));
@@ -1545,6 +1548,11 @@
FieldDecl *Field,
CXXBaseOrMemberInitializer *&CXXMemberInit) {
if (ImplicitInitKind == IIK_Copy) {
+ // FIXME: We should not return early here, but will do so until
+ // we know how to handle copy initialization of arrays.
+ CXXMemberInit = 0;
+ return false;
+
ParmVarDecl *Param = Constructor->getParamDecl(0);
QualType ParamType = Param->getType().getNonReferenceType();
@@ -4212,25 +4220,16 @@
ImplicitlyDefinedFunctionScope Scope(*this, CopyConstructor);
- // C++ [class.copy] p209
- // Before the implicitly-declared copy constructor for a class is
- // implicitly defined, all the implicitly-declared copy constructors
- // for its base class and its non-static data members shall have been
- // implicitly defined.
- for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
- Base != ClassDecl->bases_end(); ++Base) {
- CXXRecordDecl *BaseClassDecl
- = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
- if (CXXConstructorDecl *BaseCopyCtor =
- BaseClassDecl->getCopyConstructor(Context, TypeQuals)) {
- CheckDirectMemberAccess(Base->getSourceRange().getBegin(),
- BaseCopyCtor,
- PDiag(diag::err_access_copy_base)
- << Base->getType());
-
- MarkDeclarationReferenced(CurrentLocation, BaseCopyCtor);
- }
+ if (SetBaseOrMemberInitializers(CopyConstructor, 0, 0, /*AnyErrors=*/false)) {
+ Diag(CurrentLocation, diag::note_member_synthesized_at)
+ << CXXCopyConstructor << Context.getTagDeclType(ClassDecl);
+ CopyConstructor->setInvalidDecl();
+ } else {
+ CopyConstructor->setUsed();
}
+
+ // FIXME: Once SetBaseOrMemberInitializers can handle copy initialization of
+ // fields, this code below should be removed.
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
FieldEnd = ClassDecl->field_end();
Field != FieldEnd; ++Field) {
@@ -4251,7 +4250,6 @@
}
}
}
- CopyConstructor->setUsed();
}
Sema::OwningExprResult
More information about the cfe-commits
mailing list