llgo:skipall

This commit is contained in:
xushiwei
2024-06-16 21:32:11 +08:00
parent 7b7b4e5f22
commit dc1fbbf796
4 changed files with 39 additions and 13 deletions

View File

@@ -100,10 +100,11 @@ func ignoreName(name string) bool {
strings.HasPrefix(name, "arena.") || strings.HasPrefix(name, "maps.") ||
strings.HasPrefix(name, "time.") || strings.HasPrefix(name, "syscall.") ||
strings.HasPrefix(name, "os.") || strings.HasPrefix(name, "plugin.") ||
strings.HasPrefix(name, "reflect.") || strings.HasPrefix(name, "errors.") {
strings.HasPrefix(name, "reflect.") || strings.HasPrefix(name, "errors.") ||
strings.HasPrefix(name, "sync.") {
return true // TODO(xsw)
}
return inPkg(name, "runtime") || inPkg(name, "sync")
return inPkg(name, "runtime")
}
func inPkg(name, pkg string) bool {
@@ -157,6 +158,8 @@ type context struct {
inits []func()
phis []func()
skipall bool
}
func (p *context) inMain(instr ssa.Instruction) bool {
@@ -1048,7 +1051,9 @@ func NewPackageEx(prog llssa.Program, pkg, alt *ssa.Package, files []*ast.File)
processPkg(ctx, ret, alt)
ctx.skips = skips
}
processPkg(ctx, ret, pkg)
if !ctx.skipall {
processPkg(ctx, ret, pkg)
}
for len(ctx.inits) > 0 {
inits := ctx.inits
ctx.inits = nil

View File

@@ -193,10 +193,12 @@ func (p *context) initFiles(pkgPath string, files []*ast.File) {
}
}
// llgo:skip symbol1 symbol2 ...
// llgo:skipall
func (p *context) collectSkipNames(line string) {
const (
skip = "//llgo:skip "
skip2 = "// llgo:skip "
skip = "//llgo:skip"
skip2 = "// llgo:skip"
)
if strings.HasPrefix(line, skip2) {
p.collectSkip(line, len(skip2))
@@ -206,7 +208,15 @@ func (p *context) collectSkipNames(line string) {
}
func (p *context) collectSkip(line string, prefix int) {
names := strings.Split(line[prefix:], " ")
line = line[prefix:]
if line == "all" {
p.skipall = true
return
}
if len(line) == 0 || line[0] != ' ' {
return
}
names := strings.Split(line[1:], " ")
for _, name := range names {
if name != "" {
p.skips[name] = none{}