[clang] [Clang] Allow simpler visibility annotations when targeting win32 and mingw (PR #133699)

Nikolas Klauser via cfe-commits cfe-commits at lists.llvm.org
Fri May 2 23:54:51 PDT 2025


================
@@ -6606,7 +6606,10 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl *Class) {
   if (ClassExported && !ClassAttr->isInherited() &&
       TSK == TSK_ExplicitInstantiationDeclaration &&
       !Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
-    Class->dropAttr<DLLExportAttr>();
+    if (auto *DEA = Class->getAttr<DLLExportAttr>()) {
+      Class->addAttr(DLLExportOnDeclAttr::Create(Context, DEA->getLoc()));
----------------
philnik777 wrote:

I guess that would be possible. The main problem I see with this is that we'd have to check in a bunch of places whether the attribute is actually valid, and not just whether it exists (AFAICT it's usually assumed that if an attribute is in the AST it is valid).

https://github.com/llvm/llvm-project/pull/133699


More information about the cfe-commits mailing list