[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

Takuya Shimizu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 8 22:08:00 PDT 2023


hazohelet created this revision.
hazohelet added reviewers: aaron.ballman, tbaeder, shafik.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added a project: clang.

This patch marks the declarations with initializations in condition expressions such as
`if (int var = init)` as unused and unreferenced so that `-Wunused` can warn on them.

Fixes https://github.com/llvm/llvm-project/issues/61681


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152495

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclBase.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-if-json.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/SemaCXX/warn-unused-variables.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152495.529824.patch
Type: text/x-patch
Size: 6240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230609/def9da0e/attachment-0001.bin>


More information about the cfe-commits mailing list