aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gostaticanalysis
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gostaticanalysis')
-rw-r--r--vendor/github.com/gostaticanalysis/analysisutil/LICENSE21
-rw-r--r--vendor/github.com/gostaticanalysis/analysisutil/README.md10
-rw-r--r--vendor/github.com/gostaticanalysis/analysisutil/file.go18
-rw-r--r--vendor/github.com/gostaticanalysis/analysisutil/go.mod5
-rw-r--r--vendor/github.com/gostaticanalysis/analysisutil/go.sum6
-rw-r--r--vendor/github.com/gostaticanalysis/analysisutil/pkg.go26
-rw-r--r--vendor/github.com/gostaticanalysis/analysisutil/ssa.go31
7 files changed, 117 insertions, 0 deletions
diff --git a/vendor/github.com/gostaticanalysis/analysisutil/LICENSE b/vendor/github.com/gostaticanalysis/analysisutil/LICENSE
new file mode 100644
index 000000000..bf7e33db8
--- /dev/null
+++ b/vendor/github.com/gostaticanalysis/analysisutil/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 GoStaticAnalysis
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/gostaticanalysis/analysisutil/README.md b/vendor/github.com/gostaticanalysis/analysisutil/README.md
new file mode 100644
index 000000000..c031e16e2
--- /dev/null
+++ b/vendor/github.com/gostaticanalysis/analysisutil/README.md
@@ -0,0 +1,10 @@
+# analysisutil
+
+[![godoc.org][godoc-badge]][godoc]
+
+Utilities for x/tools/go/analysis package.
+
+<!-- links -->
+[godoc]: https://godoc.org/github.com/gostaticanalysis/analysisutil
+[godoc-badge]: https://img.shields.io/badge/godoc-reference-4F73B3.svg?style=flat-square&label=%20godoc.org
+
diff --git a/vendor/github.com/gostaticanalysis/analysisutil/file.go b/vendor/github.com/gostaticanalysis/analysisutil/file.go
new file mode 100644
index 000000000..2aeca1d9e
--- /dev/null
+++ b/vendor/github.com/gostaticanalysis/analysisutil/file.go
@@ -0,0 +1,18 @@
+package analysisutil
+
+import (
+ "go/ast"
+ "go/token"
+
+ "golang.org/x/tools/go/analysis"
+)
+
+// File finds *ast.File in pass.Files by pos.
+func File(pass *analysis.Pass, pos token.Pos) *ast.File {
+ for _, f := range pass.Files {
+ if f.Pos() <= pos && pos <= f.End() {
+ return f
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/gostaticanalysis/analysisutil/go.mod b/vendor/github.com/gostaticanalysis/analysisutil/go.mod
new file mode 100644
index 000000000..7e3e55be1
--- /dev/null
+++ b/vendor/github.com/gostaticanalysis/analysisutil/go.mod
@@ -0,0 +1,5 @@
+module github.com/gostaticanalysis/analysisutil
+
+go 1.12
+
+require golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5
diff --git a/vendor/github.com/gostaticanalysis/analysisutil/go.sum b/vendor/github.com/gostaticanalysis/analysisutil/go.sum
new file mode 100644
index 000000000..16c8787c4
--- /dev/null
+++ b/vendor/github.com/gostaticanalysis/analysisutil/go.sum
@@ -0,0 +1,6 @@
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5 h1:ZcPpqKMdoZeNQ/4GHlyY4COf8n8SmpPv6mcqF1+VPSM=
+golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
diff --git a/vendor/github.com/gostaticanalysis/analysisutil/pkg.go b/vendor/github.com/gostaticanalysis/analysisutil/pkg.go
new file mode 100644
index 000000000..c98710d18
--- /dev/null
+++ b/vendor/github.com/gostaticanalysis/analysisutil/pkg.go
@@ -0,0 +1,26 @@
+package analysisutil
+
+import (
+ "go/types"
+ "strings"
+)
+
+// RemoVendor removes vendoring infomation from import path.
+func RemoveVendor(path string) string {
+ i := strings.Index(path, "vendor")
+ if i >= 0 {
+ return path[i+len("vendor")+1:]
+ }
+ return path
+}
+
+// LookupFromImports finds an object from import paths.
+func LookupFromImports(imports []*types.Package, path, name string) types.Object {
+ path = RemoveVendor(path)
+ for i := range imports {
+ if path == RemoveVendor(imports[i].Path()) {
+ return imports[i].Scope().Lookup(name)
+ }
+ }
+ return nil
+}
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
+}