Files
swift-mirror/include/swift/AST/KnownDecls.def
Jordan Rose 9be6519f5a [SILGen] Show a message when an unexpected enum value is switched on (#15614)
Builds on 36eae9d4f6 to emit a message instead of just trapping
when a switch over a non-frozen enum ends up not matching anything.
If the enum is known to be an @objc enum, the message is

  unexpected enum case 'MyEnum(rawValue: -42)'

and if it's anything else (a Swift enum, a tuple containing enums,
whatever), it's a more opaque

  unexpected enum case while switching on value of type 'MyEnum'

The reason for this is to avoid calling String(describing:) or
String(reflecting:) an arbitrary value when the enum might conform to
CustomStringConvertible and therefore /itself/ have a switch that's
going to fall off the end. By handling plain @objc enums (using a
bitcast), we've at least covered the 90% case.

rdar://problem/37728359
2018-04-03 11:21:36 -07:00

82 lines
3.0 KiB
C++

//===--- KnownDecls.def - Compiler declaration metaprogramming --*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines macros used for macro-metaprogramming with compiler-known
// declarations.
//
//===----------------------------------------------------------------------===//
#ifndef FUNC_DECL
# define FUNC_DECL(Name, Id)
#endif
FUNC_DECL(ArrayForceCast, "_arrayForceCast")
FUNC_DECL(ArrayConditionalCast, "_arrayConditionalCast")
FUNC_DECL(DictionaryUpCast, "_dictionaryUpCast")
FUNC_DECL(DictionaryDownCast, "_dictionaryDownCast")
FUNC_DECL(DictionaryDownCastConditional, "_dictionaryDownCastConditional")
FUNC_DECL(SetUpCast, "_setUpCast")
FUNC_DECL(SetDownCast, "_setDownCast")
FUNC_DECL(SetDownCastConditional, "_setDownCastConditional")
FUNC_DECL(ConvertPointerToPointerArgument,
"_convertPointerToPointerArgument")
FUNC_DECL(ConvertInOutToPointerArgument,
"_convertInOutToPointerArgument")
FUNC_DECL(ConvertMutableArrayToPointerArgument,
"_convertMutableArrayToPointerArgument")
FUNC_DECL(ConvertConstArrayToPointerArgument,
"_convertConstArrayToPointerArgument")
FUNC_DECL(ConvertConstStringToUTF8PointerArgument,
"_convertConstStringToUTF8PointerArgument")
FUNC_DECL(AllocateUninitializedArray,
"_allocateUninitializedArray")
FUNC_DECL(DeallocateUninitializedArray,
"_deallocateUninitializedArray")
FUNC_DECL(ForceBridgeFromObjectiveC,
"_forceBridgeFromObjectiveC")
FUNC_DECL(ConditionallyBridgeFromObjectiveC,
"_conditionallyBridgeFromObjectiveC")
FUNC_DECL(ForceBridgeFromObjectiveCBridgeable,
"_forceBridgeFromObjectiveC_bridgeable")
FUNC_DECL(ConditionallyBridgeFromObjectiveCBridgeable,
"_conditionallyBridgeFromObjectiveC_bridgeable")
FUNC_DECL(BridgeAnythingToObjectiveC,
"_bridgeAnythingToObjectiveC")
FUNC_DECL(BridgeAnyObjectToAny,
"_bridgeAnyObjectToAny")
FUNC_DECL(ConvertToAnyHashable, "_convertToAnyHashable")
FUNC_DECL(DiagnoseUnexpectedNilOptional, "_diagnoseUnexpectedNilOptional")
FUNC_DECL(DiagnoseUnexpectedEnumCase, "_diagnoseUnexpectedEnumCase")
FUNC_DECL(DiagnoseUnexpectedEnumCaseValue, "_diagnoseUnexpectedEnumCaseValue")
FUNC_DECL(GetErrorEmbeddedNSError, "_getErrorEmbeddedNSError")
FUNC_DECL(UnsafeBitCast, "unsafeBitCast")
FUNC_DECL(ProjectKeyPathAny, "_projectKeyPathAny")
FUNC_DECL(ProjectKeyPathPartial, "_projectKeyPathPartial")
FUNC_DECL(ProjectKeyPathReadOnly, "_projectKeyPathReadOnly")
FUNC_DECL(ProjectKeyPathWritable, "_projectKeyPathWritable")
FUNC_DECL(ProjectKeyPathReferenceWritable, "_projectKeyPathReferenceWritable")
FUNC_DECL(Swap, "swap")
#undef FUNC_DECL