GeezerVison is showing github.com — C++: Add comments. · github/codeql@49600c1
File tree
Expand file treeCollapse file tree
Open diff view settings
cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1446,15 +1446,31 @@ module Public { |
1446 | 1446 | not def instanceof PhiNode |
1447 | 1447 | } |
1448 | 1448 |
|
| 1449 | + /** |
| 1450 | + * The `getAnUltimateDefinition` predicate uses an optimized step relation |
| 1451 | + * which is pruned to only those uncertain steps which lead back to a |
| 1452 | + * definition which satisfies `relevantUltimateDefinition`. This predicate |
| 1453 | + * computes the subset of `Definition`s which can lead back to definitions |
| 1454 | + * which satisfy `relevantUltimateDefinition`. |
| 1455 | + */ |
1449 | 1456 | private predicate fwd(Definition def) { |
| 1457 | + // Base case: This definition is a relevant definition |
1450 | 1458 | relevantUltimateDefinition(def) |
1451 | 1459 | or |
1452 | 1460 | exists(Definition def0 | |
| 1461 | + // Recursive case: `def0` is a relevant definition, and |
| 1462 | + // `def` is an uncertain step which takes us back to `def0`. |
1453 | 1463 | fwd(def0) and |
1454 | 1464 | def0 = getAPhiInputOrPriorDefinition(def) |
1455 | 1465 | ) |
1456 | 1466 | } |
1457 | 1467 |
|
| 1468 | + /** |
| 1469 | + * Holds if `def1 = getAPhiInputOrPriorDefinition(def2)`, and |
| 1470 | + * both `def1` and `def2` are part of a sequence of uncertain |
| 1471 | + * steps which lead back to a `Definition` which |
| 1472 | + * satisfies `relevantUltimateDefinition`. |
| 1473 | + */ |
1458 | 1474 | private predicate step(Definition def1, Definition def2) { |
1459 | 1475 | fwd(def1) and |
1460 | 1476 | fwd(def2) and |
|