|
5 | 5 | */
|
6 | 6 |
|
7 | 7 | import go
|
| 8 | +private import codeql.ssa.Ssa as SsaImplCommon |
8 | 9 |
|
9 | 10 | cached
|
10 | 11 | private module Internal {
|
@@ -460,6 +461,54 @@ private module Internal {
|
460 | 461 | firstUse(def, use2)
|
461 | 462 | )
|
462 | 463 | }
|
| 464 | + |
| 465 | + private module SsaInput implements SsaImplCommon::InputSig<Location> { |
| 466 | + private import go as G |
| 467 | + |
| 468 | + class BasicBlock = G::BasicBlock; |
| 469 | + |
| 470 | + class ControlFlowNode = G::ControlFlow::Node; |
| 471 | + |
| 472 | + BasicBlock getImmediateBasicBlockDominator(BasicBlock bb) { |
| 473 | + result = bb.getImmediateDominator() |
| 474 | + } |
| 475 | + |
| 476 | + BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getASuccessor() } |
| 477 | + |
| 478 | + class SourceVariable = SsaSourceVariable; |
| 479 | + |
| 480 | + /** |
| 481 | + * Holds if the `i`th node of basic block `bb` is a (potential) write to source |
| 482 | + * variable `v`. The Boolean `certain` indicates whether the write is certain. |
| 483 | + * |
| 484 | + * This includes implicit writes via calls. |
| 485 | + */ |
| 486 | + predicate variableWrite(BasicBlock bb, int i, SourceVariable v, boolean certain) { |
| 487 | + defAt(bb, i, v) and |
| 488 | + certain = true |
| 489 | + } |
| 490 | + |
| 491 | + /** |
| 492 | + * Holds if the `i`th of basic block `bb` reads source variable `v`. |
| 493 | + * |
| 494 | + * This includes implicit reads via calls. |
| 495 | + */ |
| 496 | + predicate variableRead(BasicBlock bb, int i, SourceVariable v, boolean certain) { |
| 497 | + useAt(bb, i, v) and certain = true |
| 498 | + or |
| 499 | + mayCapture(bb, i, v) and certain = false |
| 500 | + } |
| 501 | + } |
| 502 | + |
| 503 | + import SsaImplCommon::Make<Location, SsaInput> as Impl |
| 504 | + |
| 505 | + final class SsaInputDefinition = Impl::Definition; |
| 506 | + |
| 507 | + final class SsaInputWriteDefinition = Impl::WriteDefinition; |
| 508 | + |
| 509 | + final class SsaInputUncertainWriteDefinition = Impl::UncertainWriteDefinition; |
| 510 | + |
| 511 | + final class SsaInputPhiNode = Impl::PhiNode; |
463 | 512 | }
|
464 | 513 |
|
465 | 514 | import Internal
|
0 commit comments