Page MenuHomePhabricator

[MSVC2015] dllexport for defaulted special class members

Authored by DmitryPolukhin on May 19 2016, 4:53 AM.



Clang doesn't dllexport defaulted special member function defaulted inside class but does it if they defaulted outside class. MSVC doesn't make any distinction where they were defaulted. Also MSVC 2013 and 2015 export different set of members. MSVC2015 doesn't emit trivial defaulted x-tors but does emit copy assign operator.

Diff Detail


Event Timeline

DmitryPolukhin retitled this revision from to [MSVC2015] dllexport for defaulted special class members.
DmitryPolukhin updated this object.
DmitryPolukhin added a reviewer: rnk.
DmitryPolukhin added a subscriber: cfe-commits.
rnk added inline comments.May 19 2016, 11:56 AM
4814 ↗(On Diff #57763)

nit, can you rename this Ctor? I definitely know that that is, but not necessarily CXXC.

13111 ↗(On Diff #57763)

Can we add if (InClassDef) ActOnFinishInlineFunctionDef(MD); here instead? If the decl doesn't have dllexport, we will just defer it until its referenced, which seems OK.

DmitryPolukhin marked 2 inline comments as done.

Comments resolved, PTAL.

13111 ↗(On Diff #57763)

We can move this check here but condition has to be more complicated because MSVC2015 doesn't export trivial defaulted c-tors even if they were explicitly declared dllexport, see my check on line 4822.

rnk added inline comments.May 20 2016, 10:01 AM
13111 ↗(On Diff #57763)

Maybe we should handle that case by silently dropping dllexport on trivial defaulted ctors and dtors. Basically I'm trying to keep our dllexport policy decisions local to the dll attribute checking code. We should either consistently call ActOnFinishInlineFunctionDef for special members that were defaulted in the class body, or not do it at all.

  • drop dllexport for trivial defaulted x-tors for compatibility with MSVC2015
  • move checks to CheckCompletedCXXClass because completed class definition is required to detect if x-tor is trivial


13113–13114 ↗(On Diff #58088)

I added code to drop dllexport attribute but the check for dropping dllexport attribute is basically the same. Moreover it cannot be done when the attribute is processed because we need full class definition so I moved the check to CheckCompletedCXXClass. Alternatively I can move the check to checkClassLevelDLLAttribute but it will start working for classes without class level dllexport attribute to detect if any class member has member level attribute (it is less efficient because it requires more more loop over all class methods even for all classes).

rnk accepted this revision.May 23 2016, 8:56 AM
rnk edited edge metadata.



This revision is now accepted and ready to land.May 23 2016, 8:56 AM
This revision was automatically updated to reflect the committed changes.