Skip to content

Commit 3970a9f

Browse files
committed
C++: switch to getImplicitDestructorCall
1 parent 3a0290b commit 3970a9f

File tree

6 files changed

+192
-30
lines changed

6 files changed

+192
-30
lines changed

cpp/ql/lib/semmle/code/cpp/PrintAST.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class ExprNode extends AstNode {
310310
result.getAst() = expr.getChild(childIndex)
311311
or
312312
exists(int destructorIndex |
313-
result.getAst() = expr.getSyntheticDestructor(destructorIndex) and
313+
result.getAst() = expr.getImplicitDestructorCall(destructorIndex) and
314314
childIndex = destructorIndex + max(int index | exists(expr.getChild(index)) or index = 0) + 1
315315
)
316316
}
@@ -448,7 +448,7 @@ class StmtNode extends AstNode {
448448
)
449449
or
450450
exists(int destructorIndex |
451-
result.getAst() = stmt.getSyntheticDestructor(destructorIndex) and
451+
result.getAst() = stmt.getImplicitDestructorCall(destructorIndex) and
452452
childIndex = destructorIndex + max(int index | exists(stmt.getChild(index)) or index = 0) + 1
453453
)
454454
}
@@ -676,7 +676,7 @@ private string getChildAccessorWithoutConversions(Locatable parent, Element chil
676676
exists(int n | s.getChild(n) = child and result = "getChild(" + n + ")")
677677
or
678678
exists(int n |
679-
s.getSyntheticDestructor(n) = child and result = "getSyntheticDestructor(" + n + ")"
679+
s.getImplicitDestructorCall(n) = child and result = "getImplicitDestructorCall(" + n + ")"
680680
)
681681
)
682682
or
@@ -687,7 +687,7 @@ private string getChildAccessorWithoutConversions(Locatable parent, Element chil
687687
exists(int n | expr.getChild(n) = child and result = "getChild(" + n + ")")
688688
or
689689
exists(int n |
690-
expr.getSyntheticDestructor(n) = child and result = "getSyntheticDestructor(" + n + ")"
690+
expr.getImplicitDestructorCall(n) = child and result = "getImplicitDestructorCall(" + n + ")"
691691
)
692692
)
693693
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ class Expr extends StmtParent, @expr {
6262
* Gets the `n`th compiler-generated destructor call that is performed after this expression, in
6363
* order of destruction.
6464
*/
65-
DestructorCall getSyntheticDestructor(int n) {
65+
DestructorCall getImplicitDestructorCall(int n) {
6666
synthetic_destructor_call(this, max(int i | synthetic_destructor_call(this, i, _)) - n, result)
6767
}
6868

6969
/**
7070
* Gets a compiler-generated destructor call that is performed after this expression.
7171
*/
72-
DestructorCall getASyntheticDestructor() {
72+
DestructorCall getAnImplicitDestructorCall() {
7373
synthetic_destructor_call(this, _, result)
7474
}
7575

cpp/ql/lib/semmle/code/cpp/stmts/Stmt.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ class Stmt extends StmtParent, @stmt {
6363
* Gets the `n`th compiler-generated destructor call that is performed after this statement, in
6464
* order of destruction.
6565
*/
66-
DestructorCall getSyntheticDestructor(int n) {
66+
DestructorCall getImplicitDestructorCall(int n) {
6767
synthetic_destructor_call(this, max(int i | synthetic_destructor_call(this, i, _)) - n, result)
6868
}
6969

70-
DestructorCall getASyntheticDestructor() {
70+
DestructorCall getAnImplicitDestructorCall() {
7171
synthetic_destructor_call(this, _, result)
7272
}
7373

cpp/ql/test/library-tests/destructors/PrintAST.expected

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ destructors.cpp:
6363
# 13| Type = [IntType] int
6464
# 13| Value = [Literal] 130
6565
# 13| ValueCategory = prvalue
66-
# 14| getSyntheticDestructor(0): [DestructorCall] call to ~C
66+
# 14| getImplicitDestructorCall(0): [DestructorCall] call to ~C
6767
# 14| Type = [VoidType] void
6868
# 14| ValueCategory = prvalue
6969
# 14| getQualifier(): [VariableAccess] c30
@@ -86,13 +86,13 @@ destructors.cpp:
8686
# 17| Type = [IntType] int
8787
# 17| ValueCategory = prvalue(load)
8888
# 17| getThen(): [GotoStmt] goto ...
89-
# 21| getSyntheticDestructor(0): [DestructorCall] call to ~C
89+
# 21| getImplicitDestructorCall(0): [DestructorCall] call to ~C
9090
# 21| Type = [VoidType] void
9191
# 21| ValueCategory = prvalue
9292
# 21| getQualifier(): [VariableAccess] c31
9393
# 21| Type = [Class] C
9494
# 21| ValueCategory = lvalue
95-
# 26| getSyntheticDestructor(1): [DestructorCall] call to ~C
95+
# 26| getImplicitDestructorCall(1): [DestructorCall] call to ~C
9696
# 26| Type = [VoidType] void
9797
# 26| ValueCategory = prvalue
9898
# 26| getQualifier(): [VariableAccess] c20
@@ -118,25 +118,25 @@ destructors.cpp:
118118
# 19| Type = [IntType] int
119119
# 19| ValueCategory = prvalue(load)
120120
# 19| getThen(): [ReturnStmt] return ...
121-
# 21| getSyntheticDestructor(0): [DestructorCall] call to ~C
121+
# 21| getImplicitDestructorCall(0): [DestructorCall] call to ~C
122122
# 21| Type = [VoidType] void
123123
# 21| ValueCategory = prvalue
124124
# 21| getQualifier(): [VariableAccess] c32
125125
# 21| Type = [Class] C
126126
# 21| ValueCategory = lvalue
127-
# 21| getSyntheticDestructor(1): [DestructorCall] call to ~C
127+
# 21| getImplicitDestructorCall(1): [DestructorCall] call to ~C
128128
# 21| Type = [VoidType] void
129129
# 21| ValueCategory = prvalue
130130
# 21| getQualifier(): [VariableAccess] c31
131131
# 21| Type = [Class] C
132132
# 21| ValueCategory = lvalue
133-
# 26| getSyntheticDestructor(2): [DestructorCall] call to ~C
133+
# 26| getImplicitDestructorCall(2): [DestructorCall] call to ~C
134134
# 26| Type = [VoidType] void
135135
# 26| ValueCategory = prvalue
136136
# 26| getQualifier(): [VariableAccess] c20
137137
# 26| Type = [Class] C
138138
# 26| ValueCategory = lvalue
139-
# 35| getSyntheticDestructor(3): [DestructorCall] call to ~C
139+
# 35| getImplicitDestructorCall(3): [DestructorCall] call to ~C
140140
# 35| Type = [VoidType] void
141141
# 35| ValueCategory = prvalue
142142
# 35| getQualifier(): [VariableAccess] c10
@@ -157,19 +157,19 @@ destructors.cpp:
157157
# 20| Type = [IntType] int
158158
# 20| Value = [Literal] 133
159159
# 20| ValueCategory = prvalue
160-
# 21| getSyntheticDestructor(0): [DestructorCall] call to ~C
160+
# 21| getImplicitDestructorCall(0): [DestructorCall] call to ~C
161161
# 21| Type = [VoidType] void
162162
# 21| ValueCategory = prvalue
163163
# 21| getQualifier(): [VariableAccess] c33
164164
# 21| Type = [Class] C
165165
# 21| ValueCategory = lvalue
166-
# 21| getSyntheticDestructor(1): [DestructorCall] call to ~C
166+
# 21| getImplicitDestructorCall(1): [DestructorCall] call to ~C
167167
# 21| Type = [VoidType] void
168168
# 21| ValueCategory = prvalue
169169
# 21| getQualifier(): [VariableAccess] c32
170170
# 21| Type = [Class] C
171171
# 21| ValueCategory = lvalue
172-
# 21| getSyntheticDestructor(2): [DestructorCall] call to ~C
172+
# 21| getImplicitDestructorCall(2): [DestructorCall] call to ~C
173173
# 21| Type = [VoidType] void
174174
# 21| ValueCategory = prvalue
175175
# 21| getQualifier(): [VariableAccess] c31
@@ -187,7 +187,7 @@ destructors.cpp:
187187
# 23| Type = [IntType] int
188188
# 23| Value = [Literal] 134
189189
# 23| ValueCategory = prvalue
190-
# 24| getSyntheticDestructor(0): [DestructorCall] call to ~C
190+
# 24| getImplicitDestructorCall(0): [DestructorCall] call to ~C
191191
# 24| Type = [VoidType] void
192192
# 24| ValueCategory = prvalue
193193
# 24| getQualifier(): [VariableAccess] c34
@@ -204,13 +204,13 @@ destructors.cpp:
204204
# 25| Type = [IntType] int
205205
# 25| Value = [Literal] 121
206206
# 25| ValueCategory = prvalue
207-
# 26| getSyntheticDestructor(0): [DestructorCall] call to ~C
207+
# 26| getImplicitDestructorCall(0): [DestructorCall] call to ~C
208208
# 26| Type = [VoidType] void
209209
# 26| ValueCategory = prvalue
210210
# 26| getQualifier(): [VariableAccess] c21
211211
# 26| Type = [Class] C
212212
# 26| ValueCategory = lvalue
213-
# 26| getSyntheticDestructor(1): [DestructorCall] call to ~C
213+
# 26| getImplicitDestructorCall(1): [DestructorCall] call to ~C
214214
# 26| Type = [VoidType] void
215215
# 26| ValueCategory = prvalue
216216
# 26| getQualifier(): [VariableAccess] c20
@@ -228,7 +228,7 @@ destructors.cpp:
228228
# 28| Type = [IntType] int
229229
# 28| Value = [Literal] 122
230230
# 28| ValueCategory = prvalue
231-
# 29| getSyntheticDestructor(0): [DestructorCall] call to ~C
231+
# 29| getImplicitDestructorCall(0): [DestructorCall] call to ~C
232232
# 29| Type = [VoidType] void
233233
# 29| ValueCategory = prvalue
234234
# 29| getQualifier(): [VariableAccess] c22
@@ -247,7 +247,7 @@ destructors.cpp:
247247
# 32| Type = [IntType] int
248248
# 32| Value = [Literal] 123
249249
# 32| ValueCategory = prvalue
250-
# 33| getSyntheticDestructor(0): [DestructorCall] call to ~C
250+
# 33| getImplicitDestructorCall(0): [DestructorCall] call to ~C
251251
# 33| Type = [VoidType] void
252252
# 33| ValueCategory = prvalue
253253
# 33| getQualifier(): [VariableAccess] c23
@@ -265,13 +265,13 @@ destructors.cpp:
265265
# 34| Value = [Literal] 111
266266
# 34| ValueCategory = prvalue
267267
# 35| getStmt(5): [ReturnStmt] return ...
268-
# 35| getSyntheticDestructor(0): [DestructorCall] call to ~C
268+
# 35| getImplicitDestructorCall(0): [DestructorCall] call to ~C
269269
# 35| Type = [VoidType] void
270270
# 35| ValueCategory = prvalue
271271
# 35| getQualifier(): [VariableAccess] c11
272272
# 35| Type = [Class] C
273273
# 35| ValueCategory = lvalue
274-
# 35| getSyntheticDestructor(1): [DestructorCall] call to ~C
274+
# 35| getImplicitDestructorCall(1): [DestructorCall] call to ~C
275275
# 35| Type = [VoidType] void
276276
# 35| ValueCategory = prvalue
277277
# 35| getQualifier(): [VariableAccess] c10
@@ -341,7 +341,7 @@ destructors2.cpp:
341341
# 23| ValueCategory = prvalue(load)
342342
# 23| getThen(): [BlockStmt] { ... }
343343
# 24| getStmt(0): [ReturnStmt] return ...
344-
# 27| getSyntheticDestructor(0): [DestructorCall] call to ~Class2
344+
# 27| getImplicitDestructorCall(0): [DestructorCall] call to ~Class2
345345
# 27| Type = [VoidType] void
346346
# 27| ValueCategory = prvalue
347347
# 27| getQualifier(): [VariableAccess] c
@@ -369,13 +369,13 @@ destructors2.cpp:
369369
# 26| Type = [SpecifiedType] const Class2
370370
# 26| ValueCategory = lvalue
371371
# 27| getStmt(3): [ReturnStmt] return ...
372-
# 27| getSyntheticDestructor(0): [DestructorCall] call to ~Inner
372+
# 27| getImplicitDestructorCall(0): [DestructorCall] call to ~Inner
373373
# 27| Type = [VoidType] void
374374
# 27| ValueCategory = prvalue
375375
# 27| getQualifier(): [VariableAccess] inner
376376
# 27| Type = [NestedClass] Inner
377377
# 27| ValueCategory = lvalue
378-
# 27| getSyntheticDestructor(1): [DestructorCall] call to ~Class2
378+
# 27| getImplicitDestructorCall(1): [DestructorCall] call to ~Class2
379379
# 27| Type = [VoidType] void
380380
# 27| ValueCategory = prvalue
381381
# 27| getQualifier(): [VariableAccess] c
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import cpp
22

33
query predicate exprDestructors(Expr e, int i, DestructorCall d, Expr destructed) {
4-
d = e.getSyntheticDestructor(i) and
4+
d = e.getImplicitDestructorCall(i) and
55
d.getQualifier() = destructed
66
}
77

88
query predicate stmtDestructors(Stmt s, int i, DestructorCall d, Expr destructed) {
9-
d = s.getSyntheticDestructor(i) and
9+
d = s.getImplicitDestructorCall(i) and
1010
d.getQualifier() = destructed
1111
}

0 commit comments

Comments
 (0)