Skip to content

Commit 9eaa4e1

Browse files
committed
C++: Add IR construction for vacuous destructor calls.
1 parent fbb0ffc commit 9eaa4e1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,43 @@ class TranslatedDestructorFieldDestruction extends TranslatedNonConstantExpr, St
22082208
private TranslatedExpr getDestructorCall() { result = getTranslatedExpr(expr.getExpr()) }
22092209
}
22102210

2211+
/**
2212+
* The IR translation of a vacuous destructor call. That is, an expression that
2213+
* looks like a destructor call, but has no effect.
2214+
*
2215+
* Note that, even though there's no destructor call, we should still evaluate
2216+
* the qualifier.
2217+
*/
2218+
class TranslatedVacuousDestructorCall extends TranslatedNonConstantExpr {
2219+
override VacuousDestructorCall expr;
2220+
2221+
override Instruction getInstructionSuccessor(InstructionTag tag, EdgeKind kind) { none() }
2222+
2223+
final TranslatedExpr getQualifier() {
2224+
result = getTranslatedExpr(expr.getQualifier().getFullyConverted())
2225+
}
2226+
2227+
override Instruction getFirstInstruction(EdgeKind kind) {
2228+
result = this.getQualifier().getFirstInstruction(kind)
2229+
}
2230+
2231+
override Instruction getChildSuccessor(TranslatedElement child, EdgeKind kind) {
2232+
child = this.getQualifier() and
2233+
result = this.getParent().getChildSuccessor(this, kind)
2234+
}
2235+
2236+
override TranslatedElement getChild(int id) {
2237+
id = 0 and
2238+
result = this.getQualifier()
2239+
}
2240+
2241+
override Instruction getResult() { none() }
2242+
2243+
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
2244+
none()
2245+
}
2246+
}
2247+
22112248
/**
22122249
* The IR translation of the `?:` operator. This class has the portions of the implementation that
22132250
* are shared between the standard three-operand form (`a ? b : c`) and the GCC-extension

0 commit comments

Comments
 (0)