Skip to content

Commit b1b6cae

Browse files
committed
[Gardening] Cleanup synthesized extension analyzer
1 parent d8028a9 commit b1b6cae

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

lib/IDE/IDETypeChecking.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
261261
bool IncludeUnconditional;
262262
PrintOptions Options;
263263
MergeGroupVector AllGroups;
264-
std::unique_ptr<ExtensionInfoMap> InfoMap;
264+
ExtensionInfoMap InfoMap;
265265

266266
Implementation(NominalTypeDecl *Target,
267267
bool IncludeUnconditional,
@@ -416,9 +416,9 @@ struct SynthesizedExtensionAnalyzer::Implementation {
416416
}
417417
}
418418

419-
std::unique_ptr<ExtensionInfoMap>
419+
ExtensionInfoMap
420420
collectSynthesizedExtensionInfoForProtocol(MergeGroupVector &AllGroups) {
421-
std::unique_ptr<ExtensionInfoMap> InfoMap(new ExtensionInfoMap());
421+
ExtensionInfoMap InfoMap;
422422
ExtensionMergeInfoMap MergeInfoMap;
423423
for (auto *E : Target->getExtensions()) {
424424
if (!Options.shouldPrint(E))
@@ -427,12 +427,12 @@ struct SynthesizedExtensionAnalyzer::Implementation {
427427
/*EnablingExt*/ nullptr,
428428
/*Conf*/ nullptr);
429429
if (Pair.first) {
430-
InfoMap->insert({E, Pair.first});
430+
InfoMap.insert({E, Pair.first});
431431
MergeInfoMap.insert({E, Pair.second});
432432
}
433433
}
434-
populateMergeGroup(*InfoMap, MergeInfoMap, AllGroups,
435-
/*AllowMergeWithDefBody*/false);
434+
populateMergeGroup(InfoMap, MergeInfoMap, AllGroups,
435+
/*AllowMergeWithDefBody=*/false);
436436
std::sort(AllGroups.begin(), AllGroups.end());
437437
for (auto &Group : AllGroups) {
438438
Group.sortMembers();
@@ -448,12 +448,13 @@ struct SynthesizedExtensionAnalyzer::Implementation {
448448
return false;
449449
}
450450

451-
std::unique_ptr<ExtensionInfoMap>
451+
ExtensionInfoMap
452452
collectSynthesizedExtensionInfo(MergeGroupVector &AllGroups) {
453453
if (isa<ProtocolDecl>(Target)) {
454454
return collectSynthesizedExtensionInfoForProtocol(AllGroups);
455455
}
456-
std::unique_ptr<ExtensionInfoMap> InfoMap(new ExtensionInfoMap());
456+
457+
ExtensionInfoMap InfoMap;
457458
ExtensionMergeInfoMap MergeInfoMap;
458459
std::vector<NominalTypeDecl*> Unhandled;
459460

@@ -470,7 +471,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
470471
if (AdjustedOpts.shouldPrint(E)) {
471472
auto Pair = isApplicable(E, Synthesized, EnablingE, Conf);
472473
if (Pair.first) {
473-
InfoMap->insert({E, Pair.first});
474+
InfoMap.insert({E, Pair.first});
474475
MergeInfoMap.insert({E, Pair.second});
475476
}
476477
}
@@ -515,8 +516,8 @@ struct SynthesizedExtensionAnalyzer::Implementation {
515516
}
516517
}
517518

518-
populateMergeGroup(*InfoMap, MergeInfoMap, AllGroups,
519-
/*AllowMergeWithDefBody*/true);
519+
populateMergeGroup(InfoMap, MergeInfoMap, AllGroups,
520+
/*AllowMergeWithDefBody=*/true);
520521

521522
std::sort(AllGroups.begin(), AllGroups.end());
522523
for (auto &Group : AllGroups) {
@@ -531,20 +532,18 @@ struct SynthesizedExtensionAnalyzer::Implementation {
531532
}
532533
};
533534

534-
SynthesizedExtensionAnalyzer::
535-
SynthesizedExtensionAnalyzer(NominalTypeDecl *Target,
536-
PrintOptions Options,
537-
bool IncludeUnconditional):
538-
Impl(*(new Implementation(Target, IncludeUnconditional, Options))) {}
535+
SynthesizedExtensionAnalyzer::SynthesizedExtensionAnalyzer(
536+
NominalTypeDecl *Target, PrintOptions Options, bool IncludeUnconditional)
537+
: Impl(*(new Implementation(Target, IncludeUnconditional, Options))) {}
539538

540539
SynthesizedExtensionAnalyzer::~SynthesizedExtensionAnalyzer() {delete &Impl;}
541540

542541
bool SynthesizedExtensionAnalyzer::
543542
isInSynthesizedExtension(const ValueDecl *VD) {
544543
if (auto Ext = dyn_cast_or_null<ExtensionDecl>(VD->getDeclContext()->
545544
getInnermostTypeContext())) {
546-
return Impl.InfoMap->count(Ext) != 0 &&
547-
Impl.InfoMap->find(Ext)->second.IsSynthesized;
545+
return Impl.InfoMap.count(Ext) != 0 &&
546+
Impl.InfoMap.find(Ext)->second.IsSynthesized;
548547
}
549548
return false;
550549
}
@@ -565,8 +564,7 @@ forEachExtensionMergeGroup(MergeGroupKind Kind, ExtensionGroupOperation Fn) {
565564
}
566565
}
567566

568-
bool SynthesizedExtensionAnalyzer::
569-
hasMergeGroup(MergeGroupKind Kind) {
567+
bool SynthesizedExtensionAnalyzer::hasMergeGroup(MergeGroupKind Kind) {
570568
for (auto &Group : Impl.AllGroups) {
571569
if (Kind == MergeGroupKind::All)
572570
return true;

0 commit comments

Comments
 (0)