@@ -40,10 +40,10 @@ abstract class TranslatedCall extends TranslatedExpr {
4040 id = this .getNumberOfArguments ( ) and result = this .getSideEffects ( )
4141 }
4242
43- final override Instruction getFirstInstruction ( ) {
43+ final override Instruction getFirstInstruction ( EdgeKind kind ) {
4444 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 )
4747 }
4848
4949 override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType resultType ) {
@@ -53,19 +53,18 @@ abstract class TranslatedCall extends TranslatedExpr {
5353 }
5454
5555 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
6968 )
7069 )
7170 or
@@ -81,9 +80,8 @@ abstract class TranslatedCall extends TranslatedExpr {
8180 }
8281
8382 override Instruction getInstructionSuccessor ( InstructionTag tag , EdgeKind kind ) {
84- kind instanceof GotoEdge and
8583 tag = CallTag ( ) and
86- result = this .getSideEffects ( ) .getFirstInstruction ( )
84+ result = this .getSideEffects ( ) .getFirstInstruction ( kind )
8785 }
8886
8987 override Instruction getInstructionRegisterOperand ( InstructionTag tag , OperandTag operandTag ) {
@@ -125,8 +123,8 @@ abstract class TranslatedCall extends TranslatedExpr {
125123 * it can be overridden by a subclass for cases where there is a call target
126124 * that is not computed from an expression (e.g. a direct call).
127125 */
128- Instruction getFirstCallTargetInstruction ( ) {
129- result = this .getCallTarget ( ) .getFirstInstruction ( )
126+ Instruction getFirstCallTargetInstruction ( EdgeKind kind ) {
127+ result = this .getCallTarget ( ) .getFirstInstruction ( kind )
130128 }
131129
132130 /**
@@ -163,10 +161,12 @@ abstract class TranslatedCall extends TranslatedExpr {
163161 * If there are any arguments, gets the first instruction of the first
164162 * argument. Otherwise, returns the call instruction.
165163 */
166- final Instruction getFirstArgumentOrCallInstruction ( ) {
164+ final Instruction getFirstArgumentOrCallInstruction ( EdgeKind kind ) {
167165 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+ )
170170 }
171171
172172 /**
@@ -211,7 +211,7 @@ abstract class TranslatedSideEffects extends TranslatedElement {
211211 exists ( int i |
212212 this .getChild ( i ) = te and
213213 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 )
215215 else result = this .getParent ( ) .getChildSuccessor ( this , kind )
216216 )
217217 }
@@ -220,12 +220,12 @@ abstract class TranslatedSideEffects extends TranslatedElement {
220220 none ( )
221221 }
222222
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 )
225225 or
226226 // Some functions, like `std::move()`, have no side effects whatsoever.
227227 not exists ( this .getChild ( 0 ) ) and
228- result = this .getParent ( ) .getChildSuccessor ( this , any ( GotoEdge edge ) )
228+ result = this .getParent ( ) .getChildSuccessor ( this , kind )
229229 }
230230
231231 final override Instruction getInstructionSuccessor ( InstructionTag tag , EdgeKind kind ) { none ( ) }
@@ -240,8 +240,9 @@ abstract class TranslatedSideEffects extends TranslatedElement {
240240 * (`TranslatedAllocatorCall`).
241241 */
242242abstract 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
245246 }
246247
247248 final override Instruction getCallTargetResult ( ) { result = this .getInstruction ( CallTargetTag ( ) ) }
@@ -258,8 +259,7 @@ abstract class TranslatedDirectCall extends TranslatedCall {
258259 result = TranslatedCall .super .getInstructionSuccessor ( tag , kind )
259260 or
260261 tag = CallTargetTag ( ) and
261- kind instanceof GotoEdge and
262- result = this .getFirstArgumentOrCallInstruction ( )
262+ result = this .getFirstArgumentOrCallInstruction ( kind )
263263 }
264264}
265265
@@ -383,8 +383,9 @@ abstract class TranslatedSideEffect extends TranslatedElement {
383383
384384 final override Instruction getChildSuccessor ( TranslatedElement child , EdgeKind kind ) { none ( ) }
385385
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
388389 }
389390
390391 final override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType type ) {
0 commit comments