@@ -159,6 +159,31 @@ void CompilerInvocation::setDefaultPrebuiltCacheIfNecessary() {
159159 (llvm::Twine (pair.first ) + " preferred-interfaces" + pair.second ).str ();
160160}
161161
162+ void CompilerInvocation::setDefaultBlocklistsIfNecessary () {
163+ if (!LangOpts.BlocklistConfigFilePaths .empty ())
164+ return ;
165+ if (SearchPathOpts.RuntimeResourcePath .empty ())
166+ return ;
167+ // XcodeDefault.xctoolchain/usr/lib/swift
168+ SmallString<64 > blocklistDir{SearchPathOpts.RuntimeResourcePath };
169+ // XcodeDefault.xctoolchain/usr/lib
170+ llvm::sys::path::remove_filename (blocklistDir);
171+ // XcodeDefault.xctoolchain/usr
172+ llvm::sys::path::remove_filename (blocklistDir);
173+ // XcodeDefault.xctoolchain/usr/local/lib/swift/blocklists
174+ llvm::sys::path::append (blocklistDir, " local" , " lib" , " swift" , " blocklists" );
175+ std::error_code EC;
176+ if (llvm::sys::fs::is_directory (blocklistDir)) {
177+ for (llvm::sys::fs::directory_iterator F (blocklistDir, EC), FE;
178+ F != FE; F.increment (EC)) {
179+ StringRef ext = llvm::sys::path::extension (F->path ());
180+ if (ext == " yml" || ext == " yaml" ) {
181+ LangOpts.BlocklistConfigFilePaths .push_back (F->path ());
182+ }
183+ }
184+ }
185+ }
186+
162187static void updateRuntimeLibraryPaths (SearchPathOptions &SearchPathOpts,
163188 llvm::Triple &Triple) {
164189 llvm::SmallString<128 > LibPath (SearchPathOpts.RuntimeResourcePath );
@@ -2870,6 +2895,7 @@ bool CompilerInvocation::parseArgs(
28702895
28712896 updateRuntimeLibraryPaths (SearchPathOpts, LangOpts.Target );
28722897 setDefaultPrebuiltCacheIfNecessary ();
2898+ setDefaultBlocklistsIfNecessary ();
28732899
28742900 // Now that we've parsed everything, setup some inter-option-dependent state.
28752901 setIRGenOutputOptsFromFrontendOptions (IRGenOpts, FrontendOpts);
0 commit comments