Skip to content

Commit ff26c89

Browse files
authored
Merge pull request swiftlang#15689 from dcci/moduleimport-rightinfo
2 parents eb03f37 + eeac130 commit ff26c89

File tree

2 files changed

+15
-43
lines changed

2 files changed

+15
-43
lines changed

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 -target-triple %target-triple \
10+
// RUN: %lldb-moduleimport-test %t/DeclReconstr \
1111
// RUN: -decl-from-mangled=%t.input > %t.output 2>&1
1212
// RUN: diff %t.check %t.output
1313

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

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ void anchorForGetMainExecutable() {}
4242

4343
using namespace llvm::MachO;
4444

45-
static bool validateModule(llvm::StringRef data, bool Verbose) {
46-
swift::serialization::ExtendedValidationInfo extendedInfo;
47-
swift::serialization::ValidationInfo info =
48-
swift::serialization::validateSerializedAST(data, &extendedInfo);
45+
static bool validateModule(llvm::StringRef data, bool Verbose,
46+
swift::serialization::ValidationInfo &info,
47+
swift::serialization::ExtendedValidationInfo &extendedInfo) {
48+
info = swift::serialization::validateSerializedAST(data, &extendedInfo);
4949
if (info.status != swift::serialization::Status::Valid)
5050
return false;
5151

@@ -175,9 +175,6 @@ int main(int argc, char **argv) {
175175
llvm::cl::Positional, llvm::cl::desc("compiled_swift_file1.o ..."),
176176
llvm::cl::OneOrMore);
177177

178-
llvm::cl::opt<std::string> SDK(
179-
"sdk", llvm::cl::desc("path to the SDK to build against"));
180-
181178
llvm::cl::opt<bool> DumpModule(
182179
"dump-module", llvm::cl::desc(
183180
"Dump the imported module after checking it imports just fine"));
@@ -188,54 +185,39 @@ int main(int argc, char **argv) {
188185
llvm::cl::opt<std::string> ModuleCachePath(
189186
"module-cache-path", llvm::cl::desc("Clang module cache path"));
190187

191-
llvm::cl::list<std::string> ImportPaths(
192-
"I", llvm::cl::desc("add a directory to the import search path"));
193-
194-
llvm::cl::list<std::string> FrameworkPaths(
195-
"F", llvm::cl::desc("add a directory to the framework search path"));
196-
197188
llvm::cl::opt<std::string> DumpDeclFromMangled(
198189
"decl-from-mangled", llvm::cl::desc("dump decl from mangled names list"));
199190

200191
llvm::cl::opt<std::string> DumpTypeFromMangled(
201192
"type-from-mangled", llvm::cl::desc("dump type from mangled names list"));
202193

203-
// FIXME: we should infer this from the module.
204-
llvm::cl::opt<std::string> TargetTriple(
205-
"target-triple", llvm::cl::desc("specify target triple"));
206-
207194
llvm::cl::ParseCommandLineOptions(argc, argv);
208195
// Unregister our options so they don't interfere with the command line
209196
// parsing in CodeGen/BackendUtil.cpp.
210-
FrameworkPaths.removeArgument();
211-
ImportPaths.removeArgument();
212197
ModuleCachePath.removeArgument();
213198
DumpModule.removeArgument();
214199
DumpTypeFromMangled.removeArgument();
215-
SDK.removeArgument();
216200
InputNames.removeArgument();
217-
TargetTriple.removeArgument();
218201

219202
// Fetch the serialized module bitstreams from the Mach-O files and
220203
// register them with the module loader.
221204
llvm::SmallVector<std::pair<char *, uint64_t>, 8> Modules;
222205
if (!collectASTModules(InputNames, Modules))
223206
return 1;
224207

208+
if (Modules.empty())
209+
return 0;
210+
211+
swift::serialization::ValidationInfo info;
212+
swift::serialization::ExtendedValidationInfo extendedInfo;
225213
for (auto &Module : Modules) {
226-
if (!validateModule(StringRef(Module.first, Module.second), Verbose)) {
214+
if (!validateModule(StringRef(Module.first, Module.second), Verbose, info,
215+
extendedInfo)) {
227216
llvm::errs() << "Malformed module!\n";
228217
return 1;
229218
}
230219
}
231220

232-
// If no SDK was specified via -sdk, check environment variable SDKROOT.
233-
if (SDK.getNumOccurrences() == 0) {
234-
const char *SDKROOT = getenv("SDKROOT");
235-
if (SDKROOT)
236-
SDK = SDKROOT;
237-
}
238-
239221
// Create a Swift compiler.
240222
llvm::SmallVector<std::string, 4> modules;
241223
swift::CompilerInstance CI;
@@ -245,22 +227,12 @@ int main(int argc, char **argv) {
245227
llvm::sys::fs::getMainExecutable(argv[0],
246228
reinterpret_cast<void *>(&anchorForGetMainExecutable)));
247229

248-
Invocation.setSDKPath(SDK);
249-
250-
// FIXME: we should infer this from the module.
251-
if (!TargetTriple.empty())
252-
Invocation.setTargetTriple(TargetTriple);
253-
else
254-
Invocation.setTargetTriple(llvm::sys::getDefaultTargetTriple());
230+
// Infer SDK and Target triple from the module.
231+
Invocation.setSDKPath(extendedInfo.getSDKPath());
232+
Invocation.setTargetTriple(info.targetTriple);
255233

256234
Invocation.setModuleName("lldbtest");
257235
Invocation.getClangImporterOptions().ModuleCachePath = ModuleCachePath;
258-
Invocation.setImportSearchPaths(ImportPaths);
259-
std::vector<swift::SearchPathOptions::FrameworkSearchPath> FramePaths;
260-
for (const auto &path : FrameworkPaths) {
261-
FramePaths.push_back({path, /*isSystem=*/false});
262-
}
263-
Invocation.setFrameworkSearchPaths(FramePaths);
264236

265237
if (CI.setup(Invocation))
266238
return 1;

0 commit comments

Comments
 (0)