@@ -682,8 +682,8 @@ static void countStatsOfSourceFile(UnifiedStatsReporter &Stats,
682
682
}
683
683
}
684
684
685
- static void countStatsPostSema (UnifiedStatsReporter &Stats,
686
- CompilerInstance& Instance) {
685
+ static void countASTStats (UnifiedStatsReporter &Stats,
686
+ CompilerInstance& Instance) {
687
687
auto &C = Stats.getFrontendCounters ();
688
688
auto &SM = Instance.getSourceMgr ();
689
689
C.NumSourceBuffers = SM.getLLVMSourceMgr ().getNumBuffers ();
@@ -1223,6 +1223,16 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
1223
1223
static void performEndOfPipelineActions (CompilerInstance &Instance) {
1224
1224
assert (Instance.hasASTContext ());
1225
1225
auto &ctx = Instance.getASTContext ();
1226
+ const auto &Invocation = Instance.getInvocation ();
1227
+ const auto &opts = Invocation.getFrontendOptions ();
1228
+
1229
+ // If we were asked to print Clang stats, do so.
1230
+ if (opts.PrintClangStats && ctx.getClangModuleLoader ())
1231
+ ctx.getClangModuleLoader ()->printStatistics ();
1232
+
1233
+ // Report AST stats if needed.
1234
+ if (auto *stats = ctx.Stats )
1235
+ countASTStats (*stats, Instance);
1226
1236
1227
1237
// Make sure we didn't load a module during a parse-only invocation, unless
1228
1238
// it's -emit-imported-modules, which can load modules.
@@ -1327,10 +1337,6 @@ static bool performCompile(CompilerInstance &Instance,
1327
1337
if (observer)
1328
1338
observer->performedSemanticAnalysis (Instance);
1329
1339
1330
- if (auto *Stats = Context.Stats ) {
1331
- countStatsPostSema (*Stats, Instance);
1332
- }
1333
-
1334
1340
{
1335
1341
FrontendOptions::DebugCrashMode CrashMode = opts.CrashMode ;
1336
1342
if (CrashMode == FrontendOptions::DebugCrashMode::AssertAfterParse)
@@ -1351,10 +1357,6 @@ static bool performCompile(CompilerInstance &Instance,
1351
1357
if (auto r = dumpASTIfNeeded (Instance))
1352
1358
return *r;
1353
1359
1354
- // If we were asked to print Clang stats, do so.
1355
- if (opts.PrintClangStats && Context.getClangModuleLoader ())
1356
- Context.getClangModuleLoader ()->printStatistics ();
1357
-
1358
1360
emitSwiftRangesForAllPrimaryInputsIfNeeded (Instance);
1359
1361
emitCompiledSourceForAllPrimaryInputsIfNeeded (Instance);
1360
1362
0 commit comments