Skip to content

Commit 98a32d3

Browse files
committed
Don't reuse variables; Nest in scopes
(cherry picked from commit 688c2e8)
1 parent 5abbe31 commit 98a32d3

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
@@ -1674,38 +1674,35 @@ TypeSystemSwiftTypeRef::GetPointerType(opaque_compiler_type_t type) {
16741674
using namespace swift::Demangle;
16751675
Demangler dem;
16761676

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

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

0 commit comments

Comments
 (0)