[NFC] Rename swift_runtime_unreachable to swift_unreachable and make it use LLVM's support when available.

This commit is contained in:
John McCall
2020-10-03 02:39:21 -04:00
parent 66a42d8de7
commit 0fb407943f
38 changed files with 112 additions and 73 deletions

View File

@@ -38,7 +38,7 @@
#include "swift/Basic/RelativePointer.h" #include "swift/Basic/RelativePointer.h"
#include "swift/Demangling/Demangle.h" #include "swift/Demangling/Demangle.h"
#include "swift/Demangling/ManglingMacros.h" #include "swift/Demangling/ManglingMacros.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#include "../../../stdlib/public/SwiftShims/HeapObject.h" #include "../../../stdlib/public/SwiftShims/HeapObject.h"
#if SWIFT_OBJC_INTEROP #if SWIFT_OBJC_INTEROP
#include <objc/runtime.h> #include <objc/runtime.h>
@@ -4664,7 +4664,7 @@ int32_t TargetTypeContextDescriptor<Runtime>::getGenericArgumentOffset() const {
return llvm::cast<TargetStructDescriptor<Runtime>>(this) return llvm::cast<TargetStructDescriptor<Runtime>>(this)
->getGenericArgumentOffset(); ->getGenericArgumentOffset();
default: default:
swift_runtime_unreachable("Not a type context descriptor."); swift_unreachable("Not a type context descriptor.");
} }
} }
@@ -4682,7 +4682,7 @@ TargetTypeContextDescriptor<Runtime>::getFullGenericContextHeader() const {
return llvm::cast<TargetStructDescriptor<Runtime>>(this) return llvm::cast<TargetStructDescriptor<Runtime>>(this)
->getFullGenericContextHeader(); ->getFullGenericContextHeader();
default: default:
swift_runtime_unreachable("Not a type context descriptor."); swift_unreachable("Not a type context descriptor.");
} }
} }
@@ -4699,7 +4699,7 @@ TargetTypeContextDescriptor<Runtime>::getGenericParams() const {
case ContextDescriptorKind::OpaqueType: case ContextDescriptorKind::OpaqueType:
return llvm::cast<TargetOpaqueTypeDescriptor<Runtime>>(this)->getGenericParams(); return llvm::cast<TargetOpaqueTypeDescriptor<Runtime>>(this)->getGenericParams();
default: default:
swift_runtime_unreachable("Not a type context descriptor."); swift_unreachable("Not a type context descriptor.");
} }
} }
@@ -4717,7 +4717,7 @@ TargetTypeContextDescriptor<Runtime>::getForeignMetadataInitialization() const {
return llvm::cast<TargetStructDescriptor<Runtime>>(this) return llvm::cast<TargetStructDescriptor<Runtime>>(this)
->getForeignMetadataInitialization(); ->getForeignMetadataInitialization();
default: default:
swift_runtime_unreachable("Not a type context descriptor."); swift_unreachable("Not a type context descriptor.");
} }
} }
@@ -4735,7 +4735,7 @@ TargetTypeContextDescriptor<Runtime>::getSingletonMetadataInitialization() const
return llvm::cast<TargetClassDescriptor<Runtime>>(this) return llvm::cast<TargetClassDescriptor<Runtime>>(this)
->getSingletonMetadataInitialization(); ->getSingletonMetadataInitialization();
default: default:
swift_runtime_unreachable("Not a enum, struct or class type descriptor."); swift_unreachable("Not a enum, struct or class type descriptor.");
} }
} }
@@ -4753,7 +4753,7 @@ TargetTypeContextDescriptor<Runtime>::getCanonicicalMetadataPrespecializations()
return llvm::cast<TargetClassDescriptor<Runtime>>(this) return llvm::cast<TargetClassDescriptor<Runtime>>(this)
->getCanonicicalMetadataPrespecializations(); ->getCanonicicalMetadataPrespecializations();
default: default:
swift_runtime_unreachable("Not a type context descriptor."); swift_unreachable("Not a type context descriptor.");
} }
} }

View File

