Skip to content

Commit a2daee5

Browse files
authored
Merge pull request #7055 from hughbe/unreachable
Cleanup swift_unreachable
2 parents 6f19169 + 818099e commit a2daee5

File tree

13 files changed

+50
-45
lines changed

13 files changed

+50
-45
lines changed

include/swift/ABI/MetadataValues.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define SWIFT_ABI_METADATAVALUES_H
2121

2222
#include "swift/AST/Ownership.h"
23-
#include "swift/Basic/Unreachable.h"
23+
#include "swift/Runtime/Unreachable.h"
2424

2525
#include <stdlib.h>
2626
#include <stdint.h>
@@ -381,7 +381,7 @@ class ProtocolDescriptorFlags {
381381
return true;
382382
}
383383

384-
swift_unreachable("Unhandled ProtocolDispatchStrategy in switch.");
384+
swift_runtime_unreachable("Unhandled ProtocolDispatchStrategy in switch.");
385385
}
386386

387387
/// Return the identifier if this is a special runtime-known protocol.

include/swift/Reflection/ReflectionContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
#ifndef SWIFT_REFLECTION_REFLECTIONCONTEXT_H
1919
#define SWIFT_REFLECTION_REFLECTIONCONTEXT_H
2020

21-
#include "swift/Basic/Unreachable.h"
2221
#include "swift/Remote/MemoryReader.h"
2322
#include "swift/Remote/MetadataReader.h"
2423
#include "swift/Reflection/Records.h"
2524
#include "swift/Reflection/TypeLowering.h"
2625
#include "swift/Reflection/TypeRef.h"
2726
#include "swift/Reflection/TypeRefBuilder.h"
27+
#include "swift/Runtime/Unreachable.h"
2828

2929
#include <iostream>
3030
#include <set>
@@ -454,7 +454,7 @@ class ReflectionContext
454454
return true;
455455
}
456456

457-
swift_unreachable("Unhandled MetadataSourceKind in switch.");
457+
swift_runtime_unreachable("Unhandled MetadataSourceKind in switch.");
458458
}
459459

460460
/// Read metadata for a captured generic type from a closure context.

include/swift/Reflection/TypeRef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "llvm/ADT/DenseMap.h"
2222
#include "llvm/Support/Casting.h"
2323
#include "swift/ABI/MetadataValues.h"
24-
#include "swift/Basic/Unreachable.h"
24+
#include "swift/Runtime/Unreachable.h"
2525

2626
#include <iostream>
2727

@@ -783,7 +783,7 @@ class TypeRefVisitor {
783783
#include "swift/Reflection/TypeRefs.def"
784784
}
785785

786-
swift_unreachable("Unhandled TypeRefKind in switch.");
786+
swift_runtime_unreachable("Unhandled TypeRefKind in switch.");
787787
}
788788
};
789789

include/swift/Remote/MetadataReader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "swift/Remote/MemoryReader.h"
2222
#include "swift/Basic/Demangle.h"
2323
#include "swift/Basic/LLVM.h"
24-
#include "swift/Basic/Unreachable.h"
24+
#include "swift/Runtime/Unreachable.h"
2525

2626
#include <vector>
2727
#include <unordered_map>
@@ -763,7 +763,7 @@ class MetadataReader {
763763
}
764764
}
765765

766-
swift_unreachable("Unhandled MetadataKind in switch");
766+
swift_runtime_unreachable("Unhandled MetadataKind in switch");
767767
}
768768

