[clang-tools-extra] [clang-tidy] Centralize the logic for matching discarded expressions (PR #184069)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 6 20:15:45 PST 2026
zwuis wrote:
> > LHS of member expression (`A.B`/`A->B`) if RHS is enumerator or static member
>
> In this case though, the type of `A` still matters, right? If `A` is a function call, we can't replace it with a function that returns void (like `modernize-use-std-print` wants to do, for example), so it's not discarded in the sense these checks are interested in. Maybe there's a better name than `isDiscarded`?
>
> > explicitly cast to `void`
>
> Checks differ on how they want to handle this case (for example, `bugprone-standalone-empty` doesn't consider `(void)v.empty();` to be discarded), so I think this should be left to individual checks.
Makes sense to me. It's ok to me to only document it.
https://github.com/llvm/llvm-project/pull/184069
More information about the cfe-commits
mailing list