@@ -19,7 +19,7 @@
#ifndef SWIFT_ABI_PROTOCOLDISPATCHSTRATEGY_H #ifndef SWIFT_ABI_PROTOCOLDISPATCHSTRATEGY_H
#define SWIFT_ABI_PROTOCOLDISPATCHSTRATEGY_H #define SWIFT_ABI_PROTOCOLDISPATCHSTRATEGY_H
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
namespace swift { namespace swift {
@@ -46,7 +46,7 @@ inline bool protocolRequiresWitnessTable(ProtocolDispatchStrategy strategy) {
return true; return true;
} }
swift_runtime_unreachable("Unhandled ProtocolDispatchStrategy in switch."); swift_unreachable("Unhandled ProtocolDispatchStrategy in switch.");
} }
} }

View File

@@ -1,4 +1,4 @@
//===--- Unreachable.h - Implements swift_runtime_unreachable ---*- C++ -*-===// //===--- Unreachable.h - Implements swift_unreachable ---*- C++ -*-===//
// //
// This source file is part of the Swift.org open source project // This source file is part of the Swift.org open source project
// //
@@ -10,13 +10,25 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines swift_runtime_unreachable, an LLVM-independent // This file defines swift_unreachable, which provides the
// implementation of llvm_unreachable. // functionality of llvm_unreachable without necessarily depending on
// the LLVM support libraries.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef SWIFT_RUNTIME_UNREACHABLE_H #ifndef SWIFT_BASIC_UNREACHABLE_H
#define SWIFT_RUNTIME_UNREACHABLE_H #define SWIFT_BASIC_UNREACHABLE_H
#ifdef SWIFT_LLVM_SUPPORT_IS_AVAILABLE
// The implementation when LLVM is available.
#include "llvm/Support/ErrorHandling.h"
#define swift_unreachable llvm_unreachable
#else
// The implementation when LLVM is not available.
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
@@ -24,10 +36,12 @@
#include "swift/Runtime/Config.h" #include "swift/Runtime/Config.h"
SWIFT_RUNTIME_ATTRIBUTE_NORETURN SWIFT_RUNTIME_ATTRIBUTE_NORETURN
inline static void swift_runtime_unreachable(const char *msg) { inline static void swift_unreachable(const char *msg) {
assert(false && msg); assert(false && msg);
(void)msg; (void)msg;
abort(); abort();
} }
#endif // SWIFT_RUNTIME_UNREACHABLE_H #endif
#endif

View File

@@ -24,7 +24,7 @@
#include "swift/Demangling/Demangler.h" #include "swift/Demangling/Demangler.h"
#include "swift/Demangling/NamespaceMacros.h" #include "swift/Demangling/NamespaceMacros.h"
#include "swift/Runtime/Portability.h" #include "swift/Runtime/Portability.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#include "swift/Strings.h" #include "swift/Strings.h"
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include <vector> #include <vector>

View File

@@ -33,7 +33,7 @@
#include "swift/Reflection/TypeLowering.h" #include "swift/Reflection/TypeLowering.h"
#include "swift/Reflection/TypeRef.h" #include "swift/Reflection/TypeRef.h"
#include "swift/Reflection/TypeRefBuilder.h" #include "swift/Reflection/TypeRefBuilder.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#include <set> #include <set>
#include <unordered_map> #include <unordered_map>
@@ -1302,7 +1302,7 @@ private:
return true; return true;
} }
swift_runtime_unreachable("Unhandled MetadataSourceKind in switch."); swift_unreachable("Unhandled MetadataSourceKind in switch.");
} }
/// Read metadata for a captured generic type from a closure context. /// Read metadata for a captured generic type from a closure context.

View File

@@ -22,7 +22,7 @@
#include "llvm/Support/Casting.h" #include "llvm/Support/Casting.h"
#include "swift/ABI/MetadataValues.h" #include "swift/ABI/MetadataValues.h"
#include "swift/Remote/MetadataReader.h" #include "swift/Remote/MetadataReader.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
namespace swift { namespace swift {
namespace reflection { namespace reflection {
@@ -856,7 +856,7 @@ public:
#include "swift/Reflection/TypeRefs.def" #include "swift/Reflection/TypeRefs.def"
} }
swift_runtime_unreachable("Unhandled TypeRefKind in switch."); swift_unreachable("Unhandled TypeRefKind in switch.");
} }
}; };

View File

