[PATCH] D145271: [MSVC compatibility][DLLEXPORT/DLLIMPORT] Allow dllexport/dllimport for local classes

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 05:39:56 PST 2023


hans added a comment.

Interesting! Do you have an example where this (local dllexport/import classes) comes up in practice?

MSVC will also allow the following:

  namespace {
  struct __declspec(dllexport) T {
      void foo();
  };
  }

whereas Clang will not, and I think Clang is making the right call there.



================
Comment at: clang/lib/AST/Decl.cpp:492
+  // classes with dllexport/dllimport attributes.
+  if (spec->getASTContext().getTargetInfo().shouldDLLImportComdatSymbols())
+    if (spec->hasAttr<DLLExportAttr>() || spec->hasAttr<DLLImportAttr>())
----------------
We usually check ASTContext's `getTargetInfo().getCXXABI().isMicrosoft()`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145271/new/

https://reviews.llvm.org/D145271



More information about the llvm-commits mailing list