Skip to content

Commit 5ce5466

Browse files
committed
[metadata prespecialization] NFC: Replaced bool with enum.
Previously a bool argument was passed to isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable to indicate whether the metadata was to be used only from a specialized metadata accessor. Here, that bool is replaced with an enum.
1 parent 5204af3 commit 5ce5466

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

lib/IRGen/MetadataRequest.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ static MetadataResponse emitNominalMetadataRef(IRGenFunction &IGF,
671671
} else if (auto theClass = dyn_cast<ClassDecl>(theDecl)) {
672672
if (isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
673673
IGF.IGM, *theClass, theType,
674-
/*usingCanonicalSpecializedAccessor=*/true)) {
674+
ForUseOnlyFromAccessor)) {
675675
llvm::Function *accessor =
676676
IGF.IGM
677677
.getAddrOfCanonicalSpecializedGenericTypeMetadataAccessFunction(
@@ -698,7 +698,7 @@ static MetadataResponse emitNominalMetadataRef(IRGenFunction &IGF,
698698

699699
bool irgen::isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
700700
IRGenModule &IGM, NominalTypeDecl &nominal, CanType type,
701-
bool usingCanonicalSpecializedAccessor) {
701+
CanonicalSpecializedMetadataUsageIsOnlyFromAccessor onlyFromAccessor) {
702702
assert(nominal.isGenericContext());
703703

704704
if (!IGM.shouldPrespecializeGenericMetadata()) {
@@ -787,7 +787,7 @@ bool irgen::isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
787787
(protocols.size() > 0);
788788
};
789789
auto metadataAccessIsTrivial = [&]() {
790-
if (usingCanonicalSpecializedAccessor) {
790+
if (onlyFromAccessor) {
791791
// If an accessor is being used, then the accessor will be able to
792792
// initialize the arguments, i.e. register classes with the ObjC
793793
// runtime.
@@ -820,7 +820,7 @@ bool irgen::
820820
// Struct<Klass<Int>>
821821
// Enum<Klass<Int>>
822822
return isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
823-
IGM, nominal, type, /*usingCanonicalSpecializedAccessor=*/false);
823+
IGM, nominal, type, NotForUseOnlyFromAccessor);
824824
}
825825

826826
/// Is there a known address for canonical specialized metadata? The metadata
@@ -840,7 +840,7 @@ bool irgen::isInitializableTypeMetadataStaticallyAddressable(IRGenModule &IGM,
840840
// runtime.
841841
// Concretely, Clazz<Klass<Int>> can be prespecialized.
842842
return isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
843-
IGM, *nominal, type, /*usingCanonicalSpecializedAccessor=*/true);
843+
IGM, *nominal, type, ForUseOnlyFromAccessor);
844844
}
845845

846846
return false;
@@ -922,7 +922,7 @@ bool irgen::shouldCacheTypeMetadataAccess(IRGenModule &IGM, CanType type) {
922922
return true;
923923
if (classDecl->isGenericContext() &&
924924
isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
925-
IGM, *classDecl, type, /*usingCanonicalSpecializedAccessor=*/true))
925+
IGM, *classDecl, type, ForUseOnlyFromAccessor))
926926
return false;
927927
auto strategy = IGM.getClassMetadataStrategy(classDecl);
928928
return strategy != ClassMetadataStrategy::Fixed;

lib/IRGen/MetadataRequest.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,16 +508,21 @@ bool shouldCacheTypeMetadataAccess(IRGenModule &IGM, CanType type);
508508
bool isInitializableTypeMetadataStaticallyAddressable(IRGenModule &IGM,
509509
CanType type);
510510

511+
enum CanonicalSpecializedMetadataUsageIsOnlyFromAccessor : bool {
512+
ForUseOnlyFromAccessor = true,
513+
NotForUseOnlyFromAccessor = false
514+
};
515+
511516
/// Is the address of the canonical specialization of a generic metadata
512517
/// statically known?
513518
///
514519
/// In other words, can a canonical specialization be formed for the specified
515-
/// type. If usingCanonicalSpecializedAccessor is true, then metadata's address
520+
/// type. If onlyFromAccess is ForUseOnlyFromAccessor, then metadata's address
516521
/// is known, but access to the metadata must go through the canonical
517522
/// specialized accessor so that initialization of the metadata can occur.
518523
bool isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
519524
IRGenModule &IGM, NominalTypeDecl &nominal, CanType type,
520-
bool usingCanonicalSpecializedAccessor);
525+
CanonicalSpecializedMetadataUsageIsOnlyFromAccessor onlyFromAccessor);
521526

522527
bool isCompleteCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
523528
IRGenModule &IGM, NominalTypeDecl &nominal, CanType type);

0 commit comments

Comments
 (0)