Skip to content

Commit a15ab99

Browse files
committed
Invoke SsaImplCommon::Make
1 parent 635b722 commit a15ab99

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

go/ql/lib/semmle/go/dataflow/SsaImpl.qll

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import go
8+
private import codeql.ssa.Ssa as SsaImplCommon
89

910
cached
1011
private module Internal {
@@ -460,6 +461,54 @@ private module Internal {
460461
firstUse(def, use2)
461462
)
462463
}
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;
463512
}
464513

465514
import Internal

0 commit comments

Comments
 (0)