Skip to content

Commit b20c135

Browse files
authored
Merge pull request swiftlang#40209 from kubamracek/ndebug-vs-assert
Add #ifndef NDEBUG around assert() calls that use helper functions/variables that are also under #ifndef NDEBUG
2 parents 7c1e4de + 5bbf150 commit b20c135

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,7 +3262,9 @@ swift::swift_lookUpClassMethod(const ClassMetadata *metadata,
32623262
const ClassDescriptor *description) {
32633263
assert(metadata->isTypeMetadata());
32643264

3265+
#ifndef NDEBUG
32653266
assert(isAncestorOf(metadata, description));
3267+
#endif
32663268

32673269
auto *vtable = description->getVTableDescriptor();
32683270
assert(vtable != nullptr);
@@ -4021,9 +4023,11 @@ swift::swift_getExistentialTypeMetadata(
40214023

40224024
// Ensure that the "class constraint" bit is set whenever we have a
40234025
// superclass or a one of the protocols is class-bound.
4026+
#ifndef NDEBUG
40244027
assert(classConstraint == ProtocolClassConstraint::Class ||
40254028
(!superclassConstraint &&
40264029
!anyProtocolIsClassBound(numProtocols, protocols)));
4030+
#endif
40274031
ExistentialCacheEntry::Key key = {
40284032
superclassConstraint, classConstraint, (uint32_t)numProtocols, protocols
40294033
};

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,9 @@ ParsedTypeIdentity::parse(const TypeContextDescriptor *type) {
429429
result.ImportInfo->collect</*asserting*/true>(component);
430430
}
431431

432+
#ifndef NDEBUG
432433
assert(stage != AfterName && "no components?");
434+
#endif
433435

434436
// Record the full identity.
435437
result.FullIdentity =

0 commit comments

Comments
 (0)