Files
swift-mirror/include/swift/Demangling/DemangleNodes.def
Hamish Knight 2d7500eda6 [AST] Remove ParenType
Today ParenType is used:

1. As the type of ParenExpr
2. As the payload type of an unlabeled single
   associated value enum case (and the type of
   ParenPattern).
3. As the type for an `(X)` TypeRepr

For 1, this leads to some odd behavior, e.g the
type of `(5.0 * 5).squareRoot()` is `(Double)`. For
2, we should be checking the arity of the enum case
constructor parameters and the presence of
ParenPattern respectively. Eventually we ought to
consider replacing Paren/TuplePattern with a
PatternList node, similar to ArgumentList.

3 is one case where it could be argued that there's
some utility in preserving the sugar of the type
that the user wrote. However it's really not clear
to me that this is particularly desirable since a
bunch of diagnostic logic is already stripping
ParenTypes. In cases where we care about how the
type was written in source, we really ought to be
consulting the TypeRepr.
2024-10-31 11:32:40 +00:00

413 lines
12 KiB
C++

//===--- DemangleNodes.def - Demangling Tree 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 useful for macro-metaprogramming with nodes in
// the demangling tree.
//
//===----------------------------------------------------------------------===//
/// NODE(ID)
/// The node's enumerator value is Node::Kind::ID.
/// CONTEXT_NODE(ID)
/// Nodes that can serve as contexts for other entities.
#ifndef CONTEXT_NODE
#define CONTEXT_NODE(ID) NODE(ID)
#endif
CONTEXT_NODE(Allocator)
CONTEXT_NODE(AnonymousContext)
NODE(AnyProtocolConformanceList)
NODE(ArgumentTuple)
NODE(AssociatedType)
NODE(AssociatedTypeRef)
NODE(AssociatedTypeMetadataAccessor)
NODE(DefaultAssociatedTypeMetadataAccessor)
NODE(AccessorAttachedMacroExpansion)
NODE(AssociatedTypeWitnessTableAccessor)
NODE(BaseWitnessTableAccessor)
NODE(AutoClosureType)
NODE(BodyAttachedMacroExpansion)
NODE(BoundGenericClass)
NODE(BoundGenericEnum)
NODE(BoundGenericStructure)
NODE(BoundGenericProtocol)
NODE(BoundGenericOtherNominalType)
NODE(BoundGenericTypeAlias)
NODE(BoundGenericFunction)
NODE(BuiltinTypeName)
NODE(BuiltinTupleType)
NODE(BuiltinFixedArray)
NODE(CFunctionPointer)
NODE(ClangType)
CONTEXT_NODE(Class)
NODE(ClassMetadataBaseOffset)
NODE(ConcreteProtocolConformance)
NODE(PackProtocolConformance)
NODE(ConformanceAttachedMacroExpansion)
CONTEXT_NODE(Constructor)
NODE(CoroutineContinuationPrototype)
CONTEXT_NODE(Deallocator)
NODE(DeclContext)
CONTEXT_NODE(DefaultArgumentInitializer)
NODE(DependentAssociatedConformance)
NODE(DependentAssociatedTypeRef)
NODE(DependentGenericConformanceRequirement)
NODE(DependentGenericParamCount)
NODE(DependentGenericParamType)
NODE(DependentGenericSameTypeRequirement)
NODE(DependentGenericSameShapeRequirement)
NODE(DependentGenericLayoutRequirement)
NODE(DependentGenericParamPackMarker)
NODE(DependentGenericSignature)
NODE(DependentGenericType)
NODE(DependentMemberType)
NODE(DependentPseudogenericSignature)
NODE(DependentProtocolConformanceRoot)
NODE(DependentProtocolConformanceInherited)
NODE(DependentProtocolConformanceAssociated)
CONTEXT_NODE(Destructor)
CONTEXT_NODE(DidSet)
NODE(Directness)
NODE(DistributedThunk)
NODE(DistributedAccessor)
NODE(DynamicAttribute)
NODE(DirectMethodReferenceAttribute)
NODE(DynamicSelf)
NODE(DynamicallyReplaceableFunctionImpl)
NODE(DynamicallyReplaceableFunctionKey)
NODE(DynamicallyReplaceableFunctionVar)
CONTEXT_NODE(Enum)
NODE(EnumCase)
NODE(ErrorType)
NODE(EscapingAutoClosureType)
NODE(NoEscapeFunctionType)
NODE(ConcurrentFunctionType)
NODE(GlobalActorFunctionType)
NODE(DifferentiableFunctionType)
NODE(ExistentialMetatype)
CONTEXT_NODE(ExplicitClosure)
CONTEXT_NODE(Extension)
NODE(ExtensionAttachedMacroExpansion)
NODE(FieldOffset)
NODE(FreestandingMacroExpansion)
NODE(FullTypeMetadata)
CONTEXT_NODE(Function)
NODE(FunctionSignatureSpecialization)
NODE(FunctionSignatureSpecializationParam)
NODE(FunctionSignatureSpecializationReturn)
NODE(FunctionSignatureSpecializationParamKind)
NODE(FunctionSignatureSpecializationParamPayload)
NODE(FunctionType)
NODE(ConstrainedExistential)
NODE(ConstrainedExistentialRequirementList)
NODE(ConstrainedExistentialSelf)
NODE(GenericPartialSpecialization)
NODE(GenericPartialSpecializationNotReAbstracted)
NODE(GenericProtocolWitnessTable)
NODE(GenericProtocolWitnessTableInstantiationFunction)
NODE(ResilientProtocolWitnessTable)
NODE(GenericSpecialization)
NODE(GenericSpecializationNotReAbstracted)
NODE(GenericSpecializationInResilienceDomain)
NODE(GenericSpecializationParam)
NODE(GenericSpecializationPrespecialized)
NODE(InlinedGenericFunction)
NODE(GenericTypeMetadataPattern)
CONTEXT_NODE(Getter)
NODE(Global)
CONTEXT_NODE(GlobalGetter)
NODE(Identifier)
NODE(Index)
CONTEXT_NODE(IVarInitializer)
CONTEXT_NODE(IVarDestroyer)
NODE(ImplEscaping)
NODE(ImplConvention)
NODE(ImplDifferentiabilityKind)
NODE(ImplErasedIsolation)
NODE(ImplSendingResult)
NODE(ImplParameterResultDifferentiability)
NODE(ImplParameterSending)
NODE(ImplFunctionAttribute)
NODE(ImplFunctionConvention)
NODE(ImplFunctionConventionName)
NODE(ImplFunctionType)
NODE(ImplCoroutineKind)
NODE(ImplInvocationSubstitutions)
CONTEXT_NODE(ImplicitClosure)
NODE(ImplParameter)
NODE(ImplPatternSubstitutions)
NODE(ImplResult)
NODE(ImplYield)
NODE(ImplErrorResult)
NODE(InOut)
NODE(InfixOperator)
CONTEXT_NODE(Initializer)
CONTEXT_NODE(InitAccessor)
NODE(Isolated)
CONTEXT_NODE(IsolatedDeallocator)
NODE(Sending)
NODE(IsolatedAnyFunctionType)
NODE(SendingResultFunctionType)
NODE(KeyPathGetterThunkHelper)
NODE(KeyPathSetterThunkHelper)
NODE(KeyPathEqualsThunkHelper)
NODE(KeyPathHashThunkHelper)
NODE(LazyProtocolWitnessTableAccessor)
NODE(LazyProtocolWitnessTableCacheVariable)
NODE(LocalDeclName)
NODE(Macro)
NODE(MacroExpansionLoc)
NODE(MacroExpansionUniqueName)
CONTEXT_NODE(MaterializeForSet)
NODE(MemberAttachedMacroExpansion)
NODE(MemberAttributeAttachedMacroExpansion)
NODE(MergedFunction)
NODE(Metatype)
NODE(MetatypeRepresentation)
NODE(Metaclass)
NODE(MethodLookupFunction)
NODE(ObjCMetadataUpdateFunction)
NODE(ObjCResilientClassStub)
NODE(FullObjCResilientClassStub)
CONTEXT_NODE(ModifyAccessor)
CONTEXT_NODE(Modify2Accessor)
CONTEXT_NODE(Module)
CONTEXT_NODE(NativeOwningAddressor)
CONTEXT_NODE(NativeOwningMutableAddressor)
CONTEXT_NODE(NativePinningAddressor)
CONTEXT_NODE(NativePinningMutableAddressor)
NODE(NominalTypeDescriptor)
NODE(NominalTypeDescriptorRecord)
NODE(NonObjCAttribute)
NODE(Number)
NODE(ObjCAsyncCompletionHandlerImpl)
NODE(PredefinedObjCAsyncCompletionHandlerImpl)
NODE(ObjCAttribute)
NODE(ObjCBlock)
NODE(EscapingObjCBlock)
CONTEXT_NODE(OtherNominalType)
CONTEXT_NODE(OwningAddressor)
CONTEXT_NODE(OwningMutableAddressor)
NODE(PartialApplyForwarder)
NODE(PartialApplyObjCForwarder)
NODE(PeerAttachedMacroExpansion)
NODE(PostfixOperator)
NODE(PreambleAttachedMacroExpansion)
NODE(PrefixOperator)
NODE(PrivateDeclName)
NODE(PropertyDescriptor)
CONTEXT_NODE(PropertyWrapperBackingInitializer)
CONTEXT_NODE(PropertyWrapperInitFromProjectedValue)
CONTEXT_NODE(Protocol)
CONTEXT_NODE(ProtocolSymbolicReference)
NODE(ProtocolConformance)
NODE(ProtocolConformanceRefInTypeModule)
NODE(ProtocolConformanceRefInProtocolModule)
NODE(ProtocolConformanceRefInOtherModule)
NODE(ProtocolDescriptor)
NODE(ProtocolDescriptorRecord)
NODE(ProtocolConformanceDescriptor)
NODE(ProtocolConformanceDescriptorRecord)
NODE(ProtocolList)
NODE(ProtocolListWithClass)
NODE(ProtocolListWithAnyObject)
NODE(ProtocolSelfConformanceDescriptor)
NODE(ProtocolSelfConformanceWitness)
NODE(ProtocolSelfConformanceWitnessTable)
NODE(ProtocolWitness)
NODE(ProtocolWitnessTable)
NODE(ProtocolWitnessTableAccessor)
NODE(ProtocolWitnessTablePattern)
NODE(ReabstractionThunk)
NODE(ReabstractionThunkHelper)
NODE(ReabstractionThunkHelperWithSelf)
NODE(ReabstractionThunkHelperWithGlobalActor)
CONTEXT_NODE(ReadAccessor)
CONTEXT_NODE(Read2Accessor)
NODE(RelatedEntityDeclName)
NODE(RetroactiveConformance)
NODE(ReturnType)
NODE(Shared)
NODE(Owned)
NODE(SILBoxType)
NODE(SILBoxTypeWithLayout)
NODE(SILBoxLayout)
NODE(SILBoxMutableField)
NODE(SILBoxImmutableField)
CONTEXT_NODE(Setter)
NODE(SpecializationPassID)
NODE(IsSerialized)
CONTEXT_NODE(Static)
CONTEXT_NODE(Structure)
CONTEXT_NODE(Subscript)
NODE(Suffix)
NODE(ThinFunctionType)
NODE(Tuple)
NODE(TupleElement)
NODE(TupleElementName)
NODE(Pack)
NODE(SILPackDirect)
NODE(SILPackIndirect)
NODE(PackExpansion)
NODE(PackElement)
NODE(PackElementLevel)
NODE(Type)
CONTEXT_NODE(TypeSymbolicReference)
CONTEXT_NODE(TypeAlias)
NODE(TypeList)
NODE(TypeMangling)
NODE(TypeMetadata)
NODE(TypeMetadataAccessFunction)
NODE(TypeMetadataCompletionFunction)
NODE(TypeMetadataInstantiationCache)
NODE(TypeMetadataInstantiationFunction)
NODE(TypeMetadataSingletonInitializationCache)
NODE(TypeMetadataDemanglingCache)
NODE(TypeMetadataLazyCache)
NODE(UncurriedFunctionType)
NODE(UnknownIndex)
#define REF_STORAGE(Name, ...) NODE(Name)
#include "swift/AST/ReferenceStorage.def"
CONTEXT_NODE(UnsafeAddressor)
CONTEXT_NODE(UnsafeMutableAddressor)
NODE(ValueWitness)
NODE(ValueWitnessTable)
CONTEXT_NODE(Variable)
NODE(VTableThunk)
NODE(VTableAttribute) // note: old mangling only
CONTEXT_NODE(WillSet)
NODE(ReflectionMetadataBuiltinDescriptor)
NODE(ReflectionMetadataFieldDescriptor)
NODE(ReflectionMetadataAssocTypeDescriptor)
NODE(ReflectionMetadataSuperclassDescriptor)
NODE(GenericTypeParamDecl)
NODE(CurryThunk)
NODE(SILThunkIdentity)
NODE(SILThunkHopToMainActorIfNeeded)
NODE(DispatchThunk)
NODE(MethodDescriptor)
NODE(ProtocolRequirementsBaseDescriptor)
NODE(AssociatedConformanceDescriptor)
NODE(DefaultAssociatedConformanceAccessor)
NODE(BaseConformanceDescriptor)
NODE(AssociatedTypeDescriptor)
NODE(AsyncAnnotation)
NODE(ThrowsAnnotation)
NODE(TypedThrowsAnnotation)
NODE(EmptyList)
NODE(FirstElementMarker)
NODE(VariadicMarker)
NODE(OutlinedBridgedMethod)
NODE(OutlinedCopy)
NODE(OutlinedConsume)
NODE(OutlinedRetain)
NODE(OutlinedRelease)
NODE(OutlinedInitializeWithTake)
NODE(OutlinedInitializeWithCopy)
NODE(OutlinedAssignWithTake)
NODE(OutlinedAssignWithCopy)
NODE(OutlinedDestroy)
NODE(OutlinedVariable)
NODE(OutlinedReadOnlyObject)
NODE(AssocTypePath)
NODE(LabelList)
NODE(ModuleDescriptor)
NODE(ExtensionDescriptor)
NODE(AnonymousDescriptor)
NODE(AssociatedTypeGenericParamRef)
NODE(SugaredOptional)
NODE(SugaredArray)
NODE(SugaredDictionary)
NODE(SugaredParen) // Removed in Swift 6.TBD
// Added in Swift 5.1
NODE(AccessorFunctionReference)
NODE(OpaqueType)
NODE(OpaqueTypeDescriptorSymbolicReference)
NODE(OpaqueTypeDescriptor)
NODE(OpaqueTypeDescriptorRecord)
NODE(OpaqueTypeDescriptorAccessor)
NODE(OpaqueTypeDescriptorAccessorImpl)
NODE(OpaqueTypeDescriptorAccessorKey)
NODE(OpaqueTypeDescriptorAccessorVar)
NODE(OpaqueReturnType)
CONTEXT_NODE(OpaqueReturnTypeOf)
// Added in Swift 5.4
NODE(CanonicalSpecializedGenericMetaclass)
NODE(CanonicalSpecializedGenericTypeMetadataAccessFunction)
NODE(MetadataInstantiationCache)
NODE(NoncanonicalSpecializedGenericTypeMetadata)
NODE(NoncanonicalSpecializedGenericTypeMetadataCache)
NODE(GlobalVariableOnceFunction)
NODE(GlobalVariableOnceToken)
NODE(GlobalVariableOnceDeclList)
NODE(CanonicalPrespecializedGenericTypeCachingOnceToken)
// Added in Swift 5.5
NODE(AsyncFunctionPointer)
CONTEXT_NODE(AutoDiffFunction)
NODE(AutoDiffFunctionKind)
NODE(AutoDiffSelfReorderingReabstractionThunk)
NODE(AutoDiffSubsetParametersThunk)
NODE(AutoDiffDerivativeVTableThunk)
NODE(DifferentiabilityWitness)
NODE(NoDerivative)
NODE(IndexSubset)
NODE(AsyncAwaitResumePartialFunction)
NODE(AsyncSuspendResumePartialFunction)
// Added in Swift 5.6
NODE(AccessibleFunctionRecord)
NODE(CompileTimeConst)
// Added in Swift 5.7
NODE(BackDeploymentThunk)
NODE(BackDeploymentFallback)
NODE(ExtendedExistentialTypeShape)
NODE(Uniquable)
NODE(UniqueExtendedExistentialTypeShapeSymbolicReference)
NODE(NonUniqueExtendedExistentialTypeShapeSymbolicReference)
NODE(SymbolicExtendedExistentialType)
// Added in Swift 5.8
NODE(DroppedArgument)
NODE(HasSymbolQuery)
NODE(OpaqueReturnTypeIndex)
NODE(OpaqueReturnTypeParent)
// Addedn in Swift 6.0
NODE(OutlinedEnumTagStore)
NODE(OutlinedEnumProjectDataForLoad)
NODE(OutlinedEnumGetTag)
// Added in Swift 5.9 + 1
NODE(AsyncRemoved)
// Added in Swift 5.TBD
NODE(ObjectiveCProtocolSymbolicReference)
NODE(OutlinedInitializeWithCopyNoValueWitness)
NODE(OutlinedAssignWithTakeNoValueWitness)
NODE(OutlinedAssignWithCopyNoValueWitness)
NODE(OutlinedDestroyNoValueWitness)
NODE(DependentGenericInverseConformanceRequirement)
// Added in Swift 6.TBD
NODE(Integer)
NODE(NegativeInteger)
NODE(DependentGenericParamValueMarker)
#undef CONTEXT_NODE
#undef NODE