769769
BuiltType readTypeFromMangledName(const char *MangledTypeName,

include/swift/Runtime/Debug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
#include <llvm/Support/Compiler.h>
2121
#include <stdint.h>
22-
#include "swift/Basic/Unreachable.h"
2322
#include "swift/Runtime/Config.h"
2423
#include "swift/Runtime/Metadata.h"
24+
#include "swift/Runtime/Unreachable.h"
2525

2626
#ifdef SWIFT_HAVE_CRASHREPORTERCLIENT
2727

@@ -72,7 +72,7 @@ static inline void crash(const char *message) {
7272
CRSetCrashLogMessage(message);
7373

7474
LLVM_BUILTIN_TRAP;
75-
swift_unreachable("Expected compiler to crash.");
75+
swift_runtime_unreachable("Expected compiler to crash.");
7676
}
7777

7878
/// Report a corrupted type object.

include/swift/Runtime/Metadata.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "swift/Basic/FlaggedPointer.h"
3434
#include "swift/Basic/RelativePointer.h"
3535
#include "swift/Basic/ManglingMacros.h"
36-
#include "swift/Basic/Unreachable.h"
36+
#include "swift/Runtime/Unreachable.h"
3737
#include "../../../stdlib/public/SwiftShims/HeapObject.h"
3838

3939
namespace swift {
@@ -1160,7 +1160,7 @@ struct TargetMetadata {
11601160
return false;
11611161
}
11621162

1163-
swift_unreachable("Unhandled MetadataKind in switch.");
1163+
swift_runtime_unreachable("Unhandled MetadataKind in switch.");
11641164
}
11651165

11661166
/// Is this metadata for an existential type?
@@ -1186,7 +1186,7 @@ struct TargetMetadata {
11861186
return false;
11871187
}
11881188

1189-
swift_unreachable("Unhandled MetadataKind in switch.");
1189+
swift_runtime_unreachable("Unhandled MetadataKind in switch.");
11901190
}
11911191

11921192
/// Is this either type metadata or a class object for any kind of class?
@@ -1267,7 +1267,7 @@ struct TargetMetadata {
12671267
return RelativeDirectPointerNullPtrRef;
12681268
}
12691269

1270-
swift_unreachable("Unhandled MetadataKind in switch.");
1270+
swift_runtime_unreachable("Unhandled MetadataKind in switch.");
12711271
}
12721272

12731273
/// Get the generic metadata pattern from which this generic type instance was
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- Unreachable.h - Implements swift_unreachable -----------*- C++ -*-===//
1+
//===--- Unreachable.h - Implements swift_runtime_unreachable ---*- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -10,23 +10,23 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212
//
13-
// This file defines swift_unreachable, an LLVM-independent implementation of
14-
// llvm_unreachable.
13+
// This file defines swift_runtime_unreachable, an LLVM-independent
14+
// implementation of llvm_unreachable.
1515
//
1616
//===----------------------------------------------------------------------===//
1717

18-
#ifndef SWIFT_BASIC_UNREACHABLE_H
19-
#define SWIFT_BASIC_UNREACHABLE_H
18+
#ifndef SWIFT_RUNTIME_UNREACHABLE_H
19+
#define SWIFT_RUNTIME_UNREACHABLE_H
2020

2121
#include "llvm/Support/Compiler.h"
2222
#include <assert.h>
2323
#include <stdlib.h>
2424

2525
LLVM_ATTRIBUTE_NORETURN
26-
inline static void swift_unreachable(const char* msg) {
26+
inline static void swift_runtime_unreachable(const char *msg) {
2727
assert(false && msg);
2828
(void)msg;
2929
abort();
3030
}
3131

32-
#endif // SWIFT_BASIC_UNREACHABLE_H
32+
#endif // SWIFT_RUNTIME_UNREACHABLE_H

stdlib/public/Reflection/TypeLowering.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
//===----------------------------------------------------------------------===//
2020

2121
#include "swift/Reflection/TypeLowering.h"
22-
#include "swift/Basic/Unreachable.h"
2322
#include "swift/Reflection/TypeRef.h"
2423
#include "swift/Reflection/TypeRefBuilder.h"
24+
#include "swift/Runtime/Unreachable.h"
2525

2626
#include <iostream>
2727

@@ -186,7 +186,7 @@ class PrintTypeInfo {
186186
}
187187
}
188188

189-
swift_unreachable("Bad TypeInfo kind");
189+
swift_runtime_unreachable("Bad TypeInfo kind");
190190
}
191191
};
192192

@@ -1043,7 +1043,7 @@ class LowerType
10431043
return nullptr;
10441044
}
10451045

1046-
swift_unreachable("Unhandled FieldDescriptorKind in switch.");
1046+
swift_runtime_unreachable("Unhandled FieldDescriptorKind in switch.");
10471047
}
10481048