@@ -28,7 +28,7 @@
#include "swift/ABI/TypeIdentity.h" #include "swift/ABI/TypeIdentity.h"
#include "swift/Runtime/ExistentialContainer.h" #include "swift/Runtime/ExistentialContainer.h"
#include "swift/Runtime/HeapObject.h" #include "swift/Runtime/HeapObject.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
@@ -923,7 +923,7 @@ public:
} }
} }
swift_runtime_unreachable("Unhandled MetadataKind in switch"); swift_unreachable("Unhandled MetadataKind in switch");
} }
TypeLookupErrorOr<typename BuilderType::BuiltType> TypeLookupErrorOr<typename BuilderType::BuiltType>
@@ -1295,7 +1295,7 @@ public:
} }
} }
swift_runtime_unreachable("Unhandled IsaEncodingKind in switch."); swift_unreachable("Unhandled IsaEncodingKind in switch.");
} }
/// Read the offset of the generic parameters of a class from the nominal /// Read the offset of the generic parameters of a class from the nominal

View File

@@ -18,7 +18,7 @@
#define SWIFT_RUNTIME_DEBUG_HELPERS_H #define SWIFT_RUNTIME_DEBUG_HELPERS_H
#include "swift/Runtime/Config.h" #include "swift/Runtime/Config.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#include <atomic> #include <atomic>
#include <cstdarg> #include <cstdarg>
#include <functional> #include <functional>
@@ -79,7 +79,7 @@ static inline void crash(const char *message) {
CRSetCrashLogMessage(message); CRSetCrashLogMessage(message);
SWIFT_RUNTIME_BUILTIN_TRAP; SWIFT_RUNTIME_BUILTIN_TRAP;
swift_runtime_unreachable("Expected compiler to crash."); swift_unreachable("Expected compiler to crash.");
} }
// swift::fatalError() halts with a crash log message, // swift::fatalError() halts with a crash log message,

View File

