@@ -126,13 +126,16 @@ func (cl ContextLoader) makeFakeLoaderProgram(pkgs []*packages.Package) *loader.
126
126
}
127
127
}
128
128
129
- func (cl ContextLoader ) buildSSAProgram (pkgs []* packages.Package ) * ssa.Program {
129
+ func (cl ContextLoader ) buildSSAProgram (pkgs []* packages.Package , name string ) * ssa.Program {
130
130
startedAt := time .Now ()
131
+ var pkgsBuiltDuration time.Duration
131
132
defer func () {
132
- cl .log .Infof ("SSA repr building took %s" , time .Since (startedAt ))
133
+ cl .log .Infof ("SSA %srepr building timing: packages building %s, total %s" ,
134
+ name , pkgsBuiltDuration , time .Since (startedAt ))
133
135
}()
134
136
135
137
ssaProg , _ := ssautil .Packages (pkgs , ssa .GlobalDebug )
138
+ pkgsBuiltDuration = time .Since (startedAt )
136
139
ssaProg .Build ()
137
140
return ssaProg
138
141
}
@@ -300,24 +303,10 @@ func (cl ContextLoader) Load(ctx context.Context, linters []linter.Config) (*lin
300
303
prog = cl .makeFakeLoaderProgram (pkgs )
301
304
}
302
305
303
- var ssaProg * ssa.Program
306
+ var ssaProg , megacheckSSAProg * ssa.Program
304
307
if loadMode == packages .LoadAllSyntax {
305
- ssaProg = cl .buildSSAProgram (pkgs )
306
- for _ , pkginfo := range prog .InitialPackages () {
307
- if pkginfo == nil {
308
- cl .log .Infof ("Pkginfo is nil" )
309
- continue
310
- }
311
- if pkginfo .Pkg == nil {
312
- cl .log .Infof ("Pkg %#v: types package is nil" , * pkginfo )
313
- continue
314
- }
315
- ssaPkg := ssaProg .Package (pkginfo .Pkg )
316
- if ssaPkg == nil {
317
- cl .log .Infof ("Pkg %#v: ssaPkg is nil: %#v" , * pkginfo , * pkginfo .Pkg )
318
- continue
319
- }
320
- }
308
+ ssaProg = cl .buildSSAProgram (pkgs , "" )
309
+ megacheckSSAProg = cl .buildSSAProgram (pkgs , "for megacheck " )
321
310
}
322
311
323
312
astLog := cl .log .Child ("astcache" )
@@ -327,9 +316,10 @@ func (cl ContextLoader) Load(ctx context.Context, linters []linter.Config) (*lin
327
316
}
328
317
329
318
ret := & linter.Context {
330
- Packages : pkgs ,
331
- Program : prog ,
332
- SSAProgram : ssaProg ,
319
+ Packages : pkgs ,
320
+ Program : prog ,
321
+ SSAProgram : ssaProg ,
322
+ MegacheckSSAProgram : megacheckSSAProg ,
333
323
LoaderConfig : & loader.Config {
334
324
Cwd : "" , // used by depguard and fallbacked to os.Getcwd
335
325
Build : nil , // used by depguard and megacheck and fallbacked to build.Default
0 commit comments