C++: Fix multiple toString consistency error in use-use dataflow

This commit is contained in:
Jeroen Ketema
2023-03-09 10:08:25 +01:00
parent a2248cb5a0
commit 55da3257bf
5 changed files with 10 additions and 160 deletions

View File

@@ -413,7 +413,11 @@ class InstructionNode extends Node0 {
/** Gets the instruction corresponding to this node. */
Instruction getInstruction() { result = instr }
override string toStringImpl() { result = instr.getAst().toString() }
override string toStringImpl() {
if instr.(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable
then result = "this"
else result = instr.getAst().toString()
}
}
/**
@@ -428,7 +432,11 @@ class OperandNode extends Node, Node0 {
/** Gets the operand corresponding to this node. */
Operand getOperand() { result = op }
override string toStringImpl() { result = op.getDef().getAst().toString() }
override string toStringImpl() {
if op.getDef().(InitializeParameterInstruction).getIRVariable() instanceof IRThisVariable
then result = "this"
else result = op.getDef().getAst().toString()
}
}
/**

View File

@@ -3,18 +3,6 @@ uniqueType
uniqueNodeLocation
missingLocation
uniqueNodeToString
| dispatch.cpp:15:8:15:8 | Middle | Node should have one toString but has 2. |
| dispatch.cpp:15:8:15:8 | Middle indirection | Node should have one toString but has 2. |
| dispatch.cpp:15:8:15:8 | Middle indirection | Node should have one toString but has 2. |
| dispatch.cpp:15:8:15:8 | this | Node should have one toString but has 2. |
| dispatch.cpp:15:8:15:8 | this indirection | Node should have one toString but has 2. |
| dispatch.cpp:15:8:15:8 | this indirection | Node should have one toString but has 2. |
| dispatch.cpp:21:8:21:8 | Bottom | Node should have one toString but has 2. |
| dispatch.cpp:21:8:21:8 | Bottom indirection | Node should have one toString but has 2. |
| dispatch.cpp:21:8:21:8 | Bottom indirection | Node should have one toString but has 2. |
| dispatch.cpp:21:8:21:8 | this | Node should have one toString but has 2. |
| dispatch.cpp:21:8:21:8 | this indirection | Node should have one toString but has 2. |
| dispatch.cpp:21:8:21:8 | this indirection | Node should have one toString but has 2. |
missingToString
parameterCallable
localFlowIsLocal

View File

@@ -3,54 +3,6 @@ uniqueType
uniqueNodeLocation
missingLocation
uniqueNodeToString
| A.cpp:9:9:9:9 | C1 | Node should have one toString but has 2. |
| A.cpp:9:9:9:9 | C1 indirection | Node should have one toString but has 2. |
| A.cpp:9:9:9:9 | C1 indirection | Node should have one toString but has 2. |
| A.cpp:9:9:9:9 | this | Node should have one toString but has 2. |
| A.cpp:9:9:9:9 | this indirection | Node should have one toString but has 2. |
| A.cpp:9:9:9:9 | this indirection | Node should have one toString but has 2. |
| A.cpp:14:9:14:9 | C2 | Node should have one toString but has 2. |
| A.cpp:14:9:14:9 | C2 indirection | Node should have one toString but has 2. |
| A.cpp:14:9:14:9 | C2 indirection | Node should have one toString but has 2. |
| A.cpp:14:9:14:9 | this | Node should have one toString but has 2. |
| A.cpp:14:9:14:9 | this indirection | Node should have one toString but has 2. |
| A.cpp:14:9:14:9 | this indirection | Node should have one toString but has 2. |
| C.cpp:22:3:22:3 | C | Node should have one toString but has 2. |
| C.cpp:22:3:22:3 | C indirection | Node should have one toString but has 2. |
| C.cpp:22:3:22:3 | C indirection | Node should have one toString but has 2. |
| C.cpp:22:3:22:3 | this | Node should have one toString but has 2. |
| C.cpp:22:3:22:3 | this indirection | Node should have one toString but has 2. |
| C.cpp:22:3:22:3 | this indirection | Node should have one toString but has 2. |
| C.cpp:22:9:22:22 | C indirection [post update] | Node should have one toString but has 2. |
| C.cpp:22:9:22:22 | this indirection [post update] | Node should have one toString but has 2. |
| complex.cpp:22:3:22:5 | Bar | Node should have one toString but has 2. |
| complex.cpp:22:3:22:5 | Bar indirection | Node should have one toString but has 2. |
| complex.cpp:22:3:22:5 | Bar indirection | Node should have one toString but has 2. |
| complex.cpp:22:3:22:5 | this | Node should have one toString but has 2. |
| complex.cpp:22:3:22:5 | this indirection | Node should have one toString but has 2. |
| complex.cpp:22:3:22:5 | this indirection | Node should have one toString but has 2. |
| complex.cpp:22:11:22:17 | Bar indirection [post update] | Node should have one toString but has 2. |
| complex.cpp:22:11:22:17 | Bar indirection [post update] | Node should have one toString but has 2. |
| complex.cpp:22:11:22:17 | this indirection [post update] | Node should have one toString but has 2. |
| complex.cpp:22:11:22:17 | this indirection [post update] | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | Outer | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | Outer indirection | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | Outer indirection | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | Outer indirection [post update] | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | Outer indirection [post update] | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | this | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | this indirection | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | this indirection | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | this indirection [post update] | Node should have one toString but has 2. |
| complex.cpp:25:7:25:7 | this indirection [post update] | Node should have one toString but has 2. |
| conflated.cpp:45:3:45:12 | LinkedList | Node should have one toString but has 2. |
| conflated.cpp:45:3:45:12 | LinkedList indirection | Node should have one toString but has 2. |
| conflated.cpp:45:3:45:12 | LinkedList indirection | Node should have one toString but has 2. |
| conflated.cpp:45:3:45:12 | this | Node should have one toString but has 2. |
| conflated.cpp:45:3:45:12 | this indirection | Node should have one toString but has 2. |
| conflated.cpp:45:3:45:12 | this indirection | Node should have one toString but has 2. |
| conflated.cpp:45:34:45:43 | LinkedList indirection [post update] | Node should have one toString but has 2. |
| conflated.cpp:45:34:45:43 | this indirection [post update] | Node should have one toString but has 2. |
missingToString
parameterCallable
localFlowIsLocal
@@ -66,9 +18,7 @@ uniquePostUpdate
| aliasing.cpp:77:11:77:11 | definition of w indirection | Node has multiple PostUpdateNodes. |
| aliasing.cpp:84:11:84:11 | definition of w indirection | Node has multiple PostUpdateNodes. |
| aliasing.cpp:91:11:91:11 | definition of w indirection | Node has multiple PostUpdateNodes. |
| complex.cpp:22:3:22:5 | Bar indirection | Node has multiple PostUpdateNodes. |
| complex.cpp:22:3:22:5 | this indirection | Node has multiple PostUpdateNodes. |
| complex.cpp:25:7:25:7 | Outer indirection | Node has multiple PostUpdateNodes. |
| complex.cpp:25:7:25:7 | this indirection | Node has multiple PostUpdateNodes. |
| complex.cpp:42:10:42:14 | inner indirection | Node has multiple PostUpdateNodes. |
| complex.cpp:43:10:43:14 | inner indirection | Node has multiple PostUpdateNodes. |

View File

@@ -192,9 +192,7 @@ edges
| C.cpp:18:12:18:18 | call to C [s3] | C.cpp:19:5:19:5 | c indirection [s3] |
| C.cpp:19:5:19:5 | c indirection [s1] | C.cpp:27:8:27:11 | this indirection [s1] |
| C.cpp:19:5:19:5 | c indirection [s3] | C.cpp:27:8:27:11 | this indirection [s3] |
| C.cpp:22:9:22:22 | C indirection [post update] [s1] | C.cpp:18:12:18:18 | call to C [s1] |
| C.cpp:22:9:22:22 | this indirection [post update] [s1] | C.cpp:18:12:18:18 | call to C [s1] |
| C.cpp:22:12:22:21 | new | C.cpp:22:9:22:22 | C indirection [post update] [s1] |
| C.cpp:22:12:22:21 | new | C.cpp:22:9:22:22 | this indirection [post update] [s1] |
| C.cpp:22:12:22:21 | new | C.cpp:22:12:22:21 | new |
| C.cpp:24:5:24:25 | ... = ... | C.cpp:24:11:24:12 | this indirection [post update] [s3] |
@@ -1084,9 +1082,6 @@ nodes
| C.cpp:18:12:18:18 | call to C [s3] | semmle.label | call to C [s3] |
| C.cpp:19:5:19:5 | c indirection [s1] | semmle.label | c indirection [s1] |
| C.cpp:19:5:19:5 | c indirection [s3] | semmle.label | c indirection [s3] |
| C.cpp:22:9:22:22 | C indirection [post update] [s1] | semmle.label | C indirection [post update] [s1] |
| C.cpp:22:9:22:22 | C indirection [post update] [s1] | semmle.label | this indirection [post update] [s1] |
| C.cpp:22:9:22:22 | this indirection [post update] [s1] | semmle.label | C indirection [post update] [s1] |
| C.cpp:22:9:22:22 | this indirection [post update] [s1] | semmle.label | this indirection [post update] [s1] |
| C.cpp:22:12:22:21 | new | semmle.label | new |
| C.cpp:22:12:22:21 | new | semmle.label | new |

View File

@@ -28,94 +28,6 @@ uniqueNodeLocation
missingLocation
| Nodes without location: 12 |
uniqueNodeToString
| cpp11.cpp:65:20:65:20 | (unnamed constructor) | Node should have one toString but has 2. |
| cpp11.cpp:65:20:65:20 | (unnamed constructor) indirection | Node should have one toString but has 2. |
| cpp11.cpp:65:20:65:20 | (unnamed constructor) indirection | Node should have one toString but has 2. |
| cpp11.cpp:65:20:65:20 | (unnamed constructor) indirection [post update] | Node should have one toString but has 2. |
| cpp11.cpp:65:20:65:20 | this | Node should have one toString but has 2. |
| cpp11.cpp:65:20:65:20 | this indirection | Node should have one toString but has 2. |
| cpp11.cpp:65:20:65:20 | this indirection | Node should have one toString but has 2. |
| cpp11.cpp:65:20:65:20 | this indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | Base | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | Base indirection | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | Base indirection | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | Base indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | Base indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | this | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | this indirection | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | this indirection | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | this indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:747:8:747:8 | this indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:750:3:750:6 | Base | Node should have one toString but has 2. |
| ir.cpp:750:3:750:6 | Base indirection | Node should have one toString but has 2. |
| ir.cpp:750:3:750:6 | Base indirection | Node should have one toString but has 2. |
| ir.cpp:750:3:750:6 | this | Node should have one toString but has 2. |
| ir.cpp:750:3:750:6 | this indirection | Node should have one toString but has 2. |
| ir.cpp:750:3:750:6 | this indirection | Node should have one toString but has 2. |
| ir.cpp:750:10:750:10 | Base indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:750:10:750:10 | Base indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:750:10:750:10 | this indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:750:10:750:10 | this indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:752:3:752:7 | this | Node should have one toString but has 2. |
| ir.cpp:752:3:752:7 | this indirection | Node should have one toString but has 2. |
| ir.cpp:752:3:752:7 | this indirection | Node should have one toString but has 2. |
| ir.cpp:752:3:752:7 | ~Base | Node should have one toString but has 2. |
| ir.cpp:752:3:752:7 | ~Base indirection | Node should have one toString but has 2. |
| ir.cpp:752:3:752:7 | ~Base indirection | Node should have one toString but has 2. |
| ir.cpp:753:3:753:3 | this indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:753:3:753:3 | ~Base indirection [post update] | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | PolymorphicDerived | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | PolymorphicDerived indirection | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | PolymorphicDerived indirection | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | this | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | this | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | this indirection | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | this indirection | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | this indirection | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | this indirection | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | ~PolymorphicDerived | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | ~PolymorphicDerived indirection | Node should have one toString but has 2. |
| ir.cpp:848:8:848:8 | ~PolymorphicDerived indirection | Node should have one toString but has 2. |
| ir.cpp:869:1:869:14 | String | Node should have one toString but has 2. |
| ir.cpp:869:1:869:14 | String indirection | Node should have one toString but has 2. |
| ir.cpp:869:1:869:14 | String indirection | Node should have one toString but has 2. |
| ir.cpp:869:1:869:14 | this | Node should have one toString but has 2. |
| ir.cpp:869:1:869:14 | this indirection | Node should have one toString but has 2. |
| ir.cpp:869:1:869:14 | this indirection | Node should have one toString but has 2. |
| static_init_templates.cpp:236:7:236:7 | MyDerivedClass | Node should have one toString but has 2. |
| static_init_templates.cpp:236:7:236:7 | MyDerivedClass indirection | Node should have one toString but has 2. |
| static_init_templates.cpp:236:7:236:7 | MyDerivedClass indirection | Node should have one toString but has 2. |
| static_init_templates.cpp:236:7:236:7 | this | Node should have one toString but has 2. |
| static_init_templates.cpp:236:7:236:7 | this indirection | Node should have one toString but has 2. |
| static_init_templates.cpp:236:7:236:7 | this indirection | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | MyContainingClass | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | MyContainingClass indirection | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | MyContainingClass indirection | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | MyContainingClass indirection [post update] | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | MyContainingClass indirection [post update] | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | this | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | this indirection | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | this indirection | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | this indirection [post update] | Node should have one toString but has 2. |
| static_init_templates.cpp:240:7:240:7 | this indirection [post update] | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | exn1 | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | exn1 | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | exn1 indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | exn1 indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | exn1 indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | exn1 indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | this | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | this | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | this | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | this indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | this indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | this indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | this indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | this indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | this indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | ~exn1 | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | ~exn1 indirection | Node should have one toString but has 2. |
| try_catch.cpp:7:8:7:8 | ~exn1 indirection | Node should have one toString but has 2. |
missingToString
parameterCallable
localFlowIsLocal
@@ -136,16 +48,13 @@ uniquePostUpdate
| ir.cpp:516:10:516:11 | definition of r4 indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:659:5:659:5 | this indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:659:5:659:5 | this indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:747:8:747:8 | Base indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:747:8:747:8 | this indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:750:3:750:6 | Base indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:750:3:750:6 | this indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:759:3:759:8 | this indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:768:3:768:9 | this indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:777:3:777:11 | this indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:786:3:786:11 | this indirection | Node has multiple PostUpdateNodes. |
| ir.cpp:795:3:795:11 | this indirection | Node has multiple PostUpdateNodes. |
| static_init_templates.cpp:240:7:240:7 | MyContainingClass indirection | Node has multiple PostUpdateNodes. |
| static_init_templates.cpp:240:7:240:7 | this indirection | Node has multiple PostUpdateNodes. |
postIsInSameCallable
reverseRead