Skip to content

Commit de72824

Browse files
committed
[Gardening] Canonicalize usages of ASTContext::Stats
1 parent ccf472d commit de72824

22 files changed

+65
-45
lines changed

lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5018,8 +5018,8 @@ ProtocolDecl::setLazyRequirementSignature(LazyMemberLoader *lazyLoader,
50185018

50195019
++NumLazyRequirementSignatures;
50205020
// FIXME: (transitional) increment the redundant "always-on" counter.
5021-
if (getASTContext().Stats)
5022-
getASTContext().Stats->getFrontendCounters().NumLazyRequirementSignatures++;
5021+
if (auto *Stats = getASTContext().Stats)
5022+
Stats->getFrontendCounters().NumLazyRequirementSignatures++;
50235023
}
50245024

50255025
ArrayRef<Requirement> ProtocolDecl::getCachedRequirementSignature() const {

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3458,8 +3458,8 @@ void EquivalenceClass::modified(GenericSignatureBuilder &builder) {
34583458
GenericSignatureBuilder::GenericSignatureBuilder(
34593459
ASTContext &ctx)
34603460
: Context(ctx), Diags(Context.Diags), Impl(new Implementation) {
3461-
if (Context.Stats)
3462-
Context.Stats->getFrontendCounters().NumGenericSignatureBuilders++;
3461+
if (auto *Stats = Context.Stats)
3462+
Stats->getFrontendCounters().NumGenericSignatureBuilders++;
34633463
}
34643464

34653465
GenericSignatureBuilder::GenericSignatureBuilder(

lib/AST/Module.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,8 @@ void ModuleDecl::lookupClassMember(AccessPathTy accessPath,
629629
stats->getFrontendCounters().NumModuleLookupClassMember++;
630630

631631
if (isParsedModule(this)) {
632-
FrontendStatsTracer tracer(getASTContext().Stats, "source-file-lookup-class-member");
632+
FrontendStatsTracer tracer(getASTContext().Stats,
633+
"source-file-lookup-class-member");
633634
auto &cache = getSourceLookupCache();
634635
cache.populateMemberCache(*this);
635636
cache.lookupClassMember(accessPath, name, results);
@@ -642,7 +643,8 @@ void ModuleDecl::lookupClassMember(AccessPathTy accessPath,
642643
void SourceFile::lookupClassMember(ModuleDecl::AccessPathTy accessPath,
643644
DeclName name,
644645
SmallVectorImpl<ValueDecl*> &results) const {
645-
FrontendStatsTracer tracer(getASTContext().Stats, "source-file-lookup-class-member");
646+
FrontendStatsTracer tracer(getASTContext().Stats,
647+
"source-file-lookup-class-member");
646648
auto &cache = getCache();
647649
cache.populateMemberCache(*this);
648650
cache.lookupClassMember(accessPath, name, results);

lib/AST/UnqualifiedLookup.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ void UnqualifiedLookupFactory::performUnqualifiedLookup() {
490490
auto localCounter = lookupCounter;
491491
(void)localCounter; // for debugging
492492
#endif
493-
FrontendStatsTracer StatsTracer(Ctx.Stats, "performUnqualifedLookup",
493+
FrontendStatsTracer StatsTracer(Ctx.Stats,
494+
"performUnqualifedLookup",
494495
DC->getParentSourceFile());
495496

496497
const Optional<bool> initialIsCascadingUse = getInitialIsCascadingUse();

lib/ClangImporter/ImportDecl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7859,8 +7859,8 @@ ClangImporter::Implementation::importDeclImpl(const clang::NamedDecl *ClangDecl,
78597859
void ClangImporter::Implementation::startedImportingEntity() {
78607860
++NumTotalImportedEntities;
78617861
// FIXME: (transitional) increment the redundant "always-on" counter.
7862-
if (SwiftContext.Stats)
7863-
SwiftContext.Stats->getFrontendCounters().NumTotalClangImportedEntities++;
7862+
if (auto *Stats = SwiftContext.Stats)
7863+
Stats->getFrontendCounters().NumTotalClangImportedEntities++;
78647864
}
78657865

78667866
/// Look up associated type requirements in the conforming type.
@@ -8563,7 +8563,8 @@ static void loadAllMembersOfSuperclassIfNeeded(ClassDecl *CD) {
85638563
void
85648564
ClangImporter::Implementation::loadAllMembers(Decl *D, uint64_t extra) {
85658565

8566-
FrontendStatsTracer tracer(D->getASTContext().Stats, "load-all-members", D);
8566+
FrontendStatsTracer tracer(D->getASTContext().Stats,
8567+
"load-all-members", D);
85678568
assert(D);
85688569

85698570
// Check whether we're importing an Objective-C container of some sort.

lib/IRGen/GenDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,8 +2687,8 @@ llvm::Constant *IRGenModule::getOrCreateGOTEquivalent(llvm::Constant *global,
26872687
return gotEntry;
26882688
}
26892689

2690-
if (Context.Stats)
2691-
Context.Stats->getFrontendCounters().NumGOTEntries++;
2690+
if (auto *Stats = Context.Stats)
2691+
Stats->getFrontendCounters().NumGOTEntries++;
26922692

26932693
// Use the global as the initializer for an anonymous constant. LLVM can treat
26942694
// this as equivalent to the global's GOT entry.

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6413,8 +6413,8 @@ Parser::parseAbstractFunctionBodyImpl(AbstractFunctionDecl *AFD) {
64136413
ParseFunctionBody CC(*this, AFD);
64146414
setLocalDiscriminatorToParamList(AFD->getParameters());
64156415

6416-
if (Context.Stats)
6417-
Context.Stats->getFrontendCounters().NumFunctionsParsed++;
6416+
if (auto *Stats = Context.Stats)
6417+
Stats->getFrontendCounters().NumFunctionsParsed++;
64186418

64196419
// In implicit getter, if a CC token is the first token after '{', it might
64206420
// be a start of an accessor block. Perform special completion for that.

lib/Parse/Parser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ void swift::performCodeCompletionSecondPass(
121121
auto &SF = *state->ParentContext->getParentSourceFile();
122122
auto &Ctx = SF.getASTContext();
123123

124-
FrontendStatsTracer tracer(Ctx.Stats, "CodeCompletionSecondPass");
124+
FrontendStatsTracer tracer(Ctx.Stats,
125+
"CodeCompletionSecondPass");
125126

126127
auto BufferID = Ctx.SourceMgr.getCodeCompletionBufferID();
127128
Parser TheParser(BufferID, SF, nullptr, &ParserState, nullptr);

lib/ParseSIL/ParseSIL.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ void swift::parseIntoSourceFile(SourceFile &SF, unsigned int BufferID,
133133
if (SF.shouldBuildSyntaxTree())
134134
DelayBodyParsing = false;
135135

136-
FrontendStatsTracer tracer(SF.getASTContext().Stats, "Parsing");
136+
FrontendStatsTracer tracer(SF.getASTContext().Stats,
137+
"Parsing");
137138
Parser P(BufferID, SF, /*SIL*/ nullptr, PersistentState, STreeCreator,
138139
DelayBodyParsing);
139140
PrettyStackTraceParser StackTrace(P);
@@ -152,7 +153,8 @@ void swift::parseSourceFileSIL(SourceFile &SF, SILParserState *sil) {
152153
auto bufferID = SF.getBufferID();
153154
assert(bufferID);
154155

155-
FrontendStatsTracer tracer(SF.getASTContext().Stats, "Parsing SIL");
156+
FrontendStatsTracer tracer(SF.getASTContext().Stats,
157+
"Parsing SIL");
156158
Parser parser(*bufferID, SF, sil->Impl.get(),
157159
/*persistentParserState*/ nullptr,
158160
/*syntaxTreeCreator*/ nullptr, /*delayBodyParsing*/ false);

lib/SILGen/SILGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,8 @@ void SILGenModule::emitFunction(FuncDecl *fd) {
812812
emitAbstractFuncDecl(fd);
813813

814814
if (fd->hasBody()) {
815-
FrontendStatsTracer Tracer(getASTContext().Stats, "SILGen-funcdecl", fd);
815+
FrontendStatsTracer Tracer(getASTContext().Stats,
816+
"SILGen-funcdecl", fd);
816817
PrettyStackTraceDecl stackTrace("emitting SIL for", fd);
817818

818819
SILDeclRef constant(decl);

0 commit comments

Comments
 (0)