 6a979fb40d
			
		
	
	
		6a979fb40d
		
			
		
	
	
	
	
		
			
			* update staticcheck Don't fork staticcheck: use the upstream version. Remove unneeded SSA loading. * Cache go/analysis facts Don't load unneeded packages for go/analysis. Repeated run of go/analysis linters now 10x faster (2s vs 20s on this repo) than before.
		
			
				
	
	
		
			25 lines
		
	
	
		
			579 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			579 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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
 | |
| }
 |