[clang] [Clang] Skip past code generation for unevaluated lambdas (PR #124572)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 09:56:01 PST 2025


erichkeane wrote:

> > Which call in EmitGlobal is the one that calls it? I would expect that either of the two (not hte annotations one for obvious reasons) should be able to filter it THERE instead. Do we perhaps just mangle 'too early'?
> 
> We use the mangle name as key to decide whether something was already used haha
> 
> ```
>   StringRef MangledName = getMangledName(GD);
>   if (GetGlobalValue(MangledName) != nullptr) {
>     // The value has already been used and should therefore be emitted.
>     addDeferredDeclToEmit(GD);
>   } else if (MustBeEmitted(Global)) {
>     // The value must be emitted, but cannot be emitted eagerly.
>     assert(!MayBeEmittedEagerly(Global));
>     addDeferredDeclToEmit(GD);
>   } else {
>     // Otherwise, remember that we saw a deferred decl with this name.  The
>     // first use of the mangled name will cause it to move into
>     // DeferredDeclsToEmit.
>     DeferredDecls[MangledName] = GD;
>   }
> ```
> 
> But really i don't think we should even get there from an unevaluated context

Yeah, I agree that we shouldn't get to that point on the decision.  That said, I THINK the decision should be made in CodeGen, not Sema?  Perhaps @efriedma-quic has comments?

https://github.com/llvm/llvm-project/pull/124572


More information about the cfe-commits mailing list