From: Fariborz Jahanian Date: Sat, 8 Aug 2009 19:31:03 +0000 (+0000) Subject: Refactoring of copy ctor ir-gen. No change in functionality. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c241a2844428eb1589c7b77fc6c1888295a2045;p=clang Refactoring of copy ctor ir-gen. No change in functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78489 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 3e828bf9ac..a1ea6bf76a 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -699,7 +699,7 @@ void CodeGenFunction::EmitClassMemberwiseCopy( } } -/// EmitCopyCtorBody - This routine implicitly defines body of a copy +/// SynthesizeCXXCopyConstructor - This routine implicitly defines body of a copy /// constructor, in accordance with section 12.8 (p7 and p8) of C++03 /// The implicitly-defined copy constructor for class X performs a memberwise /// copy of its subobjects. The order of copying is the same as the order @@ -714,11 +714,14 @@ void CodeGenFunction::EmitClassMemberwiseCopy( /// Virtual base class subobjects shall be copied only once by the /// implicitly-defined copy constructor -void CodeGenFunction::EmitCopyCtorBody(const CXXConstructorDecl *CD, +void CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD, + const FunctionDecl *FD, + llvm::Function *Fn, const FunctionArgList &Args) { const CXXRecordDecl *ClassDecl = cast(CD->getDeclContext()); assert(!ClassDecl->hasUserDeclaredCopyConstructor() && - "EmitCopyCtorBody - copy constructor has definition already"); + "SynthesizeCXXCopyConstructor - copy constructor has definition already"); + StartFunction(FD, FD->getResultType(), Fn, Args, SourceLocation()); FunctionArgList::const_iterator i = Args.begin(); const VarDecl *ThisArg = i->first; @@ -759,6 +762,7 @@ void CodeGenFunction::EmitCopyCtorBody(const CXXConstructorDecl *CD, } // FIXME. Do a built-in assignment of scalar data members. } + FinishFunction(); } diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 0a3d9d4be9..eae6161e8e 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -246,9 +246,7 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD, if (CD->isCopyConstructor(getContext())) { assert(!ClassDecl->hasUserDeclaredCopyConstructor() && "bogus constructor is being synthesize"); - StartFunction(FD, FD->getResultType(), Fn, Args, SourceLocation()); - EmitCopyCtorBody(CD, Args); - FinishFunction(); + SynthesizeCXXCopyConstructor(CD, FD, Fn, Args); } else { assert(!ClassDecl->hasUserDeclaredConstructor() && diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 383f844e93..6e4d9ec891 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -369,8 +369,10 @@ public: void EmitCtorPrologue(const CXXConstructorDecl *CD); - void EmitCopyCtorBody(const CXXConstructorDecl *CD, - const FunctionArgList &Args); + void SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD, + const FunctionDecl *FD, + llvm::Function *Fn, + const FunctionArgList &Args); /// EmitDtorEpilogue - Emit all code that comes at the end of class's /// destructor. This is to call destructors on members and base classes