Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bool IncludeFixerActionFactory::runInvocation(
// diagnostics here.
Compiler.createDiagnostics(new clang::IgnoringDiagConsumer,
/*ShouldOwnClient=*/true);
Compiler.createSourceManager(*Files);
Compiler.createSourceManager();

// We abort on fatal errors so don't let a large number of errors become
// fatal. A missing #include can cause thousands of errors.
Expand Down
7 changes: 4 additions & 3 deletions clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,11 +649,12 @@ TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) {
Clang->createVirtualFileSystem(VFS);
Clang->createDiagnostics();

auto *FM = Clang->createFileManager();
Clang->createFileManager();
FileManager &FM = Clang->getFileManager();
ASSERT_TRUE(Clang->ExecuteAction(*Inputs.MakeAction()));
EXPECT_THAT(
PI.getExporters(llvm::cantFail(FM->getFileRef("foo.h")), *FM),
testing::ElementsAre(llvm::cantFail(FM->getFileRef("exporter.h"))));
PI.getExporters(llvm::cantFail(FM.getFileRef("foo.h")), FM),
testing::ElementsAre(llvm::cantFail(FM.getFileRef("exporter.h"))));
}

TEST_F(PragmaIncludeTest, OutlivesFMAndSM) {
Expand Down
6 changes: 2 additions & 4 deletions clang/include/clang/Frontend/CompilerInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,10 @@ class CompilerInstance : public ModuleLoader {
const CodeGenOptions *CodeGenOpts = nullptr);

/// Create the file manager and replace any existing one with it.
///
/// \return The new file manager on success, or null on failure.
FileManager *createFileManager();
void createFileManager();

/// Create the source manager and replace any existing one with it.
void createSourceManager(FileManager &FileMgr);
void createSourceManager();

/// Create the preprocessor, using the invocation, file, and source managers,
/// and replace any existing one with it.
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ bool ExtractAPIAction::PrepareToExecuteAction(CompilerInstance &CI) {
return true;

if (!CI.hasFileManager())
if (!CI.createFileManager())
return false;
CI.createFileManager();

auto Kind = Inputs[0].getKind();

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/ChainedIncludesSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ clang::createChainedIncludesSource(CompilerInstance &CI,
Clang->setTarget(TargetInfo::CreateTargetInfo(
Clang->getDiagnostics(), Clang->getInvocation().getTargetOpts()));
Clang->createFileManager();
Clang->createSourceManager(Clang->getFileManager());
Clang->createSourceManager();
Clang->createPreprocessor(TU_Prefix);
Clang->getDiagnosticClient().BeginSourceFile(Clang->getLangOpts(),
&Clang->getPreprocessor());
Expand Down
13 changes: 7 additions & 6 deletions clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,18 @@ IntrusiveRefCntPtr<DiagnosticsEngine> CompilerInstance::createDiagnostics(

// File Manager

FileManager *CompilerInstance::createFileManager() {
void CompilerInstance::createFileManager() {
assert(VFS && "CompilerInstance needs a VFS for creating FileManager");
FileMgr = llvm::makeIntrusiveRefCnt<FileManager>(getFileSystemOpts(), VFS);
return FileMgr.get();
}

// Source Manager

void CompilerInstance::createSourceManager(FileManager &FileMgr) {
SourceMgr =
llvm::makeIntrusiveRefCnt<SourceManager>(getDiagnostics(), FileMgr);
void CompilerInstance::createSourceManager() {
assert(Diagnostics && "DiagnosticsEngine needed for creating SourceManager");
assert(FileMgr && "FileManager needed for creating SourceManager");
SourceMgr = llvm::makeIntrusiveRefCnt<SourceManager>(getDiagnostics(),
getFileManager());
}

// Initialize the remapping of files to alternative contents, e.g.,
Expand Down Expand Up @@ -1186,7 +1187,7 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl(
if (llvm::is_contained(DiagOpts.SystemHeaderWarningsModules, ModuleName))
Instance.getDiagnostics().setSuppressSystemWarnings(false);

Instance.createSourceManager(Instance.getFileManager());
Instance.createSourceManager();
SourceManager &SourceMgr = Instance.getSourceManager();

if (ThreadSafeConfig) {
Expand Down
11 changes: 4 additions & 7 deletions clang/lib/Frontend/FrontendAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
// file, otherwise the CompilerInstance will happily destroy them.
CI.setVirtualFileSystem(AST->getFileManager().getVirtualFileSystemPtr());
CI.setFileManager(AST->getFileManagerPtr());
CI.createSourceManager(CI.getFileManager());
CI.createSourceManager();
CI.getSourceManager().initializeForReplay(AST->getSourceManager());

// Preload all the module files loaded transitively by the AST unit. Also
Expand Down Expand Up @@ -971,13 +971,10 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
// Set up the file system, file and source managers, if needed.
if (!CI.hasVirtualFileSystem())
CI.createVirtualFileSystem();
if (!CI.hasFileManager()) {
if (!CI.createFileManager()) {
return false;
}
}
if (!CI.hasFileManager())
CI.createFileManager();
if (!CI.hasSourceManager()) {
CI.createSourceManager(CI.getFileManager());
CI.createSourceManager();
if (CI.getDiagnosticOpts().getFormat() == DiagnosticOptions::SARIF) {
static_cast<SARIFDiagnosticPrinter *>(&CI.getDiagnosticClient())
->setSarifWriter(
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Testing/TestAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void createMissingComponents(CompilerInstance &Clang) {
if (!Clang.hasFileManager())
Clang.createFileManager();
if (!Clang.hasSourceManager())
Clang.createSourceManager(Clang.getFileManager());
Clang.createSourceManager();
if (!Clang.hasTarget())
Clang.createTarget();
if (!Clang.hasPreprocessor())
Expand Down
11 changes: 6 additions & 5 deletions clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,24 +415,25 @@ bool DependencyScanningAction::runInvocation(
any(Service.getOptimizeArgs() & ScanningOptimizations::VFS);

// Create a new FileManager to match the invocation's FileSystemOptions.
auto *FileMgr = ScanInstance.createFileManager();
ScanInstance.createFileManager();

// Use the dependency scanning optimized file system if requested to do so.
if (DepFS) {
DepFS->resetBypassedPathPrefix();
if (!ScanInstance.getHeaderSearchOpts().ModuleCachePath.empty()) {
SmallString<256> ModulesCachePath;
normalizeModuleCachePath(
*FileMgr, ScanInstance.getHeaderSearchOpts().ModuleCachePath,
ModulesCachePath);
ScanInstance.getFileManager(),
ScanInstance.getHeaderSearchOpts().ModuleCachePath, ModulesCachePath);
DepFS->setBypassedPathPrefix(ModulesCachePath);
}

ScanInstance.setDependencyDirectivesGetter(
std::make_unique<ScanningDependencyDirectivesGetter>(*FileMgr));
std::make_unique<ScanningDependencyDirectivesGetter>(
ScanInstance.getFileManager()));
}

ScanInstance.createSourceManager(*FileMgr);
ScanInstance.createSourceManager();

// Create a collection of stable directories derived from the ScanInstance
// for determining whether module dependencies would fully resolve from
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Tooling/Tooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ bool FrontendActionFactory::runInvocation(
if (!Compiler.hasDiagnostics())
return false;

Compiler.createSourceManager(*Files);
Compiler.createSourceManager();

const bool Success = Compiler.ExecuteAction(*ScopedToolAction);

Expand Down
2 changes: 1 addition & 1 deletion clang/tools/clang-import-test/clang-import-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ std::unique_ptr<CompilerInstance> BuildCompilerInstance() {
Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts(),
/*AuxTarget=*/nullptr);
Ins->createFileManager();
Ins->createSourceManager(Ins->getFileManager());
Ins->createSourceManager();
Ins->createPreprocessor(TU_Complete);

return Ins;
Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/CodeGen/TestCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct TestCompiler {
PtrSize = TInfo.getPointerWidth(clang::LangAS::Default) / 8;

compiler.createFileManager();
compiler.createSourceManager(compiler.getFileManager());
compiler.createSourceManager();
compiler.createPreprocessor(clang::TU_Prefix);

compiler.createASTContext();
Expand Down
4 changes: 2 additions & 2 deletions clang/unittests/Serialization/ForceCheckFileInputTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ export int aa = 43;

Clang.setDiagnostics(Diags);
Clang.createVirtualFileSystem(CIOpts.VFS);
FileManager *FM = Clang.createFileManager();
Clang.createSourceManager(*FM);
Clang.createFileManager();
Clang.createSourceManager();

EXPECT_TRUE(Clang.createTarget());
Clang.createPreprocessor(TU_Complete);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TestDependencyScanningAction : public tooling::ToolAction {
if (!Compiler.hasDiagnostics())
return false;

Compiler.createSourceManager(*FileMgr);
Compiler.createSourceManager();
Compiler.addDependencyCollector(std::make_shared<TestFileCollector>(
Compiler.getInvocation().getDependencyOutputOpts(), Deps));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ ClangExpressionParser::ClangExpressionParser(
// 6. Set up the source management objects inside the compiler
m_compiler->createFileManager();
if (!m_compiler->hasSourceManager())
m_compiler->createSourceManager(m_compiler->getFileManager());
m_compiler->createSourceManager();
m_compiler->createPreprocessor(TU_Complete);

switch (expr.Language().AsLanguageType()) {
Expand Down