@@ -9,6 +9,8 @@ else()
) )
endif() endif()
set_swift_llvm_is_available()
add_swift_host_library(swiftAST STATIC add_swift_host_library(swiftAST STATIC
AbstractSourceFileDepGraphFactory.cpp AbstractSourceFileDepGraphFactory.cpp
AccessRequests.cpp AccessRequests.cpp

View File

@@ -1,3 +1,5 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftASTSectionImporter STATIC add_swift_host_library(swiftASTSectionImporter STATIC
ASTSectionImporter.cpp ASTSectionImporter.cpp
LLVM_LINK_COMPONENTS core) LLVM_LINK_COMPONENTS core)

View File

@@ -4,6 +4,8 @@ set(SWIFT_GYB_FLAGS
add_gyb_target(generated_sorted_cf_database add_gyb_target(generated_sorted_cf_database
SortedCFDatabase.def.gyb) SortedCFDatabase.def.gyb)
set_swift_llvm_is_available()
add_swift_host_library(swiftClangImporter STATIC add_swift_host_library(swiftClangImporter STATIC
CFTypeInfo.cpp CFTypeInfo.cpp
ClangAdapter.cpp ClangAdapter.cpp

View File

@@ -1,3 +1,5 @@
set_swift_llvm_is_available()
set(swiftDriver_sources set(swiftDriver_sources
Action.cpp Action.cpp
Compilation.cpp Compilation.cpp

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftFrontend STATIC add_swift_host_library(swiftFrontend STATIC
ArgsToFrontendInputsConverter.cpp ArgsToFrontendInputsConverter.cpp
ArgsToFrontendOptionsConverter.cpp ArgsToFrontendOptionsConverter.cpp

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftFrontendTool STATIC add_swift_host_library(swiftFrontendTool STATIC
FrontendTool.cpp FrontendTool.cpp
ImportedModules.cpp ImportedModules.cpp

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftIDE STATIC add_swift_host_library(swiftIDE STATIC
CodeCompletion.cpp CodeCompletion.cpp
CodeCompletionCache.cpp CodeCompletionCache.cpp

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftIRGen STATIC add_swift_host_library(swiftIRGen STATIC
AllocStackHoisting.cpp AllocStackHoisting.cpp
ClassLayout.cpp ClassLayout.cpp

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftLLVMPasses STATIC add_swift_host_library(swiftLLVMPasses STATIC
LLVMSwiftAA.cpp LLVMSwiftAA.cpp
LLVMSwiftRCIdentity.cpp LLVMSwiftRCIdentity.cpp

View File

@@ -47,6 +47,8 @@ swift_install_in_component(FILES ${datafiles}
DESTINATION "lib/swift/migrator" DESTINATION "lib/swift/migrator"
COMPONENT compiler) COMPONENT compiler)
set_swift_llvm_is_available()
add_swift_host_library(swiftMigrator STATIC add_swift_host_library(swiftMigrator STATIC
APIDiffMigratorPass.cpp APIDiffMigratorPass.cpp
EditorAdapter.cpp EditorAdapter.cpp

View File

@@ -1,3 +1,5 @@
set_swift_llvm_is_available()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(SWIFT_GYB_FLAGS --line-directive "^\"#line %(line)d \\\"%(file)s\\\"^\"") set(SWIFT_GYB_FLAGS --line-directive "^\"#line %(line)d \\\"%(file)s\\\"^\"")
else() else()

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftPrintAsObjC STATIC add_swift_host_library(swiftPrintAsObjC STATIC
DeclAndTypePrinter.cpp DeclAndTypePrinter.cpp
ModuleContentsWriter.cpp ModuleContentsWriter.cpp

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftSIL STATIC add_swift_host_library(swiftSIL STATIC
SIL.cpp) SIL.cpp)
target_link_libraries(swiftSIL PUBLIC target_link_libraries(swiftSIL PUBLIC

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftSILGen STATIC add_swift_host_library(swiftSILGen STATIC
ArgumentSource.cpp ArgumentSource.cpp
Cleanup.cpp Cleanup.cpp

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftSILOptimizer STATIC add_swift_host_library(swiftSILOptimizer STATIC
SILOptimizer.cpp) SILOptimizer.cpp)
target_link_libraries(swiftSILOptimizer PRIVATE target_link_libraries(swiftSILOptimizer PRIVATE

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftSema STATIC add_swift_host_library(swiftSema STATIC
BuilderTransform.cpp BuilderTransform.cpp
CSApply.cpp CSApply.cpp

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftSerialization STATIC add_swift_host_library(swiftSerialization STATIC
Deserialization.cpp Deserialization.cpp
DeserializeSIL.cpp DeserializeSIL.cpp

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftSyntaxParse STATIC add_swift_host_library(swiftSyntaxParse STATIC
RawSyntaxTokenCache.cpp RawSyntaxTokenCache.cpp
SyntaxTreeCreator.cpp) SyntaxTreeCreator.cpp)

View File

@@ -1,3 +1,4 @@
set_swift_llvm_is_available()
add_swift_host_library(swiftTBDGen STATIC add_swift_host_library(swiftTBDGen STATIC
TBDGen.cpp TBDGen.cpp
TBDGenRequests.cpp TBDGenRequests.cpp

View File

@@ -23,7 +23,7 @@
#include "swift/Reflection/TypeLowering.h" #include "swift/Reflection/TypeLowering.h"
#include "swift/Reflection/TypeRef.h" #include "swift/Reflection/TypeRef.h"
#include "swift/Reflection/TypeRefBuilder.h" #include "swift/Reflection/TypeRefBuilder.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#ifdef DEBUG_TYPE_LOWERING #ifdef DEBUG_TYPE_LOWERING
#define DEBUG_LOG(expr) expr; #define DEBUG_LOG(expr) expr;
@@ -212,7 +212,7 @@ public:
} }
} }
swift_runtime_unreachable("Bad TypeInfo kind"); swift_unreachable("Bad TypeInfo kind");
} }
}; };
@@ -2007,7 +2007,7 @@ public:
return nullptr; return nullptr;
} }
swift_runtime_unreachable("Unhandled FieldDescriptorKind in switch."); swift_unreachable("Unhandled FieldDescriptorKind in switch.");
} }
const TypeInfo *visitNominalTypeRef(const NominalTypeRef *N) { const TypeInfo *visitNominalTypeRef(const NominalTypeRef *N) {
@@ -2039,7 +2039,7 @@ public:
return TC.getTypeInfo(TC.getThinFunctionTypeRef(), ExternalTypeInfo); return TC.getTypeInfo(TC.getThinFunctionTypeRef(), ExternalTypeInfo);
} }
swift_runtime_unreachable("Unhandled FunctionMetadataConvention in switch."); swift_unreachable("Unhandled FunctionMetadataConvention in switch.");
} }
const TypeInfo * const TypeInfo *
@@ -2060,7 +2060,7 @@ public:
return TC.getTypeInfo(TC.getAnyMetatypeTypeRef(), ExternalTypeInfo); return TC.getTypeInfo(TC.getAnyMetatypeTypeRef(), ExternalTypeInfo);
} }
swift_runtime_unreachable("Unhandled MetatypeRepresentation in switch."); swift_unreachable("Unhandled MetatypeRepresentation in switch.");
} }
const TypeInfo * const TypeInfo *
@@ -2256,7 +2256,7 @@ const TypeInfo *TypeConverter::getClassInstanceTypeInfo(
return nullptr; return nullptr;
} }
swift_runtime_unreachable("Unhandled FieldDescriptorKind in switch."); swift_unreachable("Unhandled FieldDescriptorKind in switch.");
} }
} // namespace reflection } // namespace reflection

