[cfe-dev] Visiting implicit copy assignment

Reid Kleckner rnk at google.com
Mon Apr 20 14:00:49 PDT 2015


On Fri, Apr 17, 2015 at 12:58 PM, Kim Gräsman <kim.grasman at gmail.com> wrote:

> Hi all,
>
> I'm experimenting with a Clang tool to generate export tables from
> source code (MSVC's .DEF files)
>
> I've noticed that MSVC always exports the copy assignment operator if
> the class is marked __declspec(dllexport), so I'm trying to mimic that
> behavior.
>

Clang already implements that behavior if you use __declspec(dllexport).
:-) But I assume you have your reasons for wanting to use .def files.


> So, given:
>
>   class Implicits { };
>
> Can I somehow visit the implicit methods (default ctor, copy ctor,
> copy assignment operator, dtor) in a Clang tool?
>
> I've smuggled Sema into the tool and tried to use the DefineImplicit
> methods to define them before visitation, but haven't had much luck.
>
> Is there a documented way to handle this? It seems Clang only defines
> these methods if they are used, but for tooling it would be useful to
> be able to work with them whether they're actually defined or not.


See where Clang implements this in SemaDeclCXX.cpp. It calls
Sema::ForceDeclarationOfImplicitMembers(), and then iterates over them and
marks them referenced to ensure they are emitted.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150420/0a6b956a/attachment.html>


More information about the cfe-dev mailing list