[Serialization] Apple platforms have default framework search paths. (#8331)

Follow Clang's lead in defining /System/Library/Frameworks and
/Library/Frameworks as default framework search paths. I'm doing this
manually rather than adding them to the actual list of search paths
because Clang will /also/ do this by default, and I don't want to
needlessly duplicate that work.

rdar://problem/31126655
This commit is contained in:
Jordan Rose
2017-03-28 10:41:12 -07:00
committed by GitHub
parent bb674fe75a
commit 8baab7b9d1
2 changed files with 47 additions and 3 deletions

View File

@@ -131,15 +131,33 @@ findModule(ASTContext &ctx, AccessPathElem moduleID,
moduleFramework += ".framework";
isFramework = true;
for (const auto &framepath : ctx.SearchPathOpts.FrameworkSearchPaths) {
currPath = framepath.Path;
auto tryFrameworkImport = [&](StringRef frameworkPath) -> bool {
currPath = frameworkPath;
llvm::sys::path::append(currPath, moduleFramework.str(),
"Modules", moduleFilename.str());
auto err = openModuleFiles(currPath,
archFile.str(), archDocFile.str(),
moduleBuffer, moduleDocBuffer,
scratch);
if (!err)
return !err;
};
for (const auto &framepath : ctx.SearchPathOpts.FrameworkSearchPaths) {
if (tryFrameworkImport(framepath.Path))
return true;
}
if (ctx.LangOpts.Target.isOSDarwin()) {
// Apple platforms have extra implicit framework search paths:
// $SDKROOT/System/Library/Frameworks/ and $SDKROOT/Library/Frameworks/
scratch = ctx.SearchPathOpts.SDKPath;
llvm::sys::path::append(scratch, "System", "Library", "Frameworks");
if (tryFrameworkImport(scratch))
return true;
scratch = ctx.SearchPathOpts.SDKPath;
llvm::sys::path::append(scratch, "Library", "Frameworks");
if (tryFrameworkImport(scratch))
return true;
}
}