View File

@@ -23,7 +23,7 @@ unsigned long long swift_reflection_classIsSwiftMask = 2;
#include "swift/Reflection/ReflectionContext.h" #include "swift/Reflection/ReflectionContext.h"
#include "swift/Reflection/TypeLowering.h" #include "swift/Reflection/TypeLowering.h"
#include "swift/Remote/CMemoryReader.h" #include "swift/Remote/CMemoryReader.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h> #include <TargetConditionals.h>
@@ -406,7 +406,7 @@ swift_layout_kind_t getTypeInfoKind(const TypeInfo &TI) {
} }
} }
swift_runtime_unreachable("Unhandled TypeInfoKind in switch"); swift_unreachable("Unhandled TypeInfoKind in switch");
} }
static swift_typeinfo_t convertTypeInfo(const TypeInfo *TI) { static swift_typeinfo_t convertTypeInfo(const TypeInfo *TI) {

View File

@@ -35,7 +35,7 @@
# define SWIFT_CASTING_SUPPORTS_MUTEX 1 # define SWIFT_CASTING_SUPPORTS_MUTEX 1
# include "swift/Runtime/Mutex.h" # include "swift/Runtime/Mutex.h"
#endif #endif
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerIntPair.h"
#if SWIFT_OBJC_INTEROP #if SWIFT_OBJC_INTEROP
@@ -1016,7 +1016,7 @@ static bool _dynamicCastToExistential(OpaqueValue *dest,
} }
} }
swift_runtime_unreachable("Unhandled ExistentialTypeRepresentation in switch."); swift_unreachable("Unhandled ExistentialTypeRepresentation in switch.");
} }
/******************************************************************************/ /******************************************************************************/
@@ -1214,7 +1214,7 @@ swift_dynamicCastMetatypeImpl(const Metadata *sourceType,
return nullptr; return nullptr;
} }
swift_runtime_unreachable("Unhandled MetadataKind in switch."); swift_unreachable("Unhandled MetadataKind in switch.");
} }
static const Metadata * static const Metadata *
@@ -1424,7 +1424,7 @@ static bool _dynamicCastToUnknownClassFromExistential(OpaqueValue *dest,
} }
} }
swift_runtime_unreachable( swift_unreachable(
"Unhandled ExistentialTypeRepresentation in switch."); "Unhandled ExistentialTypeRepresentation in switch.");
} }

View File

@@ -1806,7 +1806,7 @@ static tryCastFunctionType *selectCasterForDest(const Metadata *destType) {
case ExistentialTypeRepresentation::Error: // => Error existential case ExistentialTypeRepresentation::Error: // => Error existential
return tryCastToErrorExistential; return tryCastToErrorExistential;
} }
swift_runtime_unreachable( swift_unreachable(
"Unknown existential type representation in dynamic cast dispatch"); "Unknown existential type representation in dynamic cast dispatch");
} }
case MetadataKind::Metatype: case MetadataKind::Metatype:
@@ -1821,14 +1821,14 @@ static tryCastFunctionType *selectCasterForDest(const Metadata *destType) {
// These are internal details of runtime-only structures, // These are internal details of runtime-only structures,
// so will never appear in compiler-generated types. // so will never appear in compiler-generated types.
// As such, they don't need support here. // As such, they don't need support here.
swift_runtime_unreachable( swift_unreachable(
"Unexpected MetadataKind in dynamic cast dispatch"); "Unexpected MetadataKind in dynamic cast dispatch");
return nullptr; return nullptr;
default: default:
// If you see this message, then there is a new MetadataKind that I didn't // If you see this message, then there is a new MetadataKind that I didn't
// know about when I wrote this code. Please figure out what it is, how to // know about when I wrote this code. Please figure out what it is, how to
// handle it, and add a case for it. // handle it, and add a case for it.
swift_runtime_unreachable( swift_unreachable(
"Unknown MetadataKind in dynamic cast dispatch"); "Unknown MetadataKind in dynamic cast dispatch");
} }
} }

