mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Cleanup from code review feedback
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Add new method `CompileTimeConstantExpr.getStringifiedValue` which attempts to compute the
|
||||
* Add new predicate `CompileTimeConstantExpr.getStringifiedValue` which attempts to compute the
|
||||
`String.valueOf` string rendering of a constant expression.
|
||||
|
||||
@@ -166,10 +166,10 @@ class CompileTimeConstantExpr extends Expr {
|
||||
*
|
||||
* The stringified version of a compile-time constant expression is the equivalent to
|
||||
* the result of calling `String.valueOf(expr)` on the expression.
|
||||
*
|
||||
*
|
||||
* Note that this does not handle the following cases:
|
||||
*
|
||||
* - mathematical computations of type `long`.
|
||||
* - mathematical computations of type `long`, `float`, or `double`.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
string getStringifiedValue() {
|
||||
@@ -200,11 +200,11 @@ class CompileTimeConstantExpr extends Expr {
|
||||
string getStringValue() {
|
||||
result = this.(StringLiteral).getValue()
|
||||
or
|
||||
(
|
||||
this.getType() instanceof TypeString and
|
||||
this.getType() instanceof TypeString and // When the expression type is `String`
|
||||
result =
|
||||
// Then the resultant string is the addition of both operands stringified value, regardless of type.
|
||||
this.(AddExpr).getLeftOperand().(CompileTimeConstantExpr).getStringifiedValue() +
|
||||
this.(AddExpr).getRightOperand().(CompileTimeConstantExpr).getStringifiedValue()
|
||||
)
|
||||
or
|
||||
// Ternary conditional, with compile-time constant condition.
|
||||
exists(ConditionalExpr ce, boolean condition |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import semmle.code.java.Expr
|
||||
import java
|
||||
|
||||
from CompileTimeConstantExpr constant, RefType tpe
|
||||
where
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import semmle.code.java.Variable
|
||||
import java
|
||||
|
||||
from Variable v, CompileTimeConstantExpr init, RefType enclosing, boolean constant
|
||||
where
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import semmle.code.java.Variable
|
||||
import java
|
||||
|
||||
from Variable v, Expr init, RefType enclosing
|
||||
where
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import semmle.code.java.Variable
|
||||
import java
|
||||
|
||||
from Variable v, CompileTimeConstantExpr init, RefType enclosing, int constant
|
||||
where
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import semmle.code.java.Variable
|
||||
import java
|
||||
|
||||
from Variable v, CompileTimeConstantExpr init, RefType enclosing, string constant
|
||||
where
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import semmle.code.java.Variable
|
||||
import java
|
||||
|
||||
from Variable v, CompileTimeConstantExpr init, RefType enclosing, string constant
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user