Skip to content

Commit 53ce339

Browse files
committed
Revert "[clang] Don't silently inherit the VFS from FileManager (llvm#164323)"
breaks build/test of comgr This reverts commit 866879f.
1 parent bc294b3 commit 53ce339

File tree

15 files changed

+14
-21
lines changed

15 files changed

+14
-21
lines changed

clang-tools-extra/clang-include-fixer/IncludeFixer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ bool IncludeFixerActionFactory::runInvocation(
9090

9191
// Set up Clang.
9292
CompilerInstance Compiler(std::move(Invocation), std::move(PCHContainerOps));
93-
Compiler.setVirtualFileSystem(Files->getVirtualFileSystemPtr());
9493
Compiler.setFileManager(Files);
9594

9695
// Create the compiler's actual diagnostics engine. We want to drop all

clang/include/clang/Frontend/ASTUnit.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,6 @@ class ASTUnit {
499499
return *PPOpts;
500500
}
501501

502-
IntrusiveRefCntPtr<llvm::vfs::FileSystem> getVirtualFileSystemPtr() {
503-
// FIXME: Don't defer VFS ownership to the FileManager.
504-
return FileMgr->getVirtualFileSystemPtr();
505-
}
506-
507502
const FileManager &getFileManager() const { return *FileMgr; }
508503
FileManager &getFileManager() { return *FileMgr; }
509504
IntrusiveRefCntPtr<FileManager> getFileManagerPtr() { return FileMgr; }

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ class CompilerInstance : public ModuleLoader {
460460
FileMgr.resetWithoutRelease();
461461
}
462462

463-
/// Replace the current file manager.
463+
/// Replace the current file manager and virtual file system.
464464
void setFileManager(IntrusiveRefCntPtr<FileManager> Value);
465465

466466
/// @}

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,6 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
16461646
AST->Reader = nullptr;
16471647

16481648
// Create a file manager object to provide access to and cache the filesystem.
1649-
Clang->setVirtualFileSystem(AST->getVirtualFileSystemPtr());
16501649
Clang->setFileManager(AST->getFileManagerPtr());
16511650

16521651
// Create the source manager.
@@ -2286,7 +2285,6 @@ void ASTUnit::CodeComplete(
22862285
"IR inputs not support here!");
22872286

22882287
// Use the source and file managers that we were given.
2289-
Clang->setVirtualFileSystem(FileMgr->getVirtualFileSystemPtr());
22902288
Clang->setFileManager(FileMgr);
22912289
Clang->setSourceManager(SourceMgr);
22922290

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ bool CompilerInstance::createTarget() {
160160
}
161161

162162
void CompilerInstance::setFileManager(IntrusiveRefCntPtr<FileManager> Value) {
163+
if (!hasVirtualFileSystem())
164+
setVirtualFileSystem(Value->getVirtualFileSystemPtr());
163165
assert(Value == nullptr ||
164166
getVirtualFileSystemPtr() == Value->getVirtualFileSystemPtr());
165167
FileMgr = std::move(Value);

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,6 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
945945

946946
// Set the shared objects, these are reset when we finish processing the
947947
// file, otherwise the CompilerInstance will happily destroy them.
948-
CI.setVirtualFileSystem(AST->getVirtualFileSystemPtr());
949948
CI.setFileManager(AST->getFileManagerPtr());
950949
CI.setSourceManager(AST->getSourceManagerPtr());
951950
CI.setPreprocessor(AST->getPreprocessorPtr());

clang/lib/Frontend/PrecompiledPreamble.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,16 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build(
479479
Diagnostics->Reset();
480480
ProcessWarningOptions(*Diagnostics, Clang->getDiagnosticOpts(), *VFS);
481481

482+
VFS = createVFSFromCompilerInvocation(Clang->getInvocation(), *Diagnostics,
483+
VFS);
484+
482485
// Create a file manager object to provide access to and cache the filesystem.
483-
Clang->createVirtualFileSystem(VFS);
484-
Clang->createFileManager();
486+
Clang->setFileManager(
487+
llvm::makeIntrusiveRefCnt<FileManager>(Clang->getFileSystemOpts(), VFS));
485488

486489
// Create the source manager.
487-
Clang->createSourceManager();
490+
Clang->setSourceManager(llvm::makeIntrusiveRefCnt<SourceManager>(
491+
*Diagnostics, Clang->getFileManager()));
488492

489493
auto PreambleDepCollector = std::make_shared<PreambleDependencyCollector>();
490494
Clang->addDependencyCollector(PreambleDepCollector);

clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ void ModelInjector::onBodySynthesis(const NamedDecl *D) {
9393

9494
// The instance wants to take ownership, however DisableFree frontend option
9595
// is set to true to avoid double free issues
96-
Instance.setVirtualFileSystem(CI.getVirtualFileSystemPtr());
9796
Instance.setFileManager(CI.getFileManagerPtr());
9897
Instance.setSourceManager(SM);
9998
Instance.setPreprocessor(CI.getPreprocessorPtr());

clang/lib/Tooling/Tooling.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ bool FrontendActionFactory::runInvocation(
446446
DiagnosticConsumer *DiagConsumer) {
447447
// Create a compiler instance to handle the actual work.
448448
CompilerInstance Compiler(std::move(Invocation), std::move(PCHContainerOps));
449-
Compiler.setVirtualFileSystem(Files->getVirtualFileSystemPtr());
450449
Compiler.setFileManager(Files);
451450

452451
// The FrontendAction can have lifetime requirements for Compiler or its

clang/tools/clang-installapi/ClangInstallAPI.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ static bool run(ArrayRef<const char *> Args, const char *ProgName) {
114114

115115
// Set up compilation.
116116
std::unique_ptr<CompilerInstance> CI(new CompilerInstance());
117-
CI->setVirtualFileSystem(FM->getVirtualFileSystemPtr());
118117
CI->setFileManager(FM);
119118
CI->createDiagnostics();
120119
if (!CI->hasDiagnostics())

0 commit comments

Comments
 (0)