Skip to content

Commit 94dc11c

Browse files
committed
Revert getNonIntegerValue unification
1 parent 1cf3196 commit 94dc11c

4 files changed

Lines changed: 16 additions & 28 deletions

File tree

csharp/ql/src/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisCommon.qll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@ private Sign certainExprSign(Expr e) {
4141
)
4242
}
4343

44-
/**
45-
* Gets the value of the expression if it can't be converted to integer, but
46-
* can be converted to float.
47-
*/
48-
private float getNonIntegerValue(ExprWithPossibleValue e) {
49-
exists(string s |
50-
s = e.getValue() and
51-
result = s.toFloat() and
52-
not exists(s.toInt())
53-
)
54-
}
55-
5644
/** Holds if the sign of `e` is too complicated to determine. */
5745
private predicate unknownSign(Expr e) {
5846
not exists(certainExprSign(e)) and

csharp/ql/src/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ module Private {
3535

3636
class VariableUpdate = CS::AssignableDefinition;
3737

38-
class ExprWithPossibleValue = CS::Expr;
39-
4038
class Field = CS::Field;
4139

4240
class RealLiteral = CS::RealLiteral;
@@ -130,6 +128,15 @@ private module Impl {
130128
/** Gets the character value of expression `e`. */
131129
string getCharValue(Expr e) { result = e.getValue() and e.getType() instanceof CharType }
132130

131+
/** Gets the constant `float` value of non-`ConstantIntegerExpr` expressions. */
132+
float getNonIntegerValue(Expr e) {
133+
exists(string s |
134+
s = e.getValue() and
135+
result = s.toFloat() and
136+
not exists(s.toInt())
137+
)
138+
}
139+
133140
/**
134141
* Holds if `e` is an access to the size of a container (`string`, `Array`,
135142
* `IEnumerable`, or `ICollection`).

java/ql/src/semmle/code/java/dataflow/internal/rangeanalysis/SignAnalysisCommon.qll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@ private Sign certainExprSign(Expr e) {
4141
)
4242
}
4343

44-
/**
45-
* Gets the value of the expression if it can't be converted to integer, but
46-
* can be converted to float.
47-
*/
48-
private float getNonIntegerValue(ExprWithPossibleValue e) {
49-
exists(string s |
50-
s = e.getValue() and
51-
result = s.toFloat() and
52-
not exists(s.toInt())
53-
)
54-
}
55-
5644
/** Holds if the sign of `e` is too complicated to determine. */
5745
private predicate unknownSign(Expr e) {
5846
not exists(certainExprSign(e)) and

java/ql/src/semmle/code/java/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ module Private {
3939

4040
class VariableUpdate = J::VariableUpdate;
4141

42-
class ExprWithPossibleValue = J::Literal;
43-
4442
class Field = J::Field;
4543

4644
class DivExpr = J::DivExpr;
@@ -187,6 +185,13 @@ private module Impl {
187185
/** Gets the character value of expression `e`. */
188186
string getCharValue(Expr e) { result = e.(CharacterLiteral).getValue() }
189187

188+
/** Gets the constant `float` value of non-`ConstantIntegerExpr` expressions. */
189+
float getNonIntegerValue(Expr e) {
190+
result = e.(LongLiteral).getValue().toFloat() or
191+
result = e.(FloatingPointLiteral).getValue().toFloat() or
192+
result = e.(DoubleLiteral).getValue().toFloat()
193+
}
194+
190195
/**
191196
* Holds if `e` is an access to the size of a container (`string`, `Map`, or
192197
* `Collection`).

0 commit comments

Comments
 (0)