Skip to content

Commit 714e955

Browse files
Merge pull request swiftlang#32242 from nate-chandler/generic-metadata-prespecialization-components/enum-not-bool
[metadata prespecialization] NFC: Replaced bool with enum.
2 parents b53334e + 5ce5466 commit 714e955

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

lib/IRGen/MetadataRequest.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ static MetadataResponse emitNominalMetadataRef(IRGenFunction &IGF,
672672
} else if (auto theClass = dyn_cast<ClassDecl>(theDecl)) {
673673
if (isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
674674
IGF.IGM, *theClass, theType,
675-
/*usingCanonicalSpecializedAccessor=*/true)) {
675+
ForUseOnlyFromAccessor)) {
676676
llvm::Function *accessor =
677677
IGF.IGM
678678
.getAddrOfCanonicalSpecializedGenericTypeMetadataAccessFunction(
@@ -699,7 +699,7 @@ static MetadataResponse emitNominalMetadataRef(IRGenFunction &IGF,
699699

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

705705
if (!IGM.shouldPrespecializeGenericMetadata()) {
@@ -788,7 +788,7 @@ bool irgen::isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
788788
(protocols.size() > 0);
789789
};
790790
auto metadataAccessIsTrivial = [&]() {
791-
if (usingCanonicalSpecializedAccessor) {
791+
if (onlyFromAccessor) {
792792
// If an accessor is being used, then the accessor will be able to
793793
// initialize the arguments, i.e. register classes with the ObjC
794794
// runtime.
@@ -821,7 +821,7 @@ bool irgen::
821821
// Struct<Klass<Int>>
822822
// Enum<Klass<Int>>
823823
return isCanonicalSpecializedNominalTypeMetadataStaticallyAddressable(
824-
IGM, nominal, type, /*usingCanonicalSpecializedAccessor=*/false);
824+
IGM, nominal, type, NotForUseOnlyFromAccessor);
825825
}
826826

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

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

lib/IRGen/MetadataRequest.h

+7-2
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)