mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Expose Swift search paths in validateSerializedAST
This is for the benefit of LLDB, which currently does an expensive import of all modules to get to the same information. rdar://40097459
This commit is contained in:
@@ -44,14 +44,15 @@ void anchorForGetMainExecutable() {}
|
||||
|
||||
using namespace llvm::MachO;
|
||||
|
||||
static bool
|
||||
validateModule(llvm::StringRef data, bool Verbose, bool requiresOSSAModules,
|
||||
swift::serialization::ValidationInfo &info,
|
||||
swift::serialization::ExtendedValidationInfo &extendedInfo) {
|
||||
static bool validateModule(
|
||||
llvm::StringRef data, bool Verbose, bool requiresOSSAModules,
|
||||
swift::serialization::ValidationInfo &info,
|
||||
swift::serialization::ExtendedValidationInfo &extendedInfo,
|
||||
llvm::SmallVectorImpl<swift::serialization::SearchPath> &searchPaths) {
|
||||
info = swift::serialization::validateSerializedAST(
|
||||
data, requiresOSSAModules,
|
||||
/*requiredSDK*/ StringRef(), /*requiresRevisionMatch*/ false,
|
||||
&extendedInfo);
|
||||
&extendedInfo, /* dependencies*/ nullptr, &searchPaths);
|
||||
if (info.status != swift::serialization::Status::Valid) {
|
||||
llvm::outs() << "error: validateSerializedAST() failed\n";
|
||||
return false;
|
||||
@@ -79,6 +80,14 @@ validateModule(llvm::StringRef data, bool Verbose, bool requiresOSSAModules,
|
||||
llvm::outs() << " " << option;
|
||||
llvm::outs() << "\n";
|
||||
}
|
||||
llvm::outs() << "- Search Paths:\n";
|
||||
for (auto searchPath : searchPaths) {
|
||||
llvm::outs() << " Path: " << searchPath.Path;
|
||||
llvm::outs() << ", framework="
|
||||
<< (searchPath.IsFramework ? "true" : "false");
|
||||
llvm::outs() << ", system=" << (searchPath.IsSystem ? "true" : "false")
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -285,11 +294,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
swift::serialization::ValidationInfo info;
|
||||
swift::serialization::ExtendedValidationInfo extendedInfo;
|
||||
llvm::SmallVector<swift::serialization::SearchPath> searchPaths;
|
||||
for (auto &Module : Modules) {
|
||||
info = {};
|
||||
extendedInfo = {};
|
||||
if (!validateModule(StringRef(Module.first, Module.second), Verbose,
|
||||
EnableOSSAModules, info, extendedInfo)) {
|
||||
EnableOSSAModules, info, extendedInfo, searchPaths)) {
|
||||
llvm::errs() << "Malformed module!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user