[lldb-moduleimport] Add the logic for testing getDeclBySymbolName().

Adrian already found and reported a bug, which I'm going to fix
in a later commit. Eventually this will go away, but in the meanwhile,
we should add test for this codepath.

<rdar://problem/38720742>
This commit is contained in:
Davide Italiano
2018-03-22 10:47:24 -07:00
parent 8cd5e8026b
commit 9dbd966e73
3 changed files with 51 additions and 1 deletions

View File

@@ -62,6 +62,21 @@ static void printValidationInfo(llvm::StringRef data) {
}
}
static void resolveDeclFromMangledNameList(
swift::ASTContext &Ctx, llvm::ArrayRef<std::string> MangledNames) {
std::string Error;
for (auto &Mangled : MangledNames) {
swift::Decl *ResolvedDecl =
swift::ide::getDeclFromMangledSymbolName(Ctx, Mangled, Error);
if (!ResolvedDecl) {
llvm::errs() << "Can't resolve decl of " << Mangled << "\n";
} else {
ResolvedDecl->print(llvm::errs());
llvm::errs() << "\n";
}
}
}
static void resolveTypeFromMangledNameList(
swift::ASTContext &Ctx, llvm::ArrayRef<std::string> MangledNames) {
std::string Error;
@@ -117,8 +132,11 @@ int main(int argc, char **argv) {
llvm::cl::list<std::string> FrameworkPaths(
"F", llvm::cl::desc("add a directory to the framework search path"));
llvm::cl::opt<std::string> DumpDeclFromMangled(
"decl-from-mangled", llvm::cl::desc("dump decl from mangled names list"));
llvm::cl::opt<std::string> DumpTypeFromMangled(
"type-from-mangled", llvm::cl::desc("dump type from mangled name"));
"type-from-mangled", llvm::cl::desc("dump type from mangled names list"));
llvm::cl::ParseCommandLineOptions(argc, argv);
// Unregister our options so they don't interfere with the command line
@@ -269,6 +287,11 @@ int main(int argc, char **argv) {
collectMangledNames(DumpTypeFromMangled, MangledNames);
resolveTypeFromMangledNameList(CI.getASTContext(), MangledNames);
}
if (!DumpDeclFromMangled.empty()) {
llvm::SmallVector<std::string, 8> MangledNames;
collectMangledNames(DumpDeclFromMangled, MangledNames);
resolveDeclFromMangledNameList(CI.getASTContext(), MangledNames);
}
}
return 0;
}