[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 27 00:09:08 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);
+ }
----------------
zyn0217 wrote:
Thanks, I'll take a look
https://github.com/llvm/llvm-project/pull/122423
More information about the cfe-commits
mailing list