This is an archive of the discontinued LLVM Phabricator instance.

[Sema] -Wunused-variable warning for variables with array types should behave similarly to variables with scalar types
ClosedPublic

Authored by arphaman on Oct 25 2016, 6:12 AM.

Details

Summary

This patch makes the -Wunused-variable warning behaviour more consistent: Now clang won't warn on variables with constant array types where it doesn't warn on variables with scalar types.

Diff Detail

Repository
rL LLVM

Event Timeline

arphaman updated this revision to Diff 75692.Oct 25 2016, 6:12 AM
arphaman retitled this revision from to [Sema] -Wunused-variable warning for variables with array types should behave similarly to variables with scalar types.
arphaman updated this object.
arphaman added reviewers: rjmccall, thakis.
arphaman set the repository for this revision to rL LLVM.
arphaman added a subscriber: cfe-commits.
rjmccall requested changes to this revision.Oct 25 2016, 9:33 AM
rjmccall edited edge metadata.

There's no reason for this to only consider constant-sized arrays, and you should use getBaseElementTypeUnsafe() so you look through nested array types. That method is a no-op on non-array types, so you can just call it unconditionally here.

This revision now requires changes to proceed.Oct 25 2016, 9:33 AM
arphaman updated this revision to Diff 75877.Oct 26 2016, 7:22 AM
arphaman edited edge metadata.

The updated patch incorporates John's suggestions into code.

rjmccall accepted this revision.Oct 26 2016, 10:10 AM
rjmccall edited edge metadata.

Please add a line testing the nested-array case to warn-unused-variables.cpp, but with that, LGTM.

This revision is now accepted and ready to land.Oct 26 2016, 10:11 AM
This revision was automatically updated to reflect the committed changes.