aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gostaticanalysis/analysisutil/ssa.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-07-04 11:12:55 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-07-04 15:05:30 +0200
commitc7d7f10bdff703e4a3c0414e8a33d4e45c91eb35 (patch)
tree0dff0ee1f98dbfa3ad8776112053a450d176592b /vendor/github.com/gostaticanalysis/analysisutil/ssa.go
parent9573094ce235bd9afe88f5da27a47dd6bcc1e13b (diff)
go.mod: vendor golangci-lint
Diffstat (limited to 'vendor/github.com/gostaticanalysis/analysisutil/ssa.go')
-rw-r--r--vendor/github.com/gostaticanalysis/analysisutil/ssa.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/vendor/github.com/gostaticanalysis/analysisutil/ssa.go b/vendor/github.com/gostaticanalysis/analysisutil/ssa.go
new file mode 100644
index 000000000..379158667
--- /dev/null
+++ b/vendor/github.com/gostaticanalysis/analysisutil/ssa.go
@@ -0,0 +1,31 @@
+package analysisutil
+
+import "golang.org/x/tools/go/ssa"
+
+// IfInstr returns *ssa.If which is contained in the block b.
+// If the block b has not any if instruction, IfInstr returns nil.
+func IfInstr(b *ssa.BasicBlock) *ssa.If {
+ if len(b.Instrs) == 0 {
+ return nil
+ }
+
+ ifinstr, ok := b.Instrs[len(b.Instrs)-1].(*ssa.If)
+ if !ok {
+ return nil
+ }
+
+ return ifinstr
+}
+
+// Phi returns phi values which are contained in the block b.
+func Phi(b *ssa.BasicBlock) (phis []*ssa.Phi) {
+ for _, instr := range b.Instrs {
+ if phi, ok := instr.(*ssa.Phi); ok {
+ phis = append(phis, phi)
+ } else {
+ // no more phi
+ break
+ }
+ }
+ return
+}