@@ -159,6 +159,31 @@ void CompilerInvocation::setDefaultPrebuiltCacheIfNecessary() {
159
159
(llvm::Twine (pair.first ) + " preferred-interfaces" + pair.second ).str ();
160
160
}
161
161
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
+
162
187
static void updateRuntimeLibraryPaths (SearchPathOptions &SearchPathOpts,
163
188
llvm::Triple &Triple) {
164
189
llvm::SmallString<128 > LibPath (SearchPathOpts.RuntimeResourcePath );
@@ -2870,6 +2895,7 @@ bool CompilerInvocation::parseArgs(
2870
2895
2871
2896
updateRuntimeLibraryPaths (SearchPathOpts, LangOpts.Target );
2872
2897
setDefaultPrebuiltCacheIfNecessary ();
2898
+ setDefaultBlocklistsIfNecessary ();
2873
2899
2874
2900
// Now that we've parsed everything, setup some inter-option-dependent state.
2875
2901
setIRGenOutputOptsFromFrontendOptions (IRGenOpts, FrontendOpts);
0 commit comments