10491049
const TypeInfo *visitNominalTypeRef(const NominalTypeRef *N) {
@@ -1074,7 +1074,7 @@ class LowerType
10741074
return TC.getTypeInfo(TC.getThinFunctionTypeRef());
10751075
}
10761076

1077-
swift_unreachable("Unhandled FunctionMetadataConvention in switch.");
1077+
swift_runtime_unreachable("Unhandled FunctionMetadataConvention in switch.");
10781078
}
10791079

10801080
const TypeInfo *visitProtocolTypeRef(const ProtocolTypeRef *P) {
@@ -1102,7 +1102,7 @@ class LowerType
11021102
return TC.getTypeInfo(TC.getAnyMetatypeTypeRef());
11031103
}
11041104

1105-
swift_unreachable("Unhandled MetatypeRepresentation in switch.");
1105+
swift_runtime_unreachable("Unhandled MetatypeRepresentation in switch.");
11061106
}
11071107

11081108
const TypeInfo *
@@ -1285,7 +1285,7 @@ const TypeInfo *TypeConverter::getClassInstanceTypeInfo(const TypeRef *TR,
12851285
return nullptr;
12861286
}
12871287

1288-
swift_unreachable("Unhandled FieldDescriptorKind in switch.");
1288+
swift_runtime_unreachable("Unhandled FieldDescriptorKind in switch.");
12891289
}
12901290

12911291
} // namespace reflection

stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "swift/Basic/Unreachable.h"
1413
#include "swift/Reflection/ReflectionContext.h"
1514
#include "swift/Reflection/TypeLowering.h"
1615
#include "swift/Remote/CMemoryReader.h"
16+
#include "swift/Runtime/Unreachable.h"
1717
#include "swift/SwiftRemoteMirror/SwiftRemoteMirror.h"
1818

1919
using namespace swift;
@@ -177,7 +177,7 @@ swift_layout_kind_t getTypeInfoKind(const TypeInfo &TI) {
177177
}
178178
}
179179

180-
swift_unreachable("Unhandled TypeInfoKind in switch");
180+
swift_runtime_unreachable("Unhandled TypeInfoKind in switch");
181181
}
182182

183183
static swift_typeinfo_t convertTypeInfo(const TypeInfo *TI) {

stdlib/public/runtime/Casting.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
#include "swift/Basic/Demangle.h"
1919
#include "swift/Basic/Fallthrough.h"
2020
#include "swift/Basic/Lazy.h"
21-
#include "swift/Basic/Unreachable.h"
2221
#include "swift/Runtime/Config.h"
2322
#include "swift/Runtime/Enum.h"
2423
#include "swift/Runtime/HeapObject.h"
2524
#include "swift/Runtime/Metadata.h"
2625
#include "swift/Runtime/Mutex.h"
26+
#include "swift/Runtime/Unreachable.h"
2727
#include "llvm/ADT/DenseMap.h"
2828
#include "llvm/ADT/PointerIntPair.h"
2929
#include "swift/Runtime/Debug.h"
@@ -1013,7 +1013,7 @@ static bool _dynamicCastToExistential(OpaqueValue *dest,
10131013
}
10141014
}
10151015

1016-
swift_unreachable("Unhandled ExistentialTypeRepresentation in switch.");
1016+
swift_runtime_unreachable("Unhandled ExistentialTypeRepresentation in switch.");
10171017
}
10181018

10191019
/******************************************************************************/
@@ -1276,7 +1276,7 @@ swift::swift_dynamicCastMetatype(const Metadata *sourceType,
12761276
return origSourceType;
12771277
}
12781278

1279-
swift_unreachable("Unhandled MetadataKind in switch.");
1279+
swift_runtime_unreachable("Unhandled MetadataKind in switch.");
12801280
}
12811281

12821282
const Metadata *
@@ -1388,7 +1388,7 @@ swift::swift_dynamicCastMetatypeUnconditional(const Metadata *sourceType,
13881388
return origSourceType;
13891389
}
13901390

1391-
swift_unreachable("Unhandled MetadataKind in switch.");
1391+
swift_runtime_unreachable("Unhandled MetadataKind in switch.");
13921392
}
13931393

