Skip to content

Commit f450d09

Browse files
committed
Unindent cases to match LLVM style.
1 parent 83ed4bc commit f450d09

File tree

1 file changed

+150
-150
lines changed

1 file changed

+150
-150
lines changed

include/swift/Remote/MetadataReader.h

Lines changed: 150 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -59,169 +59,169 @@ class TypeDecoder {
5959

6060
using NodeKind = Demangle::Node::Kind;
6161
switch (Node->getKind()) {
62-
case NodeKind::Global:
63-
return decodeMangledType(Node->getChild(0));
64-
case NodeKind::TypeMangling:
65-
return decodeMangledType(Node->getChild(0));
66-
case NodeKind::Type:
67-
return decodeMangledType(Node->getChild(0));
68-
case NodeKind::Class:
69-
case NodeKind::Enum:
70-
case NodeKind::Structure: {
71-
BuiltNominalTypeDecl typeDecl = BuiltNominalTypeDecl();
72-
BuiltType parent = BuiltType();
73-
if (!decodeMangledNominalType(Node, typeDecl, parent))
74-
return BuiltType();
75-
76-
return Builder.createNominalType(typeDecl, parent);
77-
}
78-
case NodeKind::BoundGenericClass:
79-
case NodeKind::BoundGenericEnum:
80-
case NodeKind::BoundGenericStructure: {
81-
assert(Node->getNumChildren() == 2);
82-
BuiltNominalTypeDecl typeDecl = BuiltNominalTypeDecl();
83-
BuiltType parent = BuiltType();
84-
if (!decodeMangledNominalType(Node->getChild(0), typeDecl, parent))
85-
return BuiltType();
62+
case NodeKind::Global:
63+
return decodeMangledType(Node->getChild(0));
64+
case NodeKind::TypeMangling:
65+
return decodeMangledType(Node->getChild(0));
66+
case NodeKind::Type:
67+
return decodeMangledType(Node->getChild(0));
68+
case NodeKind::Class:
69+
case NodeKind::Enum:
70+
case NodeKind::Structure: {
71+
BuiltNominalTypeDecl typeDecl = BuiltNominalTypeDecl();
72+
BuiltType parent = BuiltType();
73+
if (!decodeMangledNominalType(Node, typeDecl, parent))
74+
return BuiltType();
8675

87-
std::vector<BuiltType> args;
76+
return Builder.createNominalType(typeDecl, parent);
77+
}
78+
case NodeKind::BoundGenericClass:
79+
case NodeKind::BoundGenericEnum:
80+
case NodeKind::BoundGenericStructure: {
81+
assert(Node->getNumChildren() == 2);
82+
BuiltNominalTypeDecl typeDecl = BuiltNominalTypeDecl();
83+
BuiltType parent = BuiltType();
84+
if (!decodeMangledNominalType(Node->getChild(0), typeDecl, parent))
85+
return BuiltType();
8886

89-
const auto &genericArgs = Node->getChild(1);
90-
assert(genericArgs->getKind() == NodeKind::TypeList);
87+
std::vector<BuiltType> args;
9188

92-
for (auto genericArg : *genericArgs) {
93-
auto paramType = decodeMangledType(genericArg);
94-
if (!paramType)
95-
return BuiltType();
96-
args.push_back(paramType);
97-
}
89+
const auto &genericArgs = Node->getChild(1);
90+
assert(genericArgs->getKind() == NodeKind::TypeList);
9891

99-
return Builder.createBoundGenericType(typeDecl, args, parent);
100-
}
101-
case NodeKind::BuiltinTypeName: {
102-
auto mangledName = Demangle::mangleNode(Node);
103-
return Builder.createBuiltinType(mangledName);
104-
}
105-
case NodeKind::ExistentialMetatype: {
106-
auto instance = decodeMangledType(Node->getChild(0));
107-
if (!instance)
108-
return BuiltType();
109-
return Builder.createExistentialMetatypeType(instance);
110-
}
111-
case NodeKind::Metatype: {
112-
auto instance = decodeMangledType(Node->getChild(0));
113-
if (!instance)
92+
for (auto genericArg : *genericArgs) {
93+
auto paramType = decodeMangledType(genericArg);
94+
if (!paramType)
11495
return BuiltType();
115-
return Builder.createMetatypeType(instance);
116-
}
117-
case NodeKind::ProtocolList: {
118-
std::vector<BuiltType> protocols;
119-
auto TypeList = Node->getChild(0);
120-
for (auto componentType : *TypeList) {
121-
if (auto protocol = decodeMangledType(componentType))
122-
protocols.push_back(protocol);
123-
else
124-
return BuiltType();
125-
}
126-
if (protocols.size() == 1)
127-
return protocols.front();
128-
else
129-
return Builder.createProtocolCompositionType(protocols);
130-
}
131-
case NodeKind::Protocol: {
132-
auto moduleName = Node->getChild(0)->getText();
133-
auto name = Node->getChild(1)->getText();
134-
return Builder.createProtocolType(moduleName, name);
96+
args.push_back(paramType);
13597
}
136-
case NodeKind::DependentGenericParamType: {
137-
auto depth = Node->getChild(0)->getIndex();
138-
auto index = Node->getChild(1)->getIndex();
139-
return Builder.createGenericTypeParameterType(depth, index);
140-
}
141-
case NodeKind::ObjCBlock:
142-
case NodeKind::CFunctionPointer:
143-
case NodeKind::ThinFunctionType:
144-
case NodeKind::FunctionType: {
145-
FunctionTypeFlags flags;
146-
if (Node->getKind() == NodeKind::ObjCBlock) {
147-
flags = flags.withConvention(FunctionMetadataConvention::Block);
148-
} else if (Node->getKind() == NodeKind::CFunctionPointer) {
149-
flags =
150-
flags.withConvention(FunctionMetadataConvention::CFunctionPointer);
151-
} else if (Node->getKind() == NodeKind::ThinFunctionType) {
152-
flags = flags.withConvention(FunctionMetadataConvention::Thin);
153-
}
154-
155-
bool isThrow =
156-
Node->getChild(0)->getKind() == NodeKind::ThrowsAnnotation;
157-
flags = flags.withThrows(true);
158-
159-
std::vector<BuiltType> arguments;
160-
std::vector<bool> argsAreInOut;
161-
if (!decodeMangledFunctionInputType(Node->getChild(isThrow ? 1 : 0),
162-
arguments, argsAreInOut, flags))
163-
return BuiltType();
16498

165-
auto result = decodeMangledType(Node->getChild(isThrow ? 2 : 1));
166-
if (!result) return BuiltType();
167-
return Builder.createFunctionType(arguments, argsAreInOut,
168-
result, flags);
169-
}
170-
case NodeKind::ArgumentTuple:
171-
return decodeMangledType(Node->getChild(0));
172-
case NodeKind::ReturnType:
173-
return decodeMangledType(Node->getChild(0));
174-
case NodeKind::NonVariadicTuple:
175-
case NodeKind::VariadicTuple: {
176-
std::vector<BuiltType> Elements;
177-
for (auto element : *Node) {
178-
auto elementType = decodeMangledType(element);
179-
if (!elementType)
180-
return BuiltType();
181-
Elements.push_back(elementType);
182-
}
183-
bool Variadic = (Node->getKind() == NodeKind::VariadicTuple);
184-
return Builder.createTupleType(Elements, Variadic);
185-
}
186-
case NodeKind::TupleElement:
187-
if (Node->getChild(0)->getKind() == NodeKind::TupleElementName)
188-
return decodeMangledType(Node->getChild(1));
189-
return decodeMangledType(Node->getChild(0));
190-
case NodeKind::DependentGenericType: {
191-
return decodeMangledType(Node->getChild(1));
192-
}
193-
case NodeKind::DependentMemberType: {
194-
auto base = decodeMangledType(Node->getChild(0));
195-
if (!base)
196-
return BuiltType();
197-
auto member = Node->getChild(1)->getText();
198-
auto protocol = decodeMangledType(Node->getChild(1));
199-
if (!protocol)
200-
return BuiltType();
201-
return Builder.createDependentMemberType(member, base, protocol);
202-
}
203-
case NodeKind::DependentAssociatedTypeRef:
204-
return decodeMangledType(Node->getChild(0));
205-
case NodeKind::Unowned: {
206-
auto base = decodeMangledType(Node->getChild(0));
207-
if (!base)
99+
return Builder.createBoundGenericType(typeDecl, args, parent);
100+
}
101+
case NodeKind::BuiltinTypeName: {
102+
auto mangledName = Demangle::mangleNode(Node);
103+
return Builder.createBuiltinType(mangledName);
104+
}
105+
case NodeKind::ExistentialMetatype: {
106+
auto instance = decodeMangledType(Node->getChild(0));
107+
if (!instance)
108+
return BuiltType();
109+
return Builder.createExistentialMetatypeType(instance);
110+
}
111+
case NodeKind::Metatype: {
112+
auto instance = decodeMangledType(Node->getChild(0));
113+
if (!instance)
114+
return BuiltType();
115+
return Builder.createMetatypeType(instance);
116+
}
117+
case NodeKind::ProtocolList: {
118+
std::vector<BuiltType> protocols;
119+
auto TypeList = Node->getChild(0);
120+
for (auto componentType : *TypeList) {
121+
if (auto protocol = decodeMangledType(componentType))
122+
protocols.push_back(protocol);
123+
else
208124
return BuiltType();
209-
return Builder.createUnownedStorageType(base);
210125
}
211-
case NodeKind::Unmanaged: {
212-
auto base = decodeMangledType(Node->getChild(0));
213-
if (!base)
214-
return BuiltType();
215-
return Builder.createUnmanagedStorageType(base);
126+
if (protocols.size() == 1)
127+
return protocols.front();
128+
else
129+
return Builder.createProtocolCompositionType(protocols);
130+
}
131+
case NodeKind::Protocol: {
132+
auto moduleName = Node->getChild(0)->getText();
133+
auto name = Node->getChild(1)->getText();
134+
return Builder.createProtocolType(moduleName, name);
135+
}
136+
case NodeKind::DependentGenericParamType: {
137+
auto depth = Node->getChild(0)->getIndex();
138+
auto index = Node->getChild(1)->getIndex();
139+
return Builder.createGenericTypeParameterType(depth, index);
140+
}
141+
case NodeKind::ObjCBlock:
142+
case NodeKind::CFunctionPointer:
143+
case NodeKind::ThinFunctionType:
144+
case NodeKind::FunctionType: {
145+
FunctionTypeFlags flags;
146+
if (Node->getKind() == NodeKind::ObjCBlock) {
147+
flags = flags.withConvention(FunctionMetadataConvention::Block);
148+
} else if (Node->getKind() == NodeKind::CFunctionPointer) {
149+
flags =
150+
flags.withConvention(FunctionMetadataConvention::CFunctionPointer);
151+
} else if (Node->getKind() == NodeKind::ThinFunctionType) {
152+
flags = flags.withConvention(FunctionMetadataConvention::Thin);
216153
}
217-
case NodeKind::Weak: {
218-
auto base = decodeMangledType(Node->getChild(0));
219-
if (!base)
154+
155+
bool isThrow =
156+
Node->getChild(0)->getKind() == NodeKind::ThrowsAnnotation;
157+
flags = flags.withThrows(true);
158+
159+
std::vector<BuiltType> arguments;
160+
std::vector<bool> argsAreInOut;
161+
if (!decodeMangledFunctionInputType(Node->getChild(isThrow ? 1 : 0),
162+
arguments, argsAreInOut, flags))
163+
return BuiltType();
164+
165+
auto result = decodeMangledType(Node->getChild(isThrow ? 2 : 1));
166+
if (!result) return BuiltType();
167+
return Builder.createFunctionType(arguments, argsAreInOut,
168+
result, flags);
169+
}
170+
case NodeKind::ArgumentTuple:
171+
return decodeMangledType(Node->getChild(0));
172+
case NodeKind::ReturnType:
173+
return decodeMangledType(Node->getChild(0));
174+
case NodeKind::NonVariadicTuple:
175+
case NodeKind::VariadicTuple: {
176+
std::vector<BuiltType> Elements;
177+
for (auto element : *Node) {
178+
auto elementType = decodeMangledType(element);
179+
if (!elementType)
220180
return BuiltType();
221-
return Builder.createWeakStorageType(base);
181+
Elements.push_back(elementType);
222182
}
223-
default:
183+
bool Variadic = (Node->getKind() == NodeKind::VariadicTuple);
184+
return Builder.createTupleType(Elements, Variadic);
185+
}
186+
case NodeKind::TupleElement:
187+
if (Node->getChild(0)->getKind() == NodeKind::TupleElementName)
188+
return decodeMangledType(Node->getChild(1));
189+
return decodeMangledType(Node->getChild(0));
190+
case NodeKind::DependentGenericType: {
191+
return decodeMangledType(Node->getChild(1));
192+
}
193+
case NodeKind::DependentMemberType: {
194+
auto base = decodeMangledType(Node->getChild(0));
195+
if (!base)
196+
return BuiltType();
197+
auto member = Node->getChild(1)->getText();
198+
auto protocol = decodeMangledType(Node->getChild(1));
199+
if (!protocol)
224200
return BuiltType();
201+
return Builder.createDependentMemberType(member, base, protocol);
202+
}
203+
case NodeKind::DependentAssociatedTypeRef:
204+
return decodeMangledType(Node->getChild(0));
205+
case NodeKind::Unowned: {
206+
auto base = decodeMangledType(Node->getChild(0));
207+
if (!base)
208+
return BuiltType();
209+
return Builder.createUnownedStorageType(base);
210+
}
211+
case NodeKind::Unmanaged: {
212+
auto base = decodeMangledType(Node->getChild(0));
213+
if (!base)
214+
return BuiltType();
215+
return Builder.createUnmanagedStorageType(base);
216+
}
217+
case NodeKind::Weak: {
218+
auto base = decodeMangledType(Node->getChild(0));
219+
if (!base)
220+
return BuiltType();
221+
return Builder.createWeakStorageType(base);
222+
}
223+
default:
224+
return BuiltType();
225225
}
226226
}
227227

0 commit comments

Comments
 (0)