 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.
		
			
				
	
	
		
			26 lines
		
	
	
		
			670 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			670 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package staticcheck
 | |
| 
 | |
| import (
 | |
| 	"reflect"
 | |
| 
 | |
| 	"golang.org/x/tools/go/analysis"
 | |
| 	"honnef.co/go/tools/internal/passes/buildssa"
 | |
| 	"honnef.co/go/tools/ssa"
 | |
| 	"honnef.co/go/tools/staticcheck/vrp"
 | |
| )
 | |
| 
 | |
| var valueRangesAnalyzer = &analysis.Analyzer{
 | |
| 	Name: "vrp",
 | |
| 	Doc:  "calculate value ranges of functions",
 | |
| 	Run: func(pass *analysis.Pass) (interface{}, error) {
 | |
| 		m := map[*ssa.Function]vrp.Ranges{}
 | |
| 		for _, ssafn := range pass.ResultOf[buildssa.Analyzer].(*buildssa.SSA).SrcFuncs {
 | |
| 			vr := vrp.BuildGraph(ssafn).Solve()
 | |
| 			m[ssafn] = vr
 | |
| 		}
 | |
| 		return m, nil
 | |
| 	},
 | |
| 	Requires:   []*analysis.Analyzer{buildssa.Analyzer},
 | |
| 	ResultType: reflect.TypeOf(map[*ssa.Function]vrp.Ranges{}),
 | |
| }
 |