13941394
/******************************************************************************/
@@ -1523,7 +1523,8 @@ static bool _dynamicCastToUnknownClassFromExistential(OpaqueValue *dest,
15231523
}
15241524
}
15251525

1526-
swift_unreachable("Unhandled ExistentialTypeRepresentation in switch.");
1526+
swift_runtime_unreachable(
1527+
"Unhandled ExistentialTypeRepresentation in switch.");
15271528
}
15281529

15291530
static void unwrapExistential(OpaqueValue *src,
@@ -1994,7 +1995,7 @@ static bool _dynamicCastToFunction(OpaqueValue *dest,
19941995
return _fail(src, srcType, targetType, flags);
19951996
}
19961997

1997-
swift_unreachable("Unhandled MetadataKind in switch.");
1998+
swift_runtime_unreachable("Unhandled MetadataKind in switch.");
19981999
}
19992000

20002001
/******************************************************************************/

stdlib/public/runtime/Metadata.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,7 @@ getExistentialValueWitnesses(ProtocolClassConstraint classConstraint,
22002200
return getOpaqueExistentialValueWitnesses(numWitnessTables);
22012201
}
22022202

2203-
swift_unreachable("Unhandled ProtocolClassConstraint in switch.");
2203+
swift_runtime_unreachable("Unhandled ProtocolClassConstraint in switch.");
22042204
}
22052205

22062206
template<> ExistentialTypeRepresentation
@@ -2243,7 +2243,8 @@ ExistentialTypeMetadata::mayTakeValue(const OpaqueValue *container) const {
22432243
}
22442244
}
22452245

2246-
swift_unreachable("Unhandled ExistentialTypeRepresentation in switch.");
2246+
swift_runtime_unreachable(
2247+
"Unhandled ExistentialTypeRepresentation in switch.");
22472248
}
22482249

22492250
template<> void
@@ -2294,7 +2295,8 @@ ExistentialTypeMetadata::projectValue(const OpaqueValue *container) const {
22942295
}
22952296
}
22962297

2297-
swift_unreachable("Unhandled ExistentialTypeRepresentation in switch.");
2298+
swift_runtime_unreachable(
2299+
"Unhandled ExistentialTypeRepresentation in switch.");
22982300
}
22992301

23002302
template<> const Metadata *
@@ -2318,7 +2320,8 @@ ExistentialTypeMetadata::getDynamicType(const OpaqueValue *container) const {
23182320
}
23192321
}
23202322

2321-
swift_unreachable("Unhandled ExistentialTypeRepresentation in switch.");
2323+
swift_runtime_unreachable(
2324+
"Unhandled ExistentialTypeRepresentation in switch.");
23222325
}
23232326

23242327
template<> const WitnessTable *
@@ -2609,7 +2612,7 @@ Metadata::getClassObject() const {
26092612
return nullptr;
26102613
}
26112614

2612-
swift_unreachable("Unhandled MetadataKind in switch.");
2615+
swift_runtime_unreachable("Unhandled MetadataKind in switch.");
26132616
}
26142617

26152618
#ifndef NDEBUG

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
#include "swift/Basic/LLVM.h"
1818
#include "swift/Basic/Lazy.h"
19-
#include "swift/Basic/Unreachable.h"
2019
#include "swift/Runtime/Concurrent.h"
2120
#include "swift/Runtime/Metadata.h"
2221
#include "swift/Runtime/Mutex.h"
22+
#include "swift/Runtime/Unreachable.h"
2323
#include "ImageInspection.h"
2424
#include "Private.h"
2525

@@ -118,7 +118,7 @@ const {
118118
return nullptr;
119119
}
120120

121-
swift_unreachable("Unhandled TypeMetadataRecordKind in switch.");
121+
swift_runtime_unreachable("Unhandled TypeMetadataRecordKind in switch.");
122122
}
123123

124124
template<>
@@ -133,7 +133,8 @@ const {
133133
return getWitnessTableAccessor()(type);
134134
}
135135

136-
swift_unreachable("Unhandled ProtocolConformanceReferenceKind in switch.");
136+
swift_runtime_unreachable(
137+
"Unhandled ProtocolConformanceReferenceKind in switch.");
137138
}
138139

139140
namespace {

0 commit comments

Comments
 (0)