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.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
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. |
Comments resolved, PTAL.
lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
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. |
lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
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
PTAL
lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
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). |