[cfe-commits] [PATCH] Smarter implicit copy-construction/copy-assignment.
Lang Hames
lhames at gmail.com
Mon Feb 11 16:03:07 PST 2013
Thanks John. Committed the requested changes in r174919.
Thanks to both of you for your help.
- Lang.
On Mon, Feb 11, 2013 at 11:52 AM, John McCall <rjmccall at apple.com> wrote:
> On Feb 8, 2013, at 12:21 AM, Lang Hames <lhames at gmail.com> wrote:
> > Thanks very much for all the help guys. I've attached an updated patch
> incorporating your feedback. It also fixes a bug - I had been memcpying
> members with defaulted but non-trivial assignment operators.
>
> + // Get source argument for copy constructor. Returns null if not a
> copy
> + // constructor.
> + static const VarDecl* getCCSrc(const CXXConstructorDecl *CD,
> + FunctionArgList &Args) {
> + if (CD->isCopyOrMoveConstructor() && CD->isImplicitlyDefined())
> + return Args[Args.size() - 1];
> + return 0;
> + }
> +
>
> Please name this something like getTrivialCopySource and use /// comments.
>
> void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD,
> @@ -770,8 +1107,15 @@
>
> InitializeVTablePointers(ClassDecl);
>
> - for (unsigned I = 0, E = MemberInitializers.size(); I != E; ++I)
> - EmitMemberInitializer(*this, ClassDecl, MemberInitializers[I], CD,
> Args);
> + if (getLangOpts().getGC() == LangOptions::NonGC) {
> + ConstructorMemcpyizer CM(*this, CD, Args);
> + for (unsigned I = 0, E = MemberInitializers.size(); I != E; ++I)
> + CM.addMemberInitializer(MemberInitializers[I]);
> + CM.finish();
> + } else {
> + for (unsigned I = 0, E = MemberInitializers.size(); I != E; ++I)
> + EmitMemberInitializer(*this, ClassDecl, MemberInitializers[I], CD,
> Args);
> + }
>
> You shouldn't need to split out specifically on GC mode here, since you're
> already setting MemcpyableCtor based on that.
>
> With those changes, go ahead and commit.
>
> John.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130211/81f95533/attachment.html>
More information about the cfe-commits
mailing list