Add assembly analysis to nogo.

This temporarily disables many asmdecl checks to minimize concurrent code
changes; these will be fixed separately.

PiperOrigin-RevId: 511619271
This commit is contained in:
Adin Scannell
2023-02-22 15:57:50 -08:00
committed by gVisor bot
parent d94ff26acc
commit c34a085729
2 changed files with 31 additions and 8 deletions
+12 -1
View File
@@ -88,7 +88,18 @@ global:
- pkg/shim/runtimeoptions/v14/runtimeoptions_cri.go
analyzers:
asmdecl:
external: # Enabled.
generated:
exclude: [".*"] # Disabled.
external:
exclude: [".*"] # Disabled.
internal:
suppress:
# Suppress for now, will be fixed separately.
- ".*unknown variable.*"
- ".*RET without writing.*"
- ".*wrong argument size.*"
- ".*missing Go declaration.*"
- ".*invalid.*"
assign:
external:
exclude:
+19 -7
View File
@@ -337,7 +337,7 @@ func (i *errorImporter) Import(path string) (*types.Package, error) {
// [2] golang.org/x/tools/go/checker/internal/checker
func (i *importer) checkPackage(path string, srcs []string) (*types.Package, FindingSet, *facts.Package, error) {
// Load all source files.
goFiles, _ := sortSrcs(srcs)
goFiles, nonGoFiles := sortSrcs(srcs)
syntax := make([]*ast.File, 0, len(goFiles))
for _, file := range goFiles {
include, err := shouldInclude(file)
@@ -353,6 +353,17 @@ func (i *importer) checkPackage(path string, srcs []string) (*types.Package, Fin
}
syntax = append(syntax, s)
}
otherFiles := make([]string, 0, len(nonGoFiles))
for _, file := range nonGoFiles {
include, err := shouldInclude(file)
if err != nil {
return nil, nil, nil, fmt.Errorf("error evaluating non-Go file %q: %w", file, err)
}
if !include {
continue
}
otherFiles = append(otherFiles, file)
}
// Check type information.
ei := &errorImporter{
@@ -431,12 +442,13 @@ func (i *importer) checkPackage(path string, srcs []string) (*types.Package, Fin
// Run the analysis.
var localFindings FindingSet
p := &analysis.Pass{
Analyzer: a,
Fset: i.fset,
Files: syntax,
Pkg: astPackage,
TypesInfo: typesInfo,
ResultOf: results, // All results.
Analyzer: a,
Fset: i.fset,
Files: syntax,
OtherFiles: otherFiles,
Pkg: astPackage,
TypesInfo: typesInfo,
ResultOf: results, // All results.
Report: func(d analysis.Diagnostic) {
localFindings = append(localFindings, Finding{
Category: a.Name,