@@ -254,7 +254,7 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
254254 SearchPathOpts.RuntimeLibraryPaths .push_back (DARWIN_OS_LIBRARY_PATH);
255255
256256 // If this is set, we don't want any runtime import paths.
257- if (SearchPathOpts.SkipRuntimeLibraryImportPaths ) {
257+ if (SearchPathOpts.SkipAllImplicitImportPaths ) {
258258 SearchPathOpts.setRuntimeLibraryImportPaths ({});
259259 return ;
260260 }
@@ -270,7 +270,7 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
270270 RuntimeLibraryImportPaths.push_back (std::string (LibPath.str ()));
271271 }
272272
273- if (!SearchPathOpts.ExcludeSDKPathsFromRuntimeLibraryImportPaths && !SearchPathOpts.getSDKPath ().empty ()) {
273+ if (!SearchPathOpts.SkipSDKImportPaths && !SearchPathOpts.getSDKPath ().empty ()) {
274274 const char *swiftDir = FrontendOpts.UseSharedResourceFolder
275275 ? " swift" : " swift_static" ;
276276
@@ -300,6 +300,35 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
300300 SearchPathOpts.setRuntimeLibraryImportPaths (RuntimeLibraryImportPaths);
301301}
302302
303+ static void
304+ updateImplicitFrameworkSearchPaths (SearchPathOptions &SearchPathOpts,
305+ const LangOptions &LangOpts) {
306+ if (SearchPathOpts.SkipAllImplicitImportPaths ) {
307+ SearchPathOpts.setImplicitFrameworkSearchPaths ({});
308+ return ;
309+ }
310+
311+ std::vector<std::string> ImplicitFrameworkSearchPaths;
312+ if (LangOpts.Target .isOSDarwin ()) {
313+ if (!SearchPathOpts.SkipSDKImportPaths &&
314+ !SearchPathOpts.getSDKPath ().empty ()) {
315+ StringRef SDKPath = SearchPathOpts.getSDKPath ();
316+ SmallString<128 > systemFrameworksScratch (SDKPath);
317+ llvm::sys::path::append (systemFrameworksScratch, " System" , " Library" ,
318+ " Frameworks" );
319+ SmallString<128 > systemSubFrameworksScratch (SDKPath);
320+ llvm::sys::path::append (systemSubFrameworksScratch, " System" , " Library" ,
321+ " SubFrameworks" );
322+ SmallString<128 > frameworksScratch (SDKPath);
323+ llvm::sys::path::append (frameworksScratch, " Library" , " Frameworks" );
324+ ImplicitFrameworkSearchPaths = {systemFrameworksScratch.str ().str (),
325+ systemSubFrameworksScratch.str ().str (),
326+ frameworksScratch.str ().str ()};
327+ }
328+ }
329+ SearchPathOpts.setImplicitFrameworkSearchPaths (ImplicitFrameworkSearchPaths);
330+ }
331+
303332static void
304333setIRGenOutputOptsFromFrontendOptions (IRGenOptions &IRGenOpts,
305334 const FrontendOptions &FrontendOpts) {
@@ -411,11 +440,13 @@ void CompilerInvocation::setTargetTriple(StringRef Triple) {
411440void CompilerInvocation::setTargetTriple (const llvm::Triple &Triple) {
412441 LangOpts.setTarget (Triple);
413442 updateRuntimeLibraryPaths (SearchPathOpts, FrontendOpts, LangOpts);
443+ updateImplicitFrameworkSearchPaths (SearchPathOpts, LangOpts);
414444}
415445
416446void CompilerInvocation::setSDKPath (const std::string &Path) {
417447 SearchPathOpts.setSDKPath (Path);
418448 updateRuntimeLibraryPaths (SearchPathOpts, FrontendOpts, LangOpts);
449+ updateImplicitFrameworkSearchPaths (SearchPathOpts, LangOpts);
419450}
420451
421452bool CompilerInvocation::setModuleAliasMap (std::vector<std::string> args,
@@ -2387,8 +2418,8 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
23872418 if (const Arg *A = Args.getLastArg (OPT_resource_dir))
23882419 Opts.RuntimeResourcePath = A->getValue ();
23892420
2390- Opts.SkipRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdimport);
2391- Opts.ExcludeSDKPathsFromRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdlibimport);
2421+ Opts.SkipAllImplicitImportPaths |= Args.hasArg (OPT_nostdimport);
2422+ Opts.SkipSDKImportPaths |= Args.hasArg (OPT_nostdlibimport);
23922423
23932424 Opts.DisableModulesValidateSystemDependencies |=
23942425 Args.hasArg (OPT_disable_modules_validate_system_headers);
@@ -4056,6 +4087,7 @@ bool CompilerInvocation::parseArgs(
40564087 }
40574088
40584089 updateRuntimeLibraryPaths (SearchPathOpts, FrontendOpts, LangOpts);
4090+ updateImplicitFrameworkSearchPaths (SearchPathOpts, LangOpts);
40594091 setDefaultPrebuiltCacheIfNecessary ();
40604092 setDefaultBlocklistsIfNecessary ();
40614093 setDefaultInProcessPluginServerPathIfNecessary ();
0 commit comments