Skip to content

Commit 688c2e8

Browse files
committed
Don't reuse variables; Nest in scopes
1 parent 8f837b6 commit 688c2e8

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,38 +1675,35 @@ TypeSystemSwiftTypeRef::GetPointerType(opaque_compiler_type_t type) {
16751675
using namespace swift::Demangle;
16761676
Demangler dem;
16771677

1678+
// The type that will be wrapped in UnsafePointer.
16781679
auto *pointee_type = GetDemangledType(dem, AsMangledName(type));
1679-
1680+
// The UnsafePointer type.
16801681
auto *pointer_type = dem.createNode(Node::Kind::Type);
1681-
auto *BGS = dem.createNode(Node::Kind::BoundGenericStructure);
1682-
pointer_type->addChild(BGS, dem);
1683-
1684-
NodePointer parent;
1685-
NodePointer child;
1686-
1687-
// Construct the first (Type) branch of BoundGenericStructure.
1688-
parent = BGS;
1689-
child = dem.createNode(Node::Kind::Type);
1690-
parent->addChild(child, dem);
1691-
parent = child;
1692-
child = dem.createNode(Node::Kind::Structure);
1693-
parent->addChild(child, dem);
1694-
parent = child;
1695-
parent->addChild(
1696-
dem.createNodeWithAllocatedText(Node::Kind::Module, swift::STDLIB_NAME),
1697-
dem);
1698-
parent->addChild(dem.createNode(Node::Kind::Identifier, "UnsafePointer"),
1699-
dem);
1700-
1701-
// Construct the second (TypeList) branch of BoundGenericStructure.
1702-
parent = BGS;
1703-
child = dem.createNode(Node::Kind::TypeList);
1704-
parent->addChild(child, dem);
1705-
parent = child;
1706-
child = dem.createNode(Node::Kind::Type);
1707-
parent->addChild(child, dem);
1708-
parent = child;
1709-
parent->addChild(pointee_type, dem);
1682+
1683+
auto *bgs = dem.createNode(Node::Kind::BoundGenericStructure);
1684+
pointer_type->addChild(bgs, dem);
1685+
1686+
// Construct the first branch of BoundGenericStructure.
1687+
{
1688+
auto *type = dem.createNode(Node::Kind::Type);
1689+
bgs->addChild(type, dem);
1690+
auto *structure = dem.createNode(Node::Kind::Structure);
1691+
type->addChild(structure, dem);
1692+
structure->addChild(dem.createNodeWithAllocatedText(Node::Kind::Module,
1693+
swift::STDLIB_NAME),
1694+
dem);
1695+
structure->addChild(
1696+
dem.createNode(Node::Kind::Identifier, "UnsafePointer"), dem);
1697+
}
1698+
1699+
// Construct the second branch of BoundGenericStructure.
1700+
{
1701+
auto *typelist = dem.createNode(Node::Kind::TypeList);
1702+
bgs->addChild(typelist, dem);
1703+
auto *type = dem.createNode(Node::Kind::Type);
1704+
typelist->addChild(type, dem);
1705+
type->addChild(pointee_type, dem);
1706+
}
17101707

17111708
return RemangleAsType(dem, pointer_type);
17121709
};

0 commit comments

Comments
 (0)