File tree Expand file tree Collapse file tree 4 files changed +21
-16
lines changed
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal Expand file tree Collapse file tree 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
88private import Node0ToStringSig
99private import DataFlowUtil
1010
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 ( ) }
1313
14- string operandToString ( Operand op ) {
14+ override string operandToString ( Operand op ) {
1515 result = op .getDumpString ( ) + " @ " + op .getUse ( ) .getResultId ( )
1616 }
1717
18- string toExprString ( Node n ) { none ( ) }
18+ override string toExprString ( Node n ) { none ( ) }
1919}
20-
21- import DebugNode0ToString
Original file line number Diff line number Diff line change 55 * one can import `DebugPrinting.qll` to better correlate the dataflow nodes with their underlying instructions and operands.
66 */
77
8+ import Node0ToStringSig
89import NormalNode0ToString
Original file line number Diff line number Diff line change @@ -7,19 +7,27 @@ private import codeql.util.Unit
77private import DataFlowUtil
88
99/** A signature for a module to control the behavior of `Node.toString`. */
10- signature module Node0ToStringSig {
10+ abstract class Node0ToString extends Unit {
1111 /**
1212 * Gets the string that should be used by `OperandNode.toString`.
1313 */
14- string operandToString ( Operand op ) ;
14+ abstract string operandToString ( Operand op ) ;
1515
1616 /**
1717 * Gets the string that should be used by `InstructionNode.toString`.
1818 */
19- string instructionToString ( Instruction i ) ;
19+ abstract string instructionToString ( Instruction i ) ;
2020
2121 /**
2222 * Gets the string representation of the `Expr` associated with `n`, if any.
2323 */
24- string toExprString ( Node n ) ;
24+ abstract string toExprString ( Node n ) ;
2525}
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
99private import DataFlowUtil
1010private import DataFlowPrivate
1111
12- private module NormalNode0ToStringImpl implements Node0ToStringSig {
13- string instructionToString ( Instruction i ) {
12+ class NormalNode0ToStringImpl extends Node0ToString {
13+ override string instructionToString ( Instruction i ) {
1414 if i .( InitializeParameterInstruction ) .getIRVariable ( ) instanceof IRThisVariable
1515 then result = "this"
1616 else result = i .getAst ( ) .toString ( )
1717 }
1818
19- string operandToString ( Operand op ) {
19+ override string operandToString ( Operand op ) {
2020 if op .getDef ( ) .( InitializeParameterInstruction ) .getIRVariable ( ) instanceof IRThisVariable
2121 then result = "this"
2222 else result = op .getDef ( ) .getAst ( ) .toString ( )
2323 }
2424
25- string toExprString ( Node n ) {
25+ override string toExprString ( Node n ) {
2626 result = n .asExpr ( 0 ) .toString ( )
2727 or
2828 not exists ( n .asExpr ( ) ) and
2929 result = stars ( n ) + n .asIndirectExpr ( 0 , 1 ) .toString ( )
3030 }
3131}
32-
33- import NormalNode0ToStringImpl
You can’t perform that action at this time.
0 commit comments