mirror of
https://github.com/github/codeql.git
synced 2026-05-05 13:45:19 +02:00
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.
This commit is contained in:
@@ -304,11 +304,7 @@ class CompileTimeConstantExpr extends Expr {
|
||||
int getIntValue() {
|
||||
exists(IntegralType t | this.getType() = t | t.getName().toLowerCase() != "long") and
|
||||
(
|
||||
exists(string lit | lit = this.(Literal).getValue() |
|
||||
// Don't parse `char` literal as int, instead get its code point value (see below)
|
||||
not this instanceof CharacterLiteral and
|
||||
result = lit.toInt()
|
||||
)
|
||||
result = this.(IntegerLiteral).getIntValue()
|
||||
or
|
||||
result = this.(CharacterLiteral).getCodePointValue()
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user