[clang] Warn when unique objects might be duplicated in shared libraries (PR #117622)

Devon Loehr via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 17 08:34:36 PST 2025


DKLoehr wrote:

@zmodem Thanks for the review! I've addressed the code comments. To your questions:
> What about code that's not going into a shared library?

My impression is that you wouldn't mark things as having hidden visibility if they're not going to a shared library at least some of the time. That said, if there's a way to check if something is being compiled into a shared library, it would make sense to add it as a condition for the warning.

> The new warning is DefaultIgnore.

I intend to make the warning on-by-default. However, it currently triggers at several places in the LLVM project, breaking the CI. Fixing them is nontrivial and cluttered up the PR, so I made it DefaultIgnore in order to keep things focused. Should the PR be accepted I plan to go through and clean things up, then default-enable the warning.

> Would warning during instantiation work?

That's the most likely solution! I need to look into it, but haven't had time yet. Since the warning is useful even without templates, I didn't think doing so should block making the PR.

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


More information about the cfe-commits mailing list