mirror of
https://github.com/github/codeql.git
synced 2026-04-23 15:55:18 +02:00
C++: Go back to abstract classes.
This commit is contained in:
@@ -8,14 +8,12 @@ private import codeql.util.Unit
|
||||
private import Node0ToStringSig
|
||||
private import DataFlowUtil
|
||||
|
||||
private module DebugNode0ToString implements Node0ToStringSig {
|
||||
string instructionToString(Instruction i) { result = i.getDumpString() }
|
||||
class DebugNode0ToString extends Node0ToString {
|
||||
override string instructionToString(Instruction i) { result = i.getDumpString() }
|
||||
|
||||
string operandToString(Operand op) {
|
||||
override string operandToString(Operand op) {
|
||||
result = op.getDumpString() + " @ " + op.getUse().getResultId()
|
||||
}
|
||||
|
||||
string toExprString(Node n) { none() }
|
||||
override string toExprString(Node n) { none() }
|
||||
}
|
||||
|
||||
import DebugNode0ToString
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
* one can import `DebugPrinting.qll` to better correlate the dataflow nodes with their underlying instructions and operands.
|
||||
*/
|
||||
|
||||
import Node0ToStringSig
|
||||
import NormalNode0ToString
|
||||
|
||||
@@ -7,19 +7,27 @@ private import codeql.util.Unit
|
||||
private import DataFlowUtil
|
||||
|
||||
/** A signature for a module to control the behavior of `Node.toString`. */
|
||||
signature module Node0ToStringSig {
|
||||
abstract class Node0ToString extends Unit {
|
||||
/**
|
||||
* Gets the string that should be used by `OperandNode.toString`.
|
||||
*/
|
||||
string operandToString(Operand op);
|
||||
abstract string operandToString(Operand op);
|
||||
|
||||
/**
|
||||
* Gets the string that should be used by `InstructionNode.toString`.
|
||||
*/
|
||||
string instructionToString(Instruction i);
|
||||
abstract string instructionToString(Instruction i);
|
||||
|
||||
/**
|
||||
* Gets the string representation of the `Expr` associated with `n`, if any.
|
||||
*/
|
||||
string toExprString(Node n);
|
||||
abstract string toExprString(Node n);
|
||||
}
|
||||
|
||||
string operandToString(Operand op) { result = any(Node0ToString s).operandToString(op) }
|
||||
|
||||
string instructionToString(Instruction instr) {
|
||||
result = any(Node0ToString s).instructionToString(instr)
|
||||
}
|
||||
|
||||
string toExprString(Node n) { result = any(Node0ToString s).toExprString(n) }
|
||||
|
||||
@@ -9,25 +9,23 @@ private import Node0ToStringSig
|
||||
private import DataFlowUtil
|
||||
private import DataFlowPrivate
|
||||
|
||||
private module NormalNode0ToStringImpl implements Node0ToStringSig {
|
||||
string instructionToString(Instruction i) {
|
||||
class NormalNode0ToStringImpl extends Node0ToString {
|
||||
override string instructionToString(Instruction i) {
|
||||
if i.(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable
|
||||
then result = "this"
|
||||
else result = i.getAst().toString()
|
||||
}
|
||||
|
||||
string operandToString(Operand op) {
|
||||
override string operandToString(Operand op) {
|
||||
if op.getDef().(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable
|
||||
then result = "this"
|
||||
else result = op.getDef().getAst().toString()
|
||||
}
|
||||
|
||||
string toExprString(Node n) {
|
||||
override string toExprString(Node n) {
|
||||
result = n.asExpr(0).toString()
|
||||
or
|
||||
not exists(n.asExpr()) and
|
||||
result = stars(n) + n.asIndirectExpr(0, 1).toString()
|
||||
}
|
||||
}
|
||||
|
||||
import NormalNode0ToStringImpl
|
||||
|
||||
Reference in New Issue
Block a user