File tree 4 files changed +21
-16
lines changed
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal
4 files changed +21
-16
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,12 @@ private import codeql.util.Unit
8
8
private import Node0ToStringSig
9
9
private import DataFlowUtil
10
10
11
- private module DebugNode0ToString implements Node0ToStringSig {
12
- string instructionToString ( Instruction i ) { result = i .getDumpString ( ) }
11
+ class DebugNode0ToString extends Node0ToString {
12
+ override string instructionToString ( Instruction i ) { result = i .getDumpString ( ) }
13
13
14
- string operandToString ( Operand op ) {
14
+ override string operandToString ( Operand op ) {
15
15
result = op .getDumpString ( ) + " @ " + op .getUse ( ) .getResultId ( )
16
16
}
17
17
18
- string toExprString ( Node n ) { none ( ) }
18
+ override string toExprString ( Node n ) { none ( ) }
19
19
}
20
-
21
- import DebugNode0ToString
Original file line number Diff line number Diff line change 5
5
* one can import `DebugPrinting.qll` to better correlate the dataflow nodes with their underlying instructions and operands.
6
6
*/
7
7
8
+ import Node0ToStringSig
8
9
import NormalNode0ToString
Original file line number Diff line number Diff line change @@ -7,19 +7,27 @@ private import codeql.util.Unit
7
7
private import DataFlowUtil
8
8
9
9
/** A signature for a module to control the behavior of `Node.toString`. */
10
- signature module Node0ToStringSig {
10
+ abstract class Node0ToString extends Unit {
11
11
/**
12
12
* Gets the string that should be used by `OperandNode.toString`.
13
13
*/
14
- string operandToString ( Operand op ) ;
14
+ abstract string operandToString ( Operand op ) ;
15
15
16
16
/**
17
17
* Gets the string that should be used by `InstructionNode.toString`.
18
18
*/
19
- string instructionToString ( Instruction i ) ;
19
+ abstract string instructionToString ( Instruction i ) ;
20
20
21
21
/**
22
22
* Gets the string representation of the `Expr` associated with `n`, if any.
23
23
*/
24
- string toExprString ( Node n ) ;
24
+ abstract string toExprString ( Node n ) ;
25
25
}
26
+
27
+ string operandToString ( Operand op ) { result = any ( Node0ToString s ) .operandToString ( op ) }
28
+
29
+ string instructionToString ( Instruction instr ) {
30
+ result = any ( Node0ToString s ) .instructionToString ( instr )
31
+ }
32
+
33
+ string toExprString ( Node n ) { result = any ( Node0ToString s ) .toExprString ( n ) }
Original file line number Diff line number Diff line change @@ -9,25 +9,23 @@ private import Node0ToStringSig
9
9
private import DataFlowUtil
10
10
private import DataFlowPrivate
11
11
12
- private module NormalNode0ToStringImpl implements Node0ToStringSig {
13
- string instructionToString ( Instruction i ) {
12
+ class NormalNode0ToStringImpl extends Node0ToString {
13
+ override string instructionToString ( Instruction i ) {
14
14
if i .( InitializeParameterInstruction ) .getIRVariable ( ) instanceof IRThisVariable
15
15
then result = "this"
16
16
else result = i .getAst ( ) .toString ( )
17
17
}
18
18
19
- string operandToString ( Operand op ) {
19
+ override string operandToString ( Operand op ) {
20
20
if op .getDef ( ) .( InitializeParameterInstruction ) .getIRVariable ( ) instanceof IRThisVariable
21
21
then result = "this"
22
22
else result = op .getDef ( ) .getAst ( ) .toString ( )
23
23
}
24
24
25
- string toExprString ( Node n ) {
25
+ override string toExprString ( Node n ) {
26
26
result = n .asExpr ( 0 ) .toString ( )
27
27
or
28
28
not exists ( n .asExpr ( ) ) and
29
29
result = stars ( n ) + n .asIndirectExpr ( 0 , 1 ) .toString ( )
30
30
}
31
31
}
32
-
33
- import NormalNode0ToStringImpl
You can’t perform that action at this time.
0 commit comments