llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.97k stars 11.54k forks source link

false-positive [clang-analyzer-deadcode.DeadStores] with switch-case #36531

Open pesitec opened 6 years ago

pesitec commented 6 years ago
Bugzilla Link 37183
Version unspecified
OS other
Attachments run clang-tidy on it and you'll see.
CC @EugeneZelenko,@pesitec

Extended Description

In the attached code, clang-tidy 6.0.0 reports "Value stored to 'i1' is never read", but both i1 and i2 in fact are read.

EugeneZelenko commented 6 years ago

clang-analyzer-deadcode is implemented in Clang Static Analyzer. Clang-tidy only invoke it.

pesitec commented 6 years ago

assigned to @devincoughlin

pesitec commented 2 years ago

I think the issue can be closed. Clang-tidy only issues a warning if the default branch cannot be taken. A modified example where the enumeration has a third value does not produce a warning because clang-tidy sees that the default branch can be taken. The same happens when the switch uses an integer instead of an enumeration.