@@ -113,7 +113,7 @@ class Expr extends ExprParent, @expr {
113113 if this instanceof CastingExpr or this instanceof NotNullExpr
114114 then
115115 result = this .( CastingExpr ) .getExpr ( ) .getUnderlyingExpr ( ) or
116- result = this .( NotNullExpr ) .getExpr ( ) .getUnderlyingExpr ( )
116+ result = this .( NotNullExpr ) .getOperand ( ) .getUnderlyingExpr ( )
117117 else result = this
118118 }
119119}
@@ -144,13 +144,13 @@ class CompileTimeConstantExpr extends Expr {
144144 this .( CastingExpr ) .getExpr ( ) .isCompileTimeConstant ( )
145145 or
146146 // The unary operators `+`, `-`, `~`, and `!` (but not `++` or `--`).
147- this .( PlusExpr ) .getExpr ( ) .isCompileTimeConstant ( )
147+ this .( PlusExpr ) .getOperand ( ) .isCompileTimeConstant ( )
148148 or
149- this .( MinusExpr ) .getExpr ( ) .isCompileTimeConstant ( )
149+ this .( MinusExpr ) .getOperand ( ) .isCompileTimeConstant ( )
150150 or
151- this .( BitNotExpr ) .getExpr ( ) .isCompileTimeConstant ( )
151+ this .( BitNotExpr ) .getOperand ( ) .isCompileTimeConstant ( )
152152 or
153- this .( LogNotExpr ) .getExpr ( ) .isCompileTimeConstant ( )
153+ this .( LogNotExpr ) .getOperand ( ) .isCompileTimeConstant ( )
154154 or
155155 // The multiplicative operators `*`, `/`, and `%`,
156156 // the additive operators `+` and `-`,
@@ -166,8 +166,8 @@ class CompileTimeConstantExpr extends Expr {
166166 // The ternary conditional operator ` ? : `.
167167 exists ( ConditionalExpr e | this = e |
168168 e .getCondition ( ) .isCompileTimeConstant ( ) and
169- e .getTrueExpr ( ) .isCompileTimeConstant ( ) and
170- e .getFalseExpr ( ) .isCompileTimeConstant ( )
169+ e .getThen ( ) .isCompileTimeConstant ( ) and
170+ e .getElse ( ) .isCompileTimeConstant ( )
171171 )
172172 or
173173 // Access to a final variable initialized by a compile-time constant.
@@ -943,7 +943,7 @@ class LogicExpr extends Expr {
943943 /** Gets an operand of this logical expression. */
944944 Expr getAnOperand ( ) {
945945 this .( BinaryExpr ) .getAnOperand ( ) = result or
946- this .( UnaryExpr ) .getExpr ( ) = result
946+ this .( UnaryExpr ) .getOperand ( ) = result
947947 }
948948}
949949
@@ -1039,8 +1039,15 @@ class ReferenceEqualityTest extends EqualityTest {
10391039
10401040/** A common super-class that represents unary operator expressions. */
10411041class UnaryExpr extends Expr , @unaryexpr {
1042+ /**
1043+ * DEPRECATED: Use `getOperand()` instead.
1044+ *
1045+ * Gets the operand expression.
1046+ */
1047+ deprecated Expr getExpr ( ) { result .getParent ( ) = this }
1048+
10421049 /** Gets the operand expression. */
1043- Expr getExpr ( ) { result .getParent ( ) = this }
1050+ Expr getOperand ( ) { result .getParent ( ) = this }
10441051}
10451052
10461053/**
@@ -1305,7 +1312,7 @@ class LambdaExpr extends FunctionalExpr, @lambdaexpr {
13051312
13061313 /** Gets the body of this lambda expression, if it is an expression. */
13071314 Expr getExprBody ( ) {
1308- this .hasExprBody ( ) and result = this .asMethod ( ) .getBody ( ) .getAChild ( ) .( ReturnStmt ) .getResult ( )
1315+ this .hasExprBody ( ) and result = this .asMethod ( ) .getBody ( ) .getAChild ( ) .( ReturnStmt ) .getExpr ( )
13091316 }
13101317
13111318 /** Gets the body of this lambda expression, if it is a statement. */
@@ -1340,7 +1347,7 @@ class MemberRefExpr extends FunctionalExpr, @memberref {
13401347 exists ( Stmt stmt |
13411348 stmt = this .asMethod ( ) .getBody ( ) .( SingletonBlock ) .getStmt ( ) and
13421349 (
1343- result = stmt .( ReturnStmt ) .getResult ( )
1350+ result = stmt .( ReturnStmt ) .getExpr ( )
13441351 or
13451352 // Note: Currently never an ExprStmt, but might change once https://github.com/github/codeql/issues/3605 is fixed
13461353 result = stmt .( ExprStmt ) .getExpr ( )
@@ -1456,27 +1463,43 @@ class ConditionalExpr extends Expr, @conditionalexpr {
14561463 /** Gets the condition of this conditional expression. */
14571464 Expr getCondition ( ) { result .isNthChildOf ( this , 0 ) }
14581465
1466+ /**
1467+ * DEPRECATED: Use `getThen()` instead.
1468+ *
1469+ * Gets the expression that is evaluated if the condition of this
1470+ * conditional expression evaluates to `true`.
1471+ */
1472+ deprecated Expr getTrueExpr ( ) { result .isNthChildOf ( this , 1 ) }
1473+
1474+ /**
1475+ * DEPRECATED: Use `getElse()` instead.
1476+ *
1477+ * Gets the expression that is evaluated if the condition of this
1478+ * conditional expression evaluates to `false`.
1479+ */
1480+ deprecated Expr getFalseExpr ( ) { result .isNthChildOf ( this , 2 ) }
1481+
14591482 /**
14601483 * Gets the expression that is evaluated if the condition of this
14611484 * conditional expression evaluates to `true`.
14621485 */
1463- Expr getTrueExpr ( ) { result .isNthChildOf ( this , 1 ) }
1486+ Expr getThen ( ) { result .isNthChildOf ( this , 1 ) }
14641487
14651488 /**
14661489 * Gets the expression that is evaluated if the condition of this
14671490 * conditional expression evaluates to `false`.
14681491 */
1469- Expr getFalseExpr ( ) { result .isNthChildOf ( this , 2 ) }
1492+ Expr getElse ( ) { result .isNthChildOf ( this , 2 ) }
14701493
14711494 /**
14721495 * Gets the expression that is evaluated by the specific branch of this
1473- * conditional expression. If `true` that is `getTrueExpr ()`, if `false`
1474- * it is `getFalseExpr ()`.
1496+ * conditional expression. If `true` that is `getThen ()`, if `false`
1497+ * it is `getElse ()`.
14751498 */
14761499 Expr getBranchExpr ( boolean branch ) {
1477- branch = true and result = this .getTrueExpr ( )
1500+ branch = true and result = this .getThen ( )
14781501 or
1479- branch = false and result = this .getFalseExpr ( )
1502+ branch = false and result = this .getElse ( )
14801503 }
14811504
14821505 /**
@@ -1773,14 +1796,14 @@ class VariableUpdate extends Expr {
17731796 VariableUpdate ( ) {
17741797 this .( Assignment ) .getDest ( ) instanceof VarAccess or
17751798 this instanceof LocalVariableDeclExpr or
1776- this .( UnaryAssignExpr ) .getExpr ( ) instanceof VarAccess
1799+ this .( UnaryAssignExpr ) .getOperand ( ) instanceof VarAccess
17771800 }
17781801
17791802 /** Gets the destination of this variable update. */
17801803 Variable getDestVar ( ) {
17811804 result .getAnAccess ( ) = this .( Assignment ) .getDest ( ) or
17821805 result = this .( LocalVariableDeclExpr ) .getVariable ( ) or
1783- result .getAnAccess ( ) = this .( UnaryAssignExpr ) .getExpr ( )
1806+ result .getAnAccess ( ) = this .( UnaryAssignExpr ) .getOperand ( )
17841807 }
17851808}
17861809
@@ -1970,7 +1993,7 @@ class VarAccess extends Expr, @varaccess {
19701993 */
19711994 predicate isVarWrite ( ) {
19721995 exists ( Assignment a | a .getDest ( ) = this ) or
1973- exists ( UnaryAssignExpr e | e .getExpr ( ) = this )
1996+ exists ( UnaryAssignExpr e | e .getOperand ( ) = this )
19741997 }
19751998
19761999 /**
0 commit comments