@@ -1133,7 +1133,7 @@ std::optional<std::vector<std::string>> ClangImporter::getClangCC1Arguments(
1133
1133
1134
1134
std::vector<std::string> FilteredModuleMapFiles;
1135
1135
for (auto ModuleMapFile : CI->getFrontendOpts ().ModuleMapFiles ) {
1136
- if (ctx.ClangImporterOpts .UseClangIncludeTree ) {
1136
+ if (ctx.ClangImporterOpts .HasClangIncludeTreeRoot ) {
1137
1137
// There is no need to add any module map file here. Issue a warning and
1138
1138
// drop the option.
1139
1139
importer->Impl .diagnose (SourceLoc (), diag::module_map_ignored,
@@ -1200,27 +1200,33 @@ ClangImporter::create(ASTContext &ctx,
1200
1200
}
1201
1201
}
1202
1202
1203
- auto fileMapping = getClangInvocationFileMapping (ctx);
1204
- // Wrap Swift's FS to allow Clang to override the working directory
1205
1203
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
1206
- llvm::vfs::RedirectingFileSystem::create (
1207
- fileMapping.redirectedFiles , true , *ctx.SourceMgr .getFileSystem ());
1208
- if (!fileMapping.overridenFiles .empty ()) {
1209
- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> overridenVFS =
1210
- new llvm::vfs::InMemoryFileSystem ();
1211
- for (const auto &file : fileMapping.overridenFiles ) {
1212
- auto contents = ctx.Allocate <char >(file.second .size () + 1 );
1213
- std::copy (file.second .begin (), file.second .end (), contents.begin ());
1214
- // null terminate the buffer.
1215
- contents[contents.size () - 1 ] = ' \0 ' ;
1216
- overridenVFS->addFile (file.first , 0 ,
1217
- llvm::MemoryBuffer::getMemBuffer (
1218
- StringRef (contents.begin (), contents.size () - 1 )));
1219
- }
1220
- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> overlayVFS =
1221
- new llvm::vfs::OverlayFileSystem (VFS);
1222
- VFS = overlayVFS;
1223
- overlayVFS->pushOverlay (overridenVFS);
1204
+ ctx.SourceMgr .getFileSystem ();
1205
+
1206
+ auto fileMapping = getClangInvocationFileMapping (ctx);
1207
+ // Avoid creating indirect file system when using include tree.
1208
+ if (!ctx.ClangImporterOpts .HasClangIncludeTreeRoot ) {
1209
+ // Wrap Swift's FS to allow Clang to override the working directory
1210
+ VFS = llvm::vfs::RedirectingFileSystem::create (
1211
+ fileMapping.redirectedFiles , true , *ctx.SourceMgr .getFileSystem ());
1212
+
1213
+ if (!fileMapping.overridenFiles .empty ()) {
1214
+ llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> overridenVFS =
1215
+ new llvm::vfs::InMemoryFileSystem ();
1216
+ for (const auto &file : fileMapping.overridenFiles ) {
1217
+ auto contents = ctx.Allocate <char >(file.second .size () + 1 );
1218
+ std::copy (file.second .begin (), file.second .end (), contents.begin ());
1219
+ // null terminate the buffer.
1220
+ contents[contents.size () - 1 ] = ' \0 ' ;
1221
+ overridenVFS->addFile (file.first , 0 ,
1222
+ llvm::MemoryBuffer::getMemBuffer (StringRef (
1223
+ contents.begin (), contents.size () - 1 )));
1224
+ }
1225
+ llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> overlayVFS =
1226
+ new llvm::vfs::OverlayFileSystem (VFS);
1227
+ VFS = overlayVFS;
1228
+ overlayVFS->pushOverlay (overridenVFS);
1229
+ }
1224
1230
}
1225
1231
1226
1232
// Create a new Clang compiler invocation.
0 commit comments