From 23bfee2078b9bffddb439558bc0e37df76150caf Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 4 Jun 2020 08:55:57 -0700 Subject: [PATCH] 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. --- stdlib/public/runtime/Metadata.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/stdlib/public/runtime/Metadata.cpp b/stdlib/public/runtime/Metadata.cpp index 03c3975de837a..51dff44d4a530 100644 --- a/stdlib/public/runtime/Metadata.cpp +++ b/stdlib/public/runtime/Metadata.cpp @@ -113,15 +113,14 @@ Metadata *TargetSingletonMetadataInitialization::allocate( // Such a template will fail the `isTypeMetadata` test and we'll think that it // isn't Swift metadata but a plain old ObjC class instead. if (metadata->getKind() == MetadataKind::Class) { - auto *classMetadata = static_cast(metadata); -#if SWIFT_OBJC_INTEROP - classMetadata->setAsTypeMetadata(); -#endif auto *fullMetadata = asFullMetadata(metadata); // Begin by initializing the value witness table; everything else is // initialized by swift_initClassMetadata(). #if SWIFT_OBJC_INTEROP + auto *classMetadata = static_cast(metadata); + classMetadata->setAsTypeMetadata(); + fullMetadata->ValueWitnesses = (classMetadata->Flags & ClassFlags::UsesSwiftRefcounting) ? &VALUE_WITNESS_SYM(Bo)