[PATCH] D138583: Create unused non-trivially-destructible check in clang-tidy

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 24 06:11:22 PST 2022


sammccall added a comment.

Extending --warn-unused to other types seems preferable in a few ways:

- clang warnings are more accessible than clang-tidy checks
- avoids duplicating implementation
- places description of the types along with the types, instead of in clang-tidy config
- avoids divergent ux between sources of warnings

In fact it looks like an attribute for this already exists: it can be spelled `__attribute__((warn_unused))` or `[[gnu::warn_unused]]`

  struct __attribute__((warn_unused)) S { ~S(); };
  void foo() { S s; }



  $ clang -fsyntax-only ~/test.cc -Wall
  /usr/local/google/home/sammccall/test.cc:4:5: warning: unused variable 's' [-Wunused-variable]
    S s;


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