33 * `toString` for `Instruction` and `Operand` dataflow nodes.
44 */
55
6+ private import cpp
67private import semmle.code.cpp.ir.IR
78private import codeql.util.Unit
89private import Node0ToString
910private import DataFlowUtil
1011private import DataFlowPrivate
1112
13+ /**
14+ * Gets the string representation of the unconverted expression `loc` if
15+ * `loc` is an `Expression`.
16+ *
17+ * Otherwise, this gets the string representation of `loc`.
18+ */
19+ private string unconvertedAstToString ( Locatable loc ) {
20+ result = loc .( Expr ) .getUnconverted ( ) .toString ( )
21+ or
22+ not loc instanceof Expr and
23+ result = loc .toString ( )
24+ }
25+
1226private class NormalNode0ToString extends Node0ToString {
1327 NormalNode0ToString ( ) {
1428 // Silence warning about `this` not being bound.
@@ -18,14 +32,10 @@ private class NormalNode0ToString extends Node0ToString {
1832 override string instructionToString ( Instruction i ) {
1933 if i .( InitializeParameterInstruction ) .getIRVariable ( ) instanceof IRThisVariable
2034 then result = "this"
21- else result = i .getAst ( ) . toString ( )
35+ else result = unconvertedAstToString ( i .getAst ( ) )
2236 }
2337
24- override string operandToString ( Operand op ) {
25- if op .getDef ( ) .( InitializeParameterInstruction ) .getIRVariable ( ) instanceof IRThisVariable
26- then result = "this"
27- else result = op .getDef ( ) .getAst ( ) .toString ( )
28- }
38+ override string operandToString ( Operand op ) { result = this .instructionToString ( op .getDef ( ) ) }
2939
3040 override string toExprString ( Node n ) {
3141 result = n .asExpr ( 0 ) .toString ( )
0 commit comments