View File

@@ -219,7 +219,7 @@ public:
} }
} }
swift_runtime_unreachable("access not found in set"); swift_unreachable("access not found in set");
} }
#ifndef NDEBUG #ifndef NDEBUG

View File

@@ -194,7 +194,7 @@ computeMetadataBoundsForSuperclass(const void *ref,
#endif #endif
} }
} }
swift_runtime_unreachable("unsupported superclass reference kind"); swift_unreachable("unsupported superclass reference kind");
} }
static ClassMetadataBounds computeMetadataBoundsFromSuperclass( static ClassMetadataBounds computeMetadataBoundsFromSuperclass(
@@ -3716,7 +3716,7 @@ getExistentialValueWitnesses(ProtocolClassConstraint classConstraint,
return getOpaqueExistentialValueWitnesses(numWitnessTables); return getOpaqueExistentialValueWitnesses(numWitnessTables);
} }
swift_runtime_unreachable("Unhandled ProtocolClassConstraint in switch."); swift_unreachable("Unhandled ProtocolClassConstraint in switch.");
} }
template<> ExistentialTypeRepresentation template<> ExistentialTypeRepresentation
@@ -3761,7 +3761,7 @@ ExistentialTypeMetadata::mayTakeValue(const OpaqueValue *container) const {
} }
} }
swift_runtime_unreachable( swift_unreachable(
"Unhandled ExistentialTypeRepresentation in switch."); "Unhandled ExistentialTypeRepresentation in switch.");
} }
@@ -3810,7 +3810,7 @@ ExistentialTypeMetadata::projectValue(const OpaqueValue *container) const {
} }
} }
swift_runtime_unreachable( swift_unreachable(
"Unhandled ExistentialTypeRepresentation in switch."); "Unhandled ExistentialTypeRepresentation in switch.");
} }
@@ -3835,7 +3835,7 @@ ExistentialTypeMetadata::getDynamicType(const OpaqueValue *container) const {
} }
} }
swift_runtime_unreachable( swift_unreachable(
"Unhandled ExistentialTypeRepresentation in switch."); "Unhandled ExistentialTypeRepresentation in switch.");
} }
@@ -4030,7 +4030,7 @@ class ForeignMetadataCacheEntry
return Value; return Value;
} }
void setValue(ValueType value) { void setValue(ValueType value) {
swift_runtime_unreachable("should never be called"); swift_unreachable("should never be called");
} }
public: public:
@@ -4094,7 +4094,7 @@ public:
} }
AllocationResult allocate(Metadata *candidate) { AllocationResult allocate(Metadata *candidate) {
swift_runtime_unreachable( swift_unreachable(
"always flags allocation complete during construction"); "always flags allocation complete during construction");
} }
@@ -4555,7 +4555,7 @@ static void initProtocolWitness(void **slot, void *witness,
reqt); reqt);
return; return;
} }
swift_runtime_unreachable("bad witness kind"); swift_unreachable("bad witness kind");
#else #else
*slot = witness; *slot = witness;
#endif #endif
@@ -4588,7 +4588,7 @@ static void copyProtocolWitness(void **dest, void * const *src,
swift_ptrauth_copy(dest, src, reqt.Flags.getExtraDiscriminator()); swift_ptrauth_copy(dest, src, reqt.Flags.getExtraDiscriminator());
return; return;
} }
swift_runtime_unreachable("bad witness kind"); swift_unreachable("bad witness kind");
#else #else
*dest = *src; *dest = *src;
#endif #endif
@@ -5141,7 +5141,7 @@ static const WitnessTable *swift_getAssociatedConformanceWitnessSlowImpl(
return assocWitnessTable; return assocWitnessTable;
} }
swift_runtime_unreachable("Invalid mangled associate conformance"); swift_unreachable("Invalid mangled associate conformance");
} }
const WitnessTable *swift::swift_getAssociatedConformanceWitness( const WitnessTable *swift::swift_getAssociatedConformanceWitness(
@@ -5234,7 +5234,7 @@ static Result performOnMetadataCache(const Metadata *metadata,
case TypeContextDescriptorFlags::SingletonMetadataInitialization: case TypeContextDescriptorFlags::SingletonMetadataInitialization:
return std::move(callbacks).forSingletonMetadata(description); return std::move(callbacks).forSingletonMetadata(description);
} }
swift_runtime_unreachable("bad metadata initialization kind"); swift_unreachable("bad metadata initialization kind");
} }
auto &generics = description->getFullGenericContextHeader(); auto &generics = description->getFullGenericContextHeader();
@@ -5280,7 +5280,7 @@ bool swift::addToMetadataQueue(MetadataCompletionQueueEntry *queueEntry,
} }
bool forOtherMetadata(const Metadata *metadata) && { bool forOtherMetadata(const Metadata *metadata) && {
swift_runtime_unreachable("metadata should always be complete"); swift_unreachable("metadata should always be complete");
} }
} callbacks = { queueEntry, dependency }; } callbacks = { queueEntry, dependency };
@@ -5312,7 +5312,7 @@ void swift::resumeMetadataCompletion(MetadataCompletionQueueEntry *queueEntry) {
} }
void forOtherMetadata(const Metadata *metadata) && { void forOtherMetadata(const Metadata *metadata) && {
swift_runtime_unreachable("metadata should always be complete"); swift_unreachable("metadata should always be complete");
} }
} callbacks = { queueEntry }; } callbacks = { queueEntry };

