deprecated.go (1088B)
1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package ssautil 6 7 // This file contains deprecated public APIs. 8 // We discourage their use. 9 10 import ( 11 "golang.org/x/tools/go/loader" 12 "golang.org/x/tools/go/ssa" 13 ) 14 15 // CreateProgram returns a new program in SSA form, given a program 16 // loaded from source. An SSA package is created for each transitively 17 // error-free package of lprog. 18 // 19 // Code for bodies of functions is not built until Build is called 20 // on the result. 21 // 22 // The mode parameter controls diagnostics and checking during SSA construction. 23 // 24 // Deprecated: Use [golang.org/x/tools/go/packages] and the [Packages] 25 // function instead; see ssa.Example_loadPackages. 26 func CreateProgram(lprog *loader.Program, mode ssa.BuilderMode) *ssa.Program { 27 prog := ssa.NewProgram(lprog.Fset, mode) 28 29 for _, info := range lprog.AllPackages { 30 if info.TransitivelyErrorFree { 31 prog.CreatePackage(info.Pkg, info.Files, &info.Info, info.Importable) 32 } 33 } 34 35 return prog 36 }