================
@@ -5284,8 +5284,22 @@ void Sema::InstantiateFunctionDefinition(SourceLocation
PointOfInstantiation,
savedContext.pop();
}
- DeclGroupRef DG(Function);
- Consumer.HandleTopLevelDecl(DG);
+ // With CWG2369, we substitute constraints before instantiating the
associated
+ // function template. This helps prevent potential code generation for
+ // dependent types, particularly under the MS ABI.
+ bool ShouldSkipCG = [&] {
+ auto *RD = dyn_cast<CXXRecordDecl>(Function->getParent());
+ if (!RD || !RD->isLambda())
+ return false;
+
+ return llvm::any_of(ExprEvalContexts, [](auto &Context) {
+ return Context.isUnevaluated() || Context.isImmediateFunctionContext();
+ });
+ }();
+ if (!ShouldSkipCG) {
+ DeclGroupRef DG(Function);
+ Consumer.HandleTopLevelDecl(DG);
+ }
----------------
cor3ntin wrote:
This should fix https://github.com/llvm/llvm-project/issues/82926 and
https://github.com/llvm/llvm-project/issues/123854
@zyn0217 Would you be willing to make a separate PR?
(I haven't tested though)
https://github.com/llvm/llvm-project/pull/122423
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits