================
@@ -6621,38 +6632,53 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl
*Class) {
if (MD->isDeleted())
continue;
- // Don't export inherited constructors whose parameters prevent ABI-
- // compatible forwarding. When canEmitDelegateCallArgs (in CodeGen)
- // returns false, Clang inlines the constructor body instead of
- // emitting a forwarding thunk, producing code that is not ABI-
- // compatible with MSVC. Suppress the export and warn so the user
- // gets a linker error rather than a silent runtime mismatch.
if (ClassExported) {
- if (auto *CD = dyn_cast<CXXConstructorDecl>(MD)) {
- if (CD->getInheritedConstructor()) {
- if (CD->isVariadic()) {
+ CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(MD);
+ if (CD && CD->getInheritedConstructor()) {
+ // Inherited constructors already had their base constructor's
+ // constraints checked before creation via
+ // findInheritingConstructor, so only ABI-compatibility checks
+ // are needed here.
+ //
+ // Don't export inherited constructors whose parameters prevent
+ // ABI-compatible forwarding. When canEmitDelegateCallArgs (in
+ // CodeGen) returns false, Clang inlines the constructor body
+ // instead of emitting a forwarding thunk, producing code that
+ // is not ABI-compatible with MSVC. Suppress the export and warn
+ // so the user gets a linker error rather than a silent runtime
+ // mismatch.
+ if (CD->isVariadic()) {
+ Diag(CD->getLocation(),
+ diag::warn_dllexport_inherited_ctor_unsupported)
+ << /*variadic=*/0;
+ continue;
+ }
+ if (Context.getTargetInfo()
+ .getCXXABI()
+ .areArgsDestroyedLeftToRightInCallee()) {
+ bool HasCalleeCleanupParam = false;
+ for (const ParmVarDecl *P : CD->parameters())
+ if (P->needsDestruction(Context)) {
+ HasCalleeCleanupParam = true;
+ break;
+ }
+ if (HasCalleeCleanupParam) {
Diag(CD->getLocation(),
diag::warn_dllexport_inherited_ctor_unsupported)
- << /*variadic=*/0;
+ << /*callee-cleanup=*/1;
continue;
}
- if (Context.getTargetInfo()
- .getCXXABI()
- .areArgsDestroyedLeftToRightInCallee()) {
- bool HasCalleeCleanupParam = false;
- for (const auto *P : CD->parameters())
- if (P->needsDestruction(Context)) {
- HasCalleeCleanupParam = true;
- break;
- }
- if (HasCalleeCleanupParam) {
- Diag(CD->getLocation(),
- diag::warn_dllexport_inherited_ctor_unsupported)
- << /*callee-cleanup=*/1;
- continue;
- }
- }
}
+ } else if (MD->getTrailingRequiresClause()) {
+ // Don't export methods whose requires clause is not satisfied.
----------------
efriedma-quic wrote:
Should we add a non-constructor testcase for this?
https://github.com/llvm/llvm-project/pull/186497
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits