Skip to content

Commit 23bfee2

Browse files
committed
runtime: silence -Wunused-variable warning (NFC)
`classMetadata` is only used in the ObjC path, resulting in a `-Wunused-variable` warning. Sink the variable into the ObjC path. Because the conversion of the metadata does not rely on the type metadata bits in the metadata, it is safe to delay the definition and bit adjustment to the point where it is used unifying the two ObjC paths.
1 parent 66311e1 commit 23bfee2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,14 @@ Metadata *TargetSingletonMetadataInitialization<InProcess>::allocate(
113113
// Such a template will fail the `isTypeMetadata` test and we'll think that it
114114
// isn't Swift metadata but a plain old ObjC class instead.
115115
if (metadata->getKind() == MetadataKind::Class) {
116-
auto *classMetadata = static_cast<ClassMetadata*>(metadata);
117-
#if SWIFT_OBJC_INTEROP
118-
classMetadata->setAsTypeMetadata();
119-
#endif
120116
auto *fullMetadata = asFullMetadata(metadata);
121117

122118
// Begin by initializing the value witness table; everything else is
123119
// initialized by swift_initClassMetadata().
124120
#if SWIFT_OBJC_INTEROP
121+
auto *classMetadata = static_cast<ClassMetadata*>(metadata);
122+
classMetadata->setAsTypeMetadata();
123+
125124
fullMetadata->ValueWitnesses =
126125
(classMetadata->Flags & ClassFlags::UsesSwiftRefcounting)
127126
? &VALUE_WITNESS_SYM(Bo)

0 commit comments

Comments
 (0)