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

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 27 09:47:37 PST 2025


cor3ntin 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

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


More information about the cfe-commits mailing list