Skip to content

Commit e68cb84

Browse files
authored
Merge pull request #22914 from aschackmull/ssa/postupdate
SSA: Refactor post-update support in DataFlowIntegration.
2 parents fdf5c84 + f6d51da commit e68cb84

4 files changed

Lines changed: 185 additions & 114 deletions

File tree

‎cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImplCommon.qll‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ private module IteratorIndirections {
217217
)
218218
}
219219

220+
// A by-value crement result loads the iterator, rather than aliasing its address.
221+
override predicate isAdditionalDereference(Instruction deref, Operand address) {
222+
exists(CallInstruction call |
223+
deref = call and
224+
call.getStaticCallTarget() instanceof Iterator::IteratorCrementMemberOperator and
225+
not call.getResultType() instanceof Cpp::ReferenceType and
226+
address = call.getThisArgumentOperand()
227+
)
228+
}
229+
220230
override predicate isAdditionalConversionFlow(Operand opFrom, Instruction instrTo) {
221231
// This is a bit annoying: Consider the following snippet:
222232
// ```
@@ -255,11 +265,11 @@ private module IteratorIndirections {
255265
store.getDestinationAddress() = var
256266
)
257267
or
258-
// A call to `operator++` or `operator--` is the iterator equivalent version of a
259-
// pointer arithmetic instruction.
268+
// A reference-returning `operator++` or `operator--` preserves the iterator's address.
260269
exists(CallInstruction call |
261270
instrTo = call and
262271
call.getStaticCallTarget() instanceof Iterator::IteratorCrementMemberOperator and
272+
call.getResultType() instanceof Cpp::ReferenceType and
263273
opFrom = call.getThisArgumentOperand()
264274
)
265275
}
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
| Definition cannot reach a read | 0 |
2-
| End of a basic block can be reached by multiple definitions | 0 |
3-
| Phi has less than 2 immediately prior references | 0 |
4-
| Phi node has less than two inputs | 0 |
5-
| Phi read has less than 2 immediately prior references | 0 |
6-
| Read can be reached from multiple definitions | 0 |
7-
| Read cannot be reached from a definition | 0 |
8-
| Read does not have a prior reference | 0 |
9-
| Read has multiple prior references | 0 |
10-
| Read is not dominated by a definition | 0 |

0 commit comments

Comments
 (0)