mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Stats] Count SourceFile stats when in -wmo mode.
This commit is contained in:
@@ -429,6 +429,27 @@ static bool emitIndexData(SourceFile *PrimarySourceFile,
|
||||
const CompilerInvocation &Invocation,
|
||||
CompilerInstance &Instance);
|
||||
|
||||
static void countStatsOfSourceFile(UnifiedStatsReporter &Stats,
|
||||
CompilerInstance &Instance,
|
||||
SourceFile *SF) {
|
||||
auto &C = Stats.getFrontendCounters();
|
||||
auto &SM = Instance.getSourceMgr();
|
||||
C.NumDecls += SF->Decls.size();
|
||||
C.NumLocalTypeDecls += SF->LocalTypeDecls.size();
|
||||
C.NumObjCMethods += SF->ObjCMethods.size();
|
||||
C.NumInfixOperators += SF->InfixOperators.size();
|
||||
C.NumPostfixOperators += SF->PostfixOperators.size();
|
||||
C.NumPrefixOperators += SF->PrefixOperators.size();
|
||||
C.NumPrecedenceGroups += SF->PrecedenceGroups.size();
|
||||
C.NumUsedConformances += SF->getUsedConformances().size();
|
||||
|
||||
auto bufID = SF->getBufferID();
|
||||
if (bufID.hasValue()) {
|
||||
C.NumSourceLines +=
|
||||
SM.getEntireTextForBuffer(bufID.getValue()).count('\n');
|
||||
}
|
||||
}
|
||||
|
||||
static void countStatsPostSema(UnifiedStatsReporter &Stats,
|
||||
CompilerInstance& Instance) {
|
||||
auto &C = Stats.getFrontendCounters();
|
||||
@@ -452,19 +473,13 @@ static void countStatsPostSema(UnifiedStatsReporter &Stats,
|
||||
}
|
||||
|
||||
if (auto *SF = Instance.getPrimarySourceFile()) {
|
||||
C.NumDecls = SF->Decls.size();
|
||||
C.NumLocalTypeDecls = SF->LocalTypeDecls.size();
|
||||
C.NumObjCMethods = SF->ObjCMethods.size();
|
||||
C.NumInfixOperators = SF->InfixOperators.size();
|
||||
C.NumPostfixOperators = SF->PostfixOperators.size();
|
||||
C.NumPrefixOperators = SF->PrefixOperators.size();
|
||||
C.NumPrecedenceGroups = SF->PrecedenceGroups.size();
|
||||
C.NumUsedConformances = SF->getUsedConformances().size();
|
||||
|
||||
auto bufID = SF->getBufferID();
|
||||
if (bufID.hasValue()) {
|
||||
C.NumSourceLines =
|
||||
SM.getEntireTextForBuffer(bufID.getValue()).count('\n');
|
||||
countStatsOfSourceFile(Stats, Instance, SF);
|
||||
} else if (auto *M = Instance.getMainModule()) {
|
||||
// No primary source file, but a main module; this is WMO-mode
|
||||
for (auto *F : M->getFiles()) {
|
||||
if (auto *SF = dyn_cast<SourceFile>(F)) {
|
||||
countStatsOfSourceFile(Stats, Instance, SF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user