diff options
| author | Anders Carlsson <andersca@mac.com> | 2010-04-23 16:04:08 +0000 | 
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2010-04-23 16:04:08 +0000 | 
| commit | 423f5d85fd9d3fed1342c045a71bc5bca0275379 (patch) | |
| tree | 3a28cbed16bd8e9e3b81a4958d2ca1e0bc4c6997 /clang | |
| parent | 092d1c9f64ce5e648488ee218e5e31d40dc9879e (diff) | |
| download | bcm5719-llvm-423f5d85fd9d3fed1342c045a71bc5bca0275379.tar.gz bcm5719-llvm-423f5d85fd9d3fed1342c045a71bc5bca0275379.zip  | |
Handle copy initialization in BuildImplicitMemberInitializer. Not used yet.
llvm-svn: 102178
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 41 | 
1 files changed, 35 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 26b55548b76..9d10f1de8a2 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1505,19 +1505,49 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,                                 ImplicitInitializerKind ImplicitInitKind,                                 FieldDecl *Field,                                 CXXBaseOrMemberInitializer *&CXXMemberInit) { -  // FIXME: Handle copy initialization. -  if (ImplicitInitKind != IIK_Default) { +  if (ImplicitInitKind == IIK_Copy) { +    ParmVarDecl *Param = Constructor->getParamDecl(0); +    QualType ParamType = Param->getType().getNonReferenceType(); +     +    Expr *MemberExprBase =  +      DeclRefExpr::Create(SemaRef.Context, 0, SourceRange(), Param,  +                          SourceLocation(), ParamType, 0); +     +     +    Expr *CopyCtorArg =  +      MemberExpr::Create(SemaRef.Context, MemberExprBase, /*IsArrow=*/false,  +                         0, SourceRange(), Field,  +                         DeclAccessPair::make(Field, Field->getAccess()), +                         SourceLocation(), 0,  +                         Field->getType().getNonReferenceType()); +     +    InitializedEntity InitEntity = InitializedEntity::InitializeMember(Field); +    InitializationKind InitKind = +      InitializationKind::CreateDirect(Constructor->getLocation(),  +                                       SourceLocation(), SourceLocation()); +     +    InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, +                                   &CopyCtorArg, 1); +     +    Sema::OwningExprResult MemberInit = +      InitSeq.Perform(SemaRef, InitEntity, InitKind,  +                      Sema::MultiExprArg(SemaRef, (void**)&CopyCtorArg, 1), 0); +    if (MemberInit.isInvalid()) +      return true; +          CXXMemberInit = 0;      return false;    } +  assert(ImplicitInitKind == IIK_Default && "Unhandled implicit init kind!"); +    QualType FieldBaseElementType =       SemaRef.Context.getBaseElementType(Field->getType());    if (FieldBaseElementType->isRecordType()) {      InitializedEntity InitEntity = InitializedEntity::InitializeMember(Field); -    InitializationKind InitKind -      = InitializationKind::CreateDefault(Constructor->getLocation()); +    InitializationKind InitKind =  +      InitializationKind::CreateDefault(Constructor->getLocation());      InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, 0, 0);      Sema::OwningExprResult MemberInit =  @@ -3970,8 +4000,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,            !Constructor->isUsed()) &&      "DefineImplicitDefaultConstructor - call it for implicit default ctor"); -  CXXRecordDecl *ClassDecl -    = cast<CXXRecordDecl>(Constructor->getDeclContext()); +  CXXRecordDecl *ClassDecl = Constructor->getParent();    assert(ClassDecl && "DefineImplicitDefaultConstructor - invalid constructor");    DeclContext *PreviousContext = CurContext;  | 

