@@ -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+ SmallString<128 > 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,
@@ -2381,8 +2412,8 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args,
23812412 if (const Arg *A = Args.getLastArg (OPT_resource_dir))
23822413 Opts.RuntimeResourcePath = A->getValue ();
23832414
2384- Opts.SkipRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdimport);
2385- Opts.ExcludeSDKPathsFromRuntimeLibraryImportPaths |= Args.hasArg (OPT_nostdlibimport);
2415+ Opts.SkipAllImplicitImportPaths |= Args.hasArg (OPT_nostdimport);
2416+ Opts.SkipSDKImportPaths |= Args.hasArg (OPT_nostdlibimport);
23862417
23872418 Opts.DisableModulesValidateSystemDependencies |=
23882419 Args.hasArg (OPT_disable_modules_validate_system_headers);
@@ -4046,6 +4077,7 @@ bool CompilerInvocation::parseArgs(
40464077 }
40474078
40484079 updateRuntimeLibraryPaths (SearchPathOpts, FrontendOpts, LangOpts);
4080+ updateImplicitFrameworkSearchPaths (SearchPathOpts, LangOpts);
40494081 setDefaultPrebuiltCacheIfNecessary ();
40504082 setDefaultBlocklistsIfNecessary ();
40514083 setDefaultInProcessPluginServerPathIfNecessary ();
0 commit comments