Skip to content

Commit edc7903

Browse files
committed
C++: Add a predicate for getting the 0'th child of a 'ConditionDeclExpr' without casting it to a 'VariableAccess' and use it in IR generation.
1 parent d0b0440 commit edc7903

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cpp/ql/lib/semmle/code/cpp/exprs/Assignment.qll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,15 @@ class ConditionDeclExpr extends Expr, @condition_decl {
244244

245245
/**
246246
* Gets the compiler-generated variable access that conceptually occurs after
247-
* the initialization of the declared variable.
247+
* the initialization of the declared variable, if any.
248248
*/
249-
VariableAccess getVariableAccess() { result = this.getChild(0) }
249+
VariableAccess getVariableAccess() { result = this.getExpr() }
250+
251+
/**
252+
* Gets the expression that is evaluated after the initialization of the declared
253+
* variable.
254+
*/
255+
Expr getExpr() { result = this.getChild(0) }
250256

251257
/**
252258
* Gets the expression that initializes the declared variable. This predicate

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3173,7 +3173,7 @@ class TranslatedConditionDeclExpr extends TranslatedNonConstantExpr {
31733173
private TranslatedConditionDecl getDecl() { result = getTranslatedConditionDecl(expr) }
31743174

31753175
private TranslatedExpr getConditionExpr() {
3176-
result = getTranslatedExpr(expr.getVariableAccess().getFullyConverted())
3176+
result = getTranslatedExpr(expr.getExpr().getFullyConverted())
31773177
}
31783178
}
31793179

0 commit comments

Comments
 (0)