[clang] [alpha.webkit.NoDeleteChecker] Returning or passing an argument with copy elision should be considered no-delete. (PR #200481)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 1 02:42:16 PDT 2026


https://github.com/steakhal requested changes to this pull request.

My gut instinct is that it is a lot more difficult to implement this *right*.

A couple edge-cases that inhibit copy elision:
- `return std::move(Obj)` - here the std::move inhibits copy elision
- Multiple return paths (using `if` or a ternary expr) that return different variables
- Returning function parameters - they can't be elided.
- Returning global or local static variables.

I think we should at least demonstrate these cases in tests because I think the current approach will not properly align on the expected behavior.

Of course, we can tradeoff correctness for simplicity- but I'll let you make that tradeoff.

Maybe you could ask an agent to look into how copy-elision is lowered to codegen (llvm-ir) and try to mimic it in this checker. I think it should do a pretty good job.

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


More information about the cfe-commits mailing list