ir: remove old cgo related code
There is now a custom implementation of CGo based on libclang.
Этот коммит содержится в:
родитель
07733ca056
коммит
856e5fa179
2 изменённых файлов: 2 добавлений и 20 удалений
18
ir/ir.go
18
ir/ir.go
|
@ -187,9 +187,6 @@ func NewProgram(lprogram *loader.Program, mainPath string) *Program {
|
||||||
func (p *Program) AddPackage(pkg *ssa.Package) {
|
func (p *Program) AddPackage(pkg *ssa.Package) {
|
||||||
memberNames := make([]string, 0)
|
memberNames := make([]string, 0)
|
||||||
for name := range pkg.Members {
|
for name := range pkg.Members {
|
||||||
if isCGoInternal(name) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
memberNames = append(memberNames, name)
|
memberNames = append(memberNames, name)
|
||||||
}
|
}
|
||||||
sort.Strings(memberNames)
|
sort.Strings(memberNames)
|
||||||
|
@ -198,9 +195,6 @@ func (p *Program) AddPackage(pkg *ssa.Package) {
|
||||||
member := pkg.Members[name]
|
member := pkg.Members[name]
|
||||||
switch member := member.(type) {
|
switch member := member.(type) {
|
||||||
case *ssa.Function:
|
case *ssa.Function:
|
||||||
if isCGoInternal(member.Name()) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
p.addFunction(member)
|
p.addFunction(member)
|
||||||
case *ssa.Type:
|
case *ssa.Type:
|
||||||
t := &NamedType{Type: member}
|
t := &NamedType{Type: member}
|
||||||
|
@ -438,18 +432,6 @@ func (p *Program) IsVolatile(t types.Type) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if this is a CGo-internal function that can be ignored.
|
|
||||||
func isCGoInternal(name string) bool {
|
|
||||||
if strings.HasPrefix(name, "_Cgo_") || strings.HasPrefix(name, "_cgo") {
|
|
||||||
// _Cgo_ptr, _Cgo_use, _cgoCheckResult, _cgo_runtime_cgocall
|
|
||||||
return true // CGo-internal functions
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(name, "__cgofn__cgo_") {
|
|
||||||
return true // CGo function pointer in global scope
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all methods of a type.
|
// Get all methods of a type.
|
||||||
func getAllMethods(prog *ssa.Program, typ types.Type) []*types.Selection {
|
func getAllMethods(prog *ssa.Program, typ types.Type) []*types.Selection {
|
||||||
ms := prog.MethodSets.MethodSet(typ)
|
ms := prog.MethodSets.MethodSet(typ)
|
||||||
|
|
|
@ -73,7 +73,7 @@ func (p *Program) SimpleDCE() {
|
||||||
worklist := []*ssa.Function{main}
|
worklist := []*ssa.Function{main}
|
||||||
for _, f := range p.Functions {
|
for _, f := range p.Functions {
|
||||||
if f.exported || f.Synthetic == "package initializer" || f.Pkg == runtimePkg || (f.Pkg == mathPkg && f.Pkg != nil) {
|
if f.exported || f.Synthetic == "package initializer" || f.Pkg == runtimePkg || (f.Pkg == mathPkg && f.Pkg != nil) {
|
||||||
if f.flag || isCGoInternal(f.Name()) {
|
if f.flag {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
f.flag = true
|
f.flag = true
|
||||||
|
@ -103,7 +103,7 @@ func (p *Program) SimpleDCE() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, operand := range instr.Operands(nil) {
|
for _, operand := range instr.Operands(nil) {
|
||||||
if operand == nil || *operand == nil || isCGoInternal((*operand).Name()) {
|
if operand == nil || *operand == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch operand := (*operand).(type) {
|
switch operand := (*operand).(type) {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче