This is an archive of the discontinued LLVM Phabricator instance.

[MSVC][PS][dllexport/dllimport] Propagate a dllexport/dllimport attribute to template baseclasses
ClosedPublic

Authored by wolfgangp on Mar 13 2023, 11:09 AM.

Details

Summary

For the Playstation platform, mimic MSVC in propagating dllexport/dllimport attributes
to an instantiated template base class.

This is particularly relevant in cases where the base class has static members that need to be shared between all instantiations:

template <class T>
class Base
{
public:
  static unsigned int& foo()
  {
    static unsigned int S = 0xffffffff;
    return S;
  }
};

class __declspec(dllexport) A : public Base<A>
{
};

BTW, this is unrelated to D145271

Diff Detail

Event Timeline

wolfgangp created this revision.Mar 13 2023, 11:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 13 2023, 11:09 AM
wolfgangp requested review of this revision.Mar 13 2023, 11:09 AM
hans accepted this revision.Mar 14 2023, 5:43 AM

LGTM

I've always found this to be an interesting behavior, and I'm guessing you found some code where it does matter :)

clang/lib/Sema/SemaDeclCXX.cpp
2612

Would using getTargetInfo().shouldDLLImportComdatSymbols() be appropriate here now?

This revision is now accepted and ready to land.Mar 14 2023, 5:43 AM

LGTM

I've always found this to be an interesting behavior, and I'm guessing you found some code where it does matter :)

Well, one of our customers did, anyway. The code in the description is the distilled version of it.

Thank you for the review!

clang/lib/Sema/SemaDeclCXX.cpp
2612

Perhaps. It would affect the Windows/Itanium platform in addition to what's here, and I wasn't sure if that was desirable.

This revision was landed with ongoing or failed builds.Mar 15 2023, 11:48 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2023, 11:48 AM