1515
1616import cpp
1717import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
18- import semmle.code.cpp.commons.Exclusions
1918
2019/** Holds if the range contains no boundary values. */
2120predicate isRealRange ( Expr exp ) {
@@ -36,13 +35,19 @@ predicate isRealRange(Expr exp) {
3635 upperBound ( exp ) != 32767 and
3736 upperBound ( exp ) != 255 and
3837 upperBound ( exp ) != 127 and
38+ upperBound ( exp ) != 63 and
39+ upperBound ( exp ) != 31 and
40+ upperBound ( exp ) != 15 and
41+ upperBound ( exp ) != 7 and
3942 lowerBound ( exp ) != - 2147483648 and
4043 lowerBound ( exp ) != - 268435456 and
4144 lowerBound ( exp ) != - 33554432 and
4245 lowerBound ( exp ) != - 8388608 and
4346 lowerBound ( exp ) != - 65536 and
4447 lowerBound ( exp ) != - 32768 and
45- lowerBound ( exp ) != - 128
48+ lowerBound ( exp ) != - 128 and
49+ lowerBound ( exp ) != 0 and
50+ lowerBound ( exp ) != upperBound ( exp )
4651 or
4752 lowerBound ( exp ) = 0 and
4853 upperBound ( exp ) = 1
@@ -124,7 +129,12 @@ predicate isCodeBeforeCase(SwitchStmt swtmp) {
124129from SwitchStmt sw , string msg
125130where
126131 isRealRange ( sw .getExpr ( ) ) and
127- isRealRange ( sw .getExpr ( ) .getAChild * ( ) ) and
132+ not exists ( Expr exptmp |
133+ exptmp = sw .getExpr ( ) .getAChild * ( ) and
134+ not exptmp .isConstant ( ) and
135+ not isRealRange ( exptmp )
136+ ) and
137+ ( sw .getASwitchCase ( ) .terminatesInBreakStmt ( ) or sw .getASwitchCase ( ) .terminatesInReturnStmt ( ) ) and
128138 (
129139 isNotAllSelected ( sw ) and msg = "The range of condition values is less than the selection."
130140 or
0 commit comments