You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 30, 2021. It is now read-only.
[analyzer] Avoid unnecessary enum range check on LValueToRValue casts
Summary: EnumCastOutOfRangeChecker should not perform enum range checks on LValueToRValue casts, since this type of cast does not actually change the underlying type. Performing the unnecessary check actually triggered an assertion failure deeper in EnumCastOutOfRange for certain input (which is captured in the accompanying test code).
Reviewers: #clang, Szelethus, gamesh411, NoQ
Reviewed By: Szelethus, gamesh411, NoQ
Subscribers: NoQ, gamesh411, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, Charusso, bjope, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66014
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369760 91177308-0d34-0410-b5e6-96231b3b80d8
scoped_specified_t InvalidAfterRangeEnd = (scoped_specified_t)(5); // expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
151
151
}
152
152
153
-
voidrangeContstrained1(int input) {
153
+
unscoped_unspecified_t unused;
154
+
voidunusedExpr() {
155
+
// following line is not something that EnumCastOutOfRangeChecker should evaluate. checker should either ignore this line
156
+
// or process it without producing any warnings. However, compilation will (and should) still generate a warning having
157
+
// nothing to do with this checker.
158
+
unused; // expected-warning {{expression result unused}}
159
+
}
160
+
161
+
voidrangeConstrained1(int input) {
154
162
if (input > -5 && input < 5)
155
163
auto value = static_cast<scoped_specified_t>(input); // OK. Being conservative, this is a possibly good value.
0 commit comments