llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-platform-windows @llvm/pr-subscribers-clang-codegen Author: Hans Wennborg (zmodem) <details> <summary>Changes</summary> The inherited constructors are inline thunks, so like other inline functions they are exempted from ABI compatibility concerns with this flag, and should not be exported. This is a follow-up to #<!-- -->182706 --- Full diff: https://github.com/llvm/llvm-project/pull/187684.diff 3 Files Affected: - (modified) clang/lib/Sema/SemaDeclCXX.cpp (+3-8) - (modified) clang/test/CodeGenCXX/dllexport-inherited-ctor.cpp (+11-13) - (modified) clang/test/SemaCXX/dllexport-constrained-inherited-ctor.cpp (+1) ``````````diff diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 2a24ee42bcb4d..87e07c8ac0d05 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -6590,7 +6590,7 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl *Class) { // Inherited constructors are created lazily; force their creation now so the // loop below can propagate the DLL attribute to them. - if (ClassExported) { + if (ClassExported && getLangOpts().DllExportInlines) { SmallVector<ConstructorUsingShadowDecl *, 4> Shadows; for (Decl *D : Class->decls()) if (auto *S = dyn_cast<ConstructorUsingShadowDecl>(D)) @@ -6631,7 +6631,7 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl *Class) { if (MD->isDeleted()) continue; - if (ClassExported) { + if (ClassExported && getLangOpts().DllExportInlines) { CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(MD); if (CD && CD->getInheritedConstructor()) { // Inherited constructors already had their base constructor's @@ -6724,13 +6724,8 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl *Class) { // Do not export/import inline function when -fno-dllexport-inlines is // passed. But add attribute for later local static var check. - // Inherited constructors are marked inline but must still be exported - // to match MSVC behavior, so exclude them from this override. - bool IsInheritedCtor = false; - if (auto *CD = dyn_cast_or_null<CXXConstructorDecl>(MD)) - IsInheritedCtor = (bool)CD->getInheritedConstructor(); if (!getLangOpts().DllExportInlines && MD && MD->isInlined() && - !IsInheritedCtor && TSK != TSK_ExplicitInstantiationDeclaration && + TSK != TSK_ExplicitInstantiationDeclaration && TSK != TSK_ExplicitInstantiationDefinition) { if (ClassExported) { NewAttr = ::new (getASTContext()) diff --git a/clang/test/CodeGenCXX/dllexport-inherited-ctor.cpp b/clang/test/CodeGenCXX/dllexport-inherited-ctor.cpp index 03026f843eda6..9340b5db66e7d 100644 --- a/clang/test/CodeGenCXX/dllexport-inherited-ctor.cpp +++ b/clang/test/CodeGenCXX/dllexport-inherited-ctor.cpp @@ -225,21 +225,19 @@ struct __declspec(dllexport) CalleeCleanupChild : CalleeCleanupBase { // GNU-DAG: define {{.*}}dso_local dllexport {{.*}}CalleeCleanupChild{{.*}}NontrivialDtor //===----------------------------------------------------------------------===// -// -fno-dllexport-inlines should still export inherited constructors. -// Inherited constructors are marked inline internally but must be exported. +// -fno-dllexport-inlines should not export inherited constructors. +// Inherited constructors are marked inline internally. //===----------------------------------------------------------------------===// -// NOINLINE-DAG: define weak_odr dso_local dllexport {{.*}} @"??0Child@@QEAA@H@Z" -// NOINLINE-DAG: define weak_odr dso_local dllexport {{.*}} @"??0Child@@QEAA@N@Z" -// NOINLINE-DAG: define weak_odr dso_local dllexport {{.*}} @"??0ExportedChild@@QEAA@H@Z" -// NOINLINE-DAG: define weak_odr dso_local dllexport {{.*}} @"??0ExportedChild@@QEAA@M@Z" -// NOINLINE-DAG: define weak_odr dso_local dllexport {{.*}} @"??0MLChild@@QEAA@H@Z" -// NOINLINE-DAG: define weak_odr dso_local dllexport {{.*}} @"??0TplChild@@QEAA@H@Z" -// NOINLINE-DAG: define weak_odr dso_local dllexport {{.*}} @"??0DefArgChild@@QEAA@HHH@Z" -// NOINLINE-DAG: define weak_odr dso_local dllexport {{.*}} @"??0MixedDefChild@@QEAA@HN@Z" -// NOINLINE-DAG: define weak_odr dso_local dllexport {{.*}} @"??0AllDefChild@@QEAA@HH@Z" -// The implicit default ctor is a regular inline method, NOT an inherited -// constructor, so -fno-dllexport-inlines correctly suppresses it. +// NOINLINE-NOT: define weak_odr dso_local dllexport {{.*}} @"??0Child@@QEAA@H@Z" +// NOINLINE-NOT: define weak_odr dso_local dllexport {{.*}} @"??0Child@@QEAA@N@Z" +// NOINLINE-NOT: define weak_odr dso_local dllexport {{.*}} @"??0ExportedChild@@QEAA@H@Z" +// NOINLINE-NOT: define weak_odr dso_local dllexport {{.*}} @"??0ExportedChild@@QEAA@M@Z" +// NOINLINE-NOT: define weak_odr dso_local dllexport {{.*}} @"??0MLChild@@QEAA@H@Z" +// NOINLINE-NOT: define weak_odr dso_local dllexport {{.*}} @"??0TplChild@@QEAA@H@Z" +// NOINLINE-NOT: define weak_odr dso_local dllexport {{.*}} @"??0DefArgChild@@QEAA@HHH@Z" +// NOINLINE-NOT: define weak_odr dso_local dllexport {{.*}} @"??0MixedDefChild@@QEAA@HN@Z" +// NOINLINE-NOT: define weak_odr dso_local dllexport {{.*}} @"??0AllDefChild@@QEAA@HH@Z" // NOINLINE-NOT: define {{.*}}dllexport{{.*}} @"??0AllDefChild@@QEAA@XZ" //===----------------------------------------------------------------------===// diff --git a/clang/test/SemaCXX/dllexport-constrained-inherited-ctor.cpp b/clang/test/SemaCXX/dllexport-constrained-inherited-ctor.cpp index 019f0a17bdf1e..dc37948996ea7 100644 --- a/clang/test/SemaCXX/dllexport-constrained-inherited-ctor.cpp +++ b/clang/test/SemaCXX/dllexport-constrained-inherited-ctor.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -fms-extensions -verify -std=c++20 %s +// RUN: %clang_cc1 -triple x86_64-windows-msvc -fsyntax-only -fms-extensions -verify -std=c++20 -fno-dllexport-inlines %s // RUN: %clang_cc1 -triple x86_64-windows-gnu -fsyntax-only -fms-extensions -verify -std=c++20 %s // expected-no-diagnostics `````````` </details> https://github.com/llvm/llvm-project/pull/187684 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