View File

@@ -366,7 +366,7 @@ public:
template <class... ArgTys> template <class... ArgTys>
Status beginInitialization(ConcurrencyControl &concurrency, Status beginInitialization(ConcurrencyControl &concurrency,
ArgTys &&...args) { ArgTys &&...args) {
swift_runtime_unreachable("beginAllocation always short-circuits"); swift_unreachable("beginAllocation always short-circuits");
} }
}; };
@@ -592,7 +592,7 @@ inline bool satisfies(PrivateMetadataState state, MetadataState requirement) {
case MetadataState::Complete: case MetadataState::Complete:
return state >= PrivateMetadataState::Complete; return state >= PrivateMetadataState::Complete;
} }
swift_runtime_unreachable("unsupported requirement kind"); swift_unreachable("unsupported requirement kind");
} }
class PrivateMetadataTrackingInfo { class PrivateMetadataTrackingInfo {
@@ -642,7 +642,7 @@ public:
MetadataState getAccomplishedRequestState() const { MetadataState getAccomplishedRequestState() const {
switch (getState()) { switch (getState()) {
case PrivateMetadataState::Allocating: case PrivateMetadataState::Allocating:
swift_runtime_unreachable("cannot call on allocating state"); swift_unreachable("cannot call on allocating state");
case PrivateMetadataState::Abstract: case PrivateMetadataState::Abstract:
return MetadataState::Abstract; return MetadataState::Abstract;
case PrivateMetadataState::LayoutComplete: case PrivateMetadataState::LayoutComplete:
@@ -652,7 +652,7 @@ public:
case PrivateMetadataState::Complete: case PrivateMetadataState::Complete:
return MetadataState::Complete; return MetadataState::Complete;
} }
swift_runtime_unreachable("bad state"); swift_unreachable("bad state");
} }
bool satisfies(MetadataState requirement) { bool satisfies(MetadataState requirement) {
@@ -678,7 +678,7 @@ public:
// Otherwise, if it's a non-blocking request, we do not need to block. // Otherwise, if it's a non-blocking request, we do not need to block.
return (request.isBlocking() && !satisfies(request.getState())); return (request.isBlocking() && !satisfies(request.getState()));
} }
swift_runtime_unreachable("bad state"); swift_unreachable("bad state");
} }
constexpr RawType getRawValue() const { return Data; } constexpr RawType getRawValue() const { return Data; }
@@ -1124,9 +1124,9 @@ private:
return; return;
case LSK::Complete: case LSK::Complete:
swift_runtime_unreachable("preparing to enqueue when already complete?"); swift_unreachable("preparing to enqueue when already complete?");
} }
swift_runtime_unreachable("bad kind"); swift_unreachable("bad kind");
} }
/// Claim all the satisfied completion queue entries, given that /// Claim all the satisfied completion queue entries, given that
@@ -1288,7 +1288,7 @@ public:
switch (LockedStorageKind) { switch (LockedStorageKind) {
case LSK::Complete: case LSK::Complete:
swift_runtime_unreachable("enqueuing on complete cache entry?"); swift_unreachable("enqueuing on complete cache entry?");
case LSK::AllocatingThread: case LSK::AllocatingThread:
LockedStorageKind = LSK::CompletionQueue; LockedStorageKind = LSK::CompletionQueue;
@@ -1340,7 +1340,7 @@ public:
// Check for an existing dependency. // Check for an existing dependency.
switch (LockedStorageKind) { switch (LockedStorageKind) {
case LSK::Complete: case LSK::Complete:
swift_runtime_unreachable("dependency on complete cache entry?"); swift_unreachable("dependency on complete cache entry?");
case LSK::AllocatingThread: case LSK::AllocatingThread:
case LSK::CompletionQueue: case LSK::CompletionQueue:

View File

@@ -88,10 +88,10 @@ static uintptr_t resolveSymbolicReferenceOffset(SymbolicReferenceKind kind,
return (uintptr_t)contextPtr; return (uintptr_t)contextPtr;
} }
case SymbolicReferenceKind::AccessorFunctionReference: { case SymbolicReferenceKind::AccessorFunctionReference: {
swift_runtime_unreachable("should not be indirectly referenced"); swift_unreachable("should not be indirectly referenced");
} }
} }
swift_runtime_unreachable("unknown symbolic reference kind"); swift_unreachable("unknown symbolic reference kind");
} else { } else {
return ptr; return ptr;
} }
@@ -176,7 +176,7 @@ _buildDemanglingForSymbolicReference(SymbolicReferenceKind kind,
(uintptr_t)resolvedReference); (uintptr_t)resolvedReference);
} }
swift_runtime_unreachable("invalid symbolic reference kind"); swift_unreachable("invalid symbolic reference kind");
} }
NodePointer NodePointer
@@ -1168,7 +1168,7 @@ findAssociatedTypeByName(const ProtocolDescriptor *protocol, StringRef name) {
++currentAssocTypeIdx; ++currentAssocTypeIdx;
} }
swift_runtime_unreachable("associated type names don't line up"); swift_unreachable("associated type names don't line up");
} }
namespace { namespace {

View File

@@ -20,7 +20,7 @@
#include "swift/Runtime/Concurrent.h" #include "swift/Runtime/Concurrent.h"
#include "swift/Runtime/HeapObject.h" #include "swift/Runtime/HeapObject.h"
#include "swift/Runtime/Metadata.h" #include "swift/Runtime/Metadata.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#include "CompatibilityOverride.h" #include "CompatibilityOverride.h"
#include "ImageInspection.h" #include "ImageInspection.h"
#include "Private.h" #include "Private.h"
@@ -116,7 +116,7 @@ const ClassMetadata *TypeReference::getObjCClass(TypeReferenceKind kind) const {
return nullptr; return nullptr;
} }
swift_runtime_unreachable("Unhandled TypeReferenceKind in switch."); swift_unreachable("Unhandled TypeReferenceKind in switch.");
} }
#endif #endif
@@ -155,7 +155,7 @@ ProtocolConformanceDescriptor::getCanonicalTypeMetadata() const {
} }
} }
swift_runtime_unreachable("Unhandled TypeReferenceKind in switch."); swift_unreachable("Unhandled TypeReferenceKind in switch.");
} }
template<> template<>

View File

@@ -17,7 +17,7 @@
#include "swift/Runtime/HeapObject.h" #include "swift/Runtime/HeapObject.h"
#include "swift/Runtime/Metadata.h" #include "swift/Runtime/Metadata.h"
#include "swift/Runtime/Enum.h" #include "swift/Runtime/Enum.h"
#include "swift/Runtime/Unreachable.h" #include "swift/Basic/Unreachable.h"
#include "swift/Demangling/Demangle.h" #include "swift/Demangling/Demangle.h"
#include "swift/Runtime/Debug.h" #include "swift/Runtime/Debug.h"
#include "swift/Runtime/Portability.h" #include "swift/Runtime/Portability.h"

View File

@@ -231,7 +231,7 @@ override_getCanonicalTypeMetadata(const ProtocolConformanceDescriptor *conf) {
} }
} }
swift_runtime_unreachable("Unhandled TypeReferenceKind in switch."); swift_unreachable("Unhandled TypeReferenceKind in switch.");
} }
class ConformanceCandidate { class ConformanceCandidate {