Skip to content

Commit fee9800

Browse files
authored
Merge pull request #15432 from dcci/rdar38720742
[TypeReconstruction] Fix reconstructions for allocator.
2 parents efa619a + 5e463b1 commit fee9800

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

lib/IDE/TypeReconstruction.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ static void VisitLocalDeclVariableName(ASTContext *ast,
12171217
name->getText());
12181218
}
12191219

1220-
// VisitNodeFunction gets used for Function, Variable and Allocator:
1220+
// VisitNodeFunction gets used for Function and Variable.
12211221
static void VisitNodeFunction(
12221222
ASTContext *ast,
12231223
Demangle::NodePointer cur_node, VisitNodeResult &result) {
@@ -1347,25 +1347,6 @@ static void VisitNodeFunction(
13471347
}
13481348
} while (0);
13491349

1350-
// if (node_kind == Demangle::Node::Kind::Allocator)
1351-
// {
1352-
// // For allocators we don't have an identifier for
1353-
// the name, we will
1354-
// // need to extract it from the class or struct in
1355-
// "identifier_result"
1356-
// //Find
1357-
// if (identifier_result.HasSingleType())
1358-
// {
1359-
// // This contains the class or struct
1360-
// StringRef init_name("init");
1361-
//
1362-
// if (FindFirstNamedDeclWithKind(ast, init_name,
1363-
// DeclKind::Constructor, identifier_result))
1364-
// {
1365-
// }
1366-
// }
1367-
// }
1368-
13691350
if (identifier_result._types.size() == 1) {
13701351
result._module = identifier_result._module;
13711352
result._decls.push_back(identifier_result._decls[0]);
@@ -2229,6 +2210,7 @@ static void VisitNode(
22292210
VisitAllChildNodes(ast, node, result);
22302211
break;
22312212

2213+
case Demangle::Node::Kind::Allocator:
22322214
case Demangle::Node::Kind::Constructor:
22332215
VisitNodeConstructor(ast, node, result);
22342216
break;
@@ -2254,7 +2236,6 @@ static void VisitNode(
22542236
break;
22552237

22562238
case Demangle::Node::Kind::Function:
2257-
case Demangle::Node::Kind::Allocator:
22582239
case Demangle::Node::Kind::Variable:
22592240
case Demangle::Node::Kind::Subscript: // Out of order on purpose
22602241
VisitNodeFunction(ast, node, result);

test/DebugInfo/DumpDeclFromMangledName.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// RUN: sed -ne '/--->/s/^.*---> *//p' < %S/Inputs/decl-reconstr-names.txt > %t.check
88

99
// RUN: %target-build-swift -emit-executable %s -g -o %t/DeclReconstr -emit-module
10-
// RUN: %lldb-moduleimport-test %t/DeclReconstr \
10+
// RUN: %lldb-moduleimport-test %t/DeclReconstr -target-triple %target-triple \
1111
// RUN: -decl-from-mangled=%t.input > %t.output 2>&1
1212
// RUN: diff %t.check %t.output
1313

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
$S12DeclReconstr8patatinoSiyF ---> func patatino() -> Int
2-
$S12DeclReconstr1SVACycfC ---> Can't resolve decl of $S12DeclReconstr1SVACycfC
2+
$S12DeclReconstr1SVACycfC ---> init()

tools/lldb-moduleimport-test/lldb-moduleimport-test.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ int main(int argc, char **argv) {
138138
llvm::cl::opt<std::string> DumpTypeFromMangled(
139139
"type-from-mangled", llvm::cl::desc("dump type from mangled names list"));
140140

141+
// FIXME: we should infer this from the module.
142+
llvm::cl::opt<std::string> TargetTriple(
143+
"target-triple", llvm::cl::desc("specify target triple"));
144+
141145
llvm::cl::ParseCommandLineOptions(argc, argv);
142146
// Unregister our options so they don't interfere with the command line
143147
// parsing in CodeGen/BackendUtil.cpp.
@@ -148,6 +152,7 @@ int main(int argc, char **argv) {
148152
DumpTypeFromMangled.removeArgument();
149153
SDK.removeArgument();
150154
InputNames.removeArgument();
155+
TargetTriple.removeArgument();
151156

152157
// If no SDK was specified via -sdk, check environment variable SDKROOT.
153158
if (SDK.getNumOccurrences() == 0) {
@@ -166,7 +171,13 @@ int main(int argc, char **argv) {
166171
reinterpret_cast<void *>(&anchorForGetMainExecutable)));
167172

168173
Invocation.setSDKPath(SDK);
169-
Invocation.setTargetTriple(llvm::sys::getDefaultTargetTriple());
174+
175+
// FIXME: we should infer this from the module.
176+
if (!TargetTriple.empty())
177+
Invocation.setTargetTriple(TargetTriple);
178+
else
179+
Invocation.setTargetTriple(llvm::sys::getDefaultTargetTriple());
180+
170181
Invocation.setModuleName("lldbtest");
171182
Invocation.getClangImporterOptions().ModuleCachePath = ModuleCachePath;
172183
Invocation.setImportSearchPaths(ImportPaths);

0 commit comments

Comments
 (0)