[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 26 23:56:34 PST 2025
================
@@ -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
More information about the cfe-commits
mailing list