[PATCH] D138583: Create unused non-trivially-destructible check in clang-tidy
Andrei via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 24 05:11:50 PST 2022
ankineri requested review of this revision.
ankineri added a comment.
`-Wunused-variable` does not detect unused non-trivially-destructible objects because they may be used for RAII, i.e.
{
scoped_lock lock(&global_mutex);
critical_section();
}
`lock` here is not an unused variable because its destructor side-effects are its usage. However if replaced with say `absl::Status` or even `std::string` it will be more or less obvious that the variable is unused, but the warning will still not be triggered (as both `absl::Status` and `std::string` have nontrivial destructors). This is where this checks is useful: for non-trivially-destructible types known not to be used in RAII.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138583/new/
https://reviews.llvm.org/D138583
More information about the cfe-commits
mailing list