@@ -40,10 +40,10 @@ abstract class TranslatedCall extends TranslatedExpr {
40
40
id = this .getNumberOfArguments ( ) and result = this .getSideEffects ( )
41
41
}
42
42
43
- final override Instruction getFirstInstruction ( ) {
43
+ final override Instruction getFirstInstruction ( EdgeKind kind ) {
44
44
if exists ( this .getQualifier ( ) )
45
- then result = this .getQualifier ( ) .getFirstInstruction ( )
46
- else result = this .getFirstCallTargetInstruction ( )
45
+ then result = this .getQualifier ( ) .getFirstInstruction ( kind )
46
+ else result = this .getFirstCallTargetInstruction ( kind )
47
47
}
48
48
49
49
override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType resultType ) {
@@ -53,19 +53,18 @@ abstract class TranslatedCall extends TranslatedExpr {
53
53
}
54
54
55
55
override Instruction getChildSuccessor ( TranslatedElement child , EdgeKind kind ) {
56
- kind instanceof GotoEdge and
57
- (
58
- child = this .getQualifier ( ) and
59
- result = this .getFirstCallTargetInstruction ( )
60
- or
61
- child = this .getCallTarget ( ) and
62
- result = this .getFirstArgumentOrCallInstruction ( )
63
- or
64
- exists ( int argIndex |
65
- child = this .getArgument ( argIndex ) and
66
- if exists ( this .getArgument ( argIndex + 1 ) )
67
- then result = this .getArgument ( argIndex + 1 ) .getFirstInstruction ( )
68
- else result = this .getInstruction ( CallTag ( ) )
56
+ child = this .getQualifier ( ) and
57
+ result = this .getFirstCallTargetInstruction ( kind )
58
+ or
59
+ child = this .getCallTarget ( ) and
60
+ result = this .getFirstArgumentOrCallInstruction ( kind )
61
+ or
62
+ exists ( int argIndex |
63
+ child = this .getArgument ( argIndex ) and
64
+ if exists ( this .getArgument ( argIndex + 1 ) )
65
+ then result = this .getArgument ( argIndex + 1 ) .getFirstInstruction ( kind )
66
+ else (
67
+ result = this .getInstruction ( CallTag ( ) ) and kind instanceof GotoEdge
69
68
)
70
69
)
71
70
or
@@ -81,9 +80,8 @@ abstract class TranslatedCall extends TranslatedExpr {
81
80
}
82
81
83
82
override Instruction getInstructionSuccessor ( InstructionTag tag , EdgeKind kind ) {
84
- kind instanceof GotoEdge and
85
83
tag = CallTag ( ) and
86
- result = this .getSideEffects ( ) .getFirstInstruction ( )
84
+ result = this .getSideEffects ( ) .getFirstInstruction ( kind )
87
85
}
88
86
89
87
override Instruction getInstructionRegisterOperand ( InstructionTag tag , OperandTag operandTag ) {
@@ -125,8 +123,8 @@ abstract class TranslatedCall extends TranslatedExpr {
125
123
* it can be overridden by a subclass for cases where there is a call target
126
124
* that is not computed from an expression (e.g. a direct call).
127
125
*/
128
- Instruction getFirstCallTargetInstruction ( ) {
129
- result = this .getCallTarget ( ) .getFirstInstruction ( )
126
+ Instruction getFirstCallTargetInstruction ( EdgeKind kind ) {
127
+ result = this .getCallTarget ( ) .getFirstInstruction ( kind )
130
128
}
131
129
132
130
/**
@@ -163,10 +161,12 @@ abstract class TranslatedCall extends TranslatedExpr {
163
161
* If there are any arguments, gets the first instruction of the first
164
162
* argument. Otherwise, returns the call instruction.
165
163
*/
166
- final Instruction getFirstArgumentOrCallInstruction ( ) {
164
+ final Instruction getFirstArgumentOrCallInstruction ( EdgeKind kind ) {
167
165
if this .hasArguments ( )
168
- then result = this .getArgument ( 0 ) .getFirstInstruction ( )
169
- else result = this .getInstruction ( CallTag ( ) )
166
+ then result = this .getArgument ( 0 ) .getFirstInstruction ( kind )
167
+ else (
168
+ kind instanceof GotoEdge and result = this .getInstruction ( CallTag ( ) )
169
+ )
170
170
}
171
171
172
172
/**
@@ -211,7 +211,7 @@ abstract class TranslatedSideEffects extends TranslatedElement {
211
211
exists ( int i |
212
212
this .getChild ( i ) = te and
213
213
if exists ( this .getChild ( i + 1 ) )
214
- then kind instanceof GotoEdge and result = this .getChild ( i + 1 ) .getFirstInstruction ( )
214
+ then result = this .getChild ( i + 1 ) .getFirstInstruction ( kind )
215
215
else result = this .getParent ( ) .getChildSuccessor ( this , kind )
216
216
)
217
217
}
@@ -220,12 +220,12 @@ abstract class TranslatedSideEffects extends TranslatedElement {
220
220
none ( )
221
221
}
222
222
223
- final override Instruction getFirstInstruction ( ) {
224
- result = this .getChild ( 0 ) .getFirstInstruction ( )
223
+ final override Instruction getFirstInstruction ( EdgeKind kind ) {
224
+ result = this .getChild ( 0 ) .getFirstInstruction ( kind )
225
225
or
226
226
// Some functions, like `std::move()`, have no side effects whatsoever.
227
227
not exists ( this .getChild ( 0 ) ) and
228
- result = this .getParent ( ) .getChildSuccessor ( this , any ( GotoEdge edge ) )
228
+ result = this .getParent ( ) .getChildSuccessor ( this , kind )
229
229
}
230
230
231
231
final override Instruction getInstructionSuccessor ( InstructionTag tag , EdgeKind kind ) { none ( ) }
@@ -240,8 +240,9 @@ abstract class TranslatedSideEffects extends TranslatedElement {
240
240
* (`TranslatedAllocatorCall`).
241
241
*/
242
242
abstract class TranslatedDirectCall extends TranslatedCall {
243
- final override Instruction getFirstCallTargetInstruction ( ) {
244
- result = this .getInstruction ( CallTargetTag ( ) )
243
+ final override Instruction getFirstCallTargetInstruction ( EdgeKind kind ) {
244
+ result = this .getInstruction ( CallTargetTag ( ) ) and
245
+ kind instanceof GotoEdge
245
246
}
246
247
247
248
final override Instruction getCallTargetResult ( ) { result = this .getInstruction ( CallTargetTag ( ) ) }
@@ -258,8 +259,7 @@ abstract class TranslatedDirectCall extends TranslatedCall {
258
259
result = TranslatedCall .super .getInstructionSuccessor ( tag , kind )
259
260
or
260
261
tag = CallTargetTag ( ) and
261
- kind instanceof GotoEdge and
262
- result = this .getFirstArgumentOrCallInstruction ( )
262
+ result = this .getFirstArgumentOrCallInstruction ( kind )
263
263
}
264
264
}
265
265
@@ -383,8 +383,9 @@ abstract class TranslatedSideEffect extends TranslatedElement {
383
383
384
384
final override Instruction getChildSuccessor ( TranslatedElement child , EdgeKind kind ) { none ( ) }
385
385
386
- final override Instruction getFirstInstruction ( ) {
387
- result = this .getInstruction ( OnlyInstructionTag ( ) )
386
+ final override Instruction getFirstInstruction ( EdgeKind kind ) {
387
+ result = this .getInstruction ( OnlyInstructionTag ( ) ) and
388
+ kind instanceof GotoEdge
388
389
}
389
390
390
391
final override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType type ) {
0 commit comments