aboutsummaryrefslogtreecommitdiff
path: root/vendor/honnef.co/go/tools/functions/terminates.go
diff options
context:
space:
mode:
authorJoseph Richey <joerichey@google.com>2018-02-11 21:43:56 -0800
committerGitHub <noreply@github.com>2018-02-11 21:43:56 -0800
commit8b6cbfcca9d1f3fb5b05a91b4ac0bca66f75f19e (patch)
tree5f6fdc40c7518bc23a63fdac9a92b516dd0c6d36 /vendor/honnef.co/go/tools/functions/terminates.go
parentaebae1aae2fc61185a8bbc96313d8462727ad202 (diff)
parentb330463662825a7d7b22efabb2b7a40640d2b18e (diff)
Merge pull request #85 from google/depfix
Complete the new Build System
Diffstat (limited to 'vendor/honnef.co/go/tools/functions/terminates.go')
-rw-r--r--vendor/honnef.co/go/tools/functions/terminates.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/honnef.co/go/tools/functions/terminates.go b/vendor/honnef.co/go/tools/functions/terminates.go
new file mode 100644
index 0000000..65f9e16
--- /dev/null
+++ b/vendor/honnef.co/go/tools/functions/terminates.go
@@ -0,0 +1,24 @@
+package functions
+
+import "honnef.co/go/tools/ssa"
+
+// terminates reports whether fn is supposed to return, that is if it
+// has at least one theoretic path that returns from the function.
+// Explicit panics do not count as terminating.
+func terminates(fn *ssa.Function) bool {
+ if fn.Blocks == nil {
+ // assuming that a function terminates is the conservative
+ // choice
+ return true
+ }
+
+ for _, block := range fn.Blocks {
+ if len(block.Instrs) == 0 {
+ continue
+ }
+ if _, ok := block.Instrs[len(block.Instrs)-1].(*ssa.Return); ok {
+ return true
+ }
+ }
+ return false
+}