Skip to content

Commit 4f59886

Browse files
committed
Java: Simplify CompileTimeConstantExpr.getIntValue()
The changed code previously also only covered IntegerLiteral: - Restricted to Literal - Integral type - != "long" - != "char" So the only class left which matches all of these is IntegerLiteral.
1 parent 9730021 commit 4f59886

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

java/ql/lib/semmle/code/java/Expr.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,7 @@ class CompileTimeConstantExpr extends Expr {
304304
int getIntValue() {
305305
exists(IntegralType t | this.getType() = t | t.getName().toLowerCase() != "long") and
306306
(
307-
exists(string lit | lit = this.(Literal).getValue() |
308-
// Don't parse `char` literal as int, instead get its code point value (see below)
309-
not this instanceof CharacterLiteral and
310-
result = lit.toInt()
311-
)
307+
result = this.(IntegerLiteral).getIntValue()
312308
or
313309
result = this.(CharacterLiteral).getCodePointValue()
314310
or

0 commit comments

Comments
 (0)