mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Apply suggestions from code review
Co-authored-by: Chris Smowton <smowton@github.com>
This commit is contained in:
committed by
GitHub
parent
2e8b5f743b
commit
65457cc2e2
@@ -1,5 +1,5 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Add new method `CharacterLiteral.getStringifiedValue` which attempts to compute the
|
||||
`String.valueOf` compile time constant value of the expression.
|
||||
* Add new method `CompileTimeConstantExpr.getStringifiedValue` which attempts to compute the
|
||||
`String.valueOf` string rendering of a constant expression.
|
||||
|
||||
@@ -201,17 +201,9 @@ class CompileTimeConstantExpr extends Expr {
|
||||
result = this.(StringLiteral).getValue()
|
||||
or
|
||||
(
|
||||
if this.(AddExpr).getAnOperand().getType() instanceof TypeString // If either operand type is already a String:
|
||||
then
|
||||
// Then the stringified version of the expression can be safely used as a String will be created.
|
||||
result =
|
||||
this.(AddExpr).getLeftOperand().(CompileTimeConstantExpr).getStringifiedValue() +
|
||||
this.(AddExpr).getRightOperand().(CompileTimeConstantExpr).getStringifiedValue()
|
||||
else
|
||||
// Adding two literals of primitive type will not result in a String.
|
||||
result =
|
||||
this.(AddExpr).getLeftOperand().(CompileTimeConstantExpr).getStringValue() +
|
||||
this.(AddExpr).getRightOperand().(CompileTimeConstantExpr).getStringValue()
|
||||
this.getType() instanceof TypeString and
|
||||
this.(AddExpr).getLeftOperand().(CompileTimeConstantExpr).getStringifiedValue() +
|
||||
this.(AddExpr).getRightOperand().(CompileTimeConstantExpr).getStringifiedValue()
|
||||
)
|
||||
or
|
||||
// Ternary conditional, with compile-time constant condition.
|
||||
|
||||
Reference in New Issue
Block a user