Skip to content

Commit f58757f

Browse files
committed
C++: Skip children we cannot translate when translating builtin operations.
1 parent af4d2f1 commit f58757f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,9 +3208,13 @@ class TranslatedBuiltInOperation extends TranslatedNonConstantExpr {
32083208

32093209
final override Instruction getResult() { result = this.getInstruction(OnlyInstructionTag()) }
32103210

3211+
private TranslatedElement getRankedChild(int rnk) {
3212+
result = rank[rnk + 1](int id, TranslatedElement te | te = this.getChild(id) | te order by id)
3213+
}
3214+
32113215
final override Instruction getFirstInstruction(EdgeKind kind) {
3212-
if exists(this.getChild(0))
3213-
then result = this.getChild(0).getFirstInstruction(kind)
3216+
if exists(this.getRankedChild(0))
3217+
then result = this.getRankedChild(0).getFirstInstruction(kind)
32143218
else (
32153219
kind instanceof GotoEdge and result = this.getInstruction(OnlyInstructionTag())
32163220
)
@@ -3230,11 +3234,11 @@ class TranslatedBuiltInOperation extends TranslatedNonConstantExpr {
32303234
}
32313235

32323236
final override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) {
3233-
exists(int id | child = this.getChild(id) |
3234-
result = this.getChild(id + 1).getFirstInstruction(kind)
3237+
exists(int id | child = this.getRankedChild(id) |
3238+
result = this.getRankedChild(id + 1).getFirstInstruction(kind)
32353239
or
32363240
kind instanceof GotoEdge and
3237-
not exists(this.getChild(id + 1)) and
3241+
not exists(this.getRankedChild(id + 1)) and
32383242
result = this.getInstruction(OnlyInstructionTag())
32393243
)
32403244
}
@@ -3249,7 +3253,7 @@ class TranslatedBuiltInOperation extends TranslatedNonConstantExpr {
32493253
tag = OnlyInstructionTag() and
32503254
exists(int index |
32513255
operandTag = positionalArgumentOperand(index) and
3252-
result = this.getChild(index).(TranslatedExpr).getResult()
3256+
result = this.getRankedChild(index).(TranslatedExpr).getResult()
32533257
)
32543258
}
32553259

0 commit comments

Comments
 (0)