@@ -144,13 +144,30 @@ class AssignPointerSubExpr extends AssignOperation, @assignpsubexpr {
144144/**
145145 * A C++ variable declaration in an expression where a condition is expected.
146146 * For example, on the `ConditionDeclExpr` in `if (bool c = x < y)`,
147- * `getExpr()` is an access to `c` (with possible casts), and `getVariable` is
148- * the variable `c`, which has an initializer `x < y`.
147+ * `getVariableAccess()` is an access to `c` (with possible casts),
148+ * `getVariable` is the variable `c`, which has an initializer `x < y`, and
149+ * `getInitializingExpr` is `x < y`.
149150 */
150151class ConditionDeclExpr extends Expr , @condition_decl {
151- /** Gets the access using the condition for this declaration. */
152+ /**
153+ * DEPRECATED: Use `getVariableAccess` or `getInitializingExpr` instead.
154+ * Gets the access using the condition for this declaration.
155+ */
156+ deprecated
152157 Expr getExpr ( ) { result = this .getChild ( 0 ) }
153158
159+ /**
160+ * Gets the compiler-generated variable access that conceptually occurs after
161+ * the initialization of the declared variable.
162+ */
163+ VariableAccess getVariableAccess ( ) { result = this .getChild ( 0 ) }
164+
165+ /**
166+ * Gets the expression that initializes the declared variable. This predicate
167+ * always has a result.
168+ */
169+ Expr getInitializingExpr ( ) { result = this .getVariable ( ) .getInitializer ( ) .getExpr ( ) }
170+
154171 /** Gets the variable that is declared. */
155172 Variable getVariable ( ) { condition_decl_bind ( underlyingElement ( this ) , unresolveElement ( result ) ) }
156173
0 commit comments