Skip to content

Commit df9a14d

Browse files
committed
Reapply "[NFC] Explicitly pass a VFS when creating DiagnosticsEngine (#115852)"
This reverts commit a1153cd with fixes to lldb breakages. Fixes #117145.
1 parent d800ea7 commit df9a14d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+197
-138
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ bool IncludeFixerActionFactory::runInvocation(
9595

9696
// Create the compiler's actual diagnostics engine. We want to drop all
9797
// diagnostics here.
98-
Compiler.createDiagnostics(new clang::IgnoringDiagConsumer,
98+
Compiler.createDiagnostics(Files->getVirtualFileSystem(),
99+
new clang::IgnoringDiagConsumer,
99100
/*ShouldOwnClient=*/true);
100101
Compiler.createSourceManager(*Files);
101102

clang-tools-extra/clangd/Compiler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,
110110
CIOpts.VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory);
111111
CIOpts.CC1Args = CC1Args;
112112
CIOpts.RecoverOnError = true;
113-
CIOpts.Diags =
114-
CompilerInstance::createDiagnostics(new DiagnosticOptions, &D, false);
113+
CIOpts.Diags = CompilerInstance::createDiagnostics(
114+
*CIOpts.VFS, new DiagnosticOptions, &D, false);
115115
CIOpts.ProbePrecompiled = false;
116116
std::unique_ptr<CompilerInvocation> CI = createInvocation(ArgStrs, CIOpts);
117117
if (!CI)
@@ -148,7 +148,7 @@ prepareCompilerInstance(std::unique_ptr<clang::CompilerInvocation> CI,
148148
auto Clang = std::make_unique<CompilerInstance>(
149149
std::make_shared<PCHContainerOperations>());
150150
Clang->setInvocation(std::move(CI));
151-
Clang->createDiagnostics(&DiagsClient, false);
151+
Clang->createDiagnostics(*VFS, &DiagsClient, false);
152152

153153
if (auto VFSWithRemapping = createVFSFromCompilerInvocation(
154154
Clang->getInvocation(), Clang->getDiagnostics(), VFS))

clang-tools-extra/clangd/ModulesBuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ bool IsModuleFileUpToDate(PathRef ModuleFilePath,
188188

189189
clang::clangd::IgnoreDiagnostics IgnoreDiags;
190190
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
191-
CompilerInstance::createDiagnostics(new DiagnosticOptions, &IgnoreDiags,
191+
CompilerInstance::createDiagnostics(*VFS, new DiagnosticOptions,
192+
&IgnoreDiags,
192193
/*ShouldOwnClient=*/false);
193194

194195
LangOptions LangOpts;

clang-tools-extra/clangd/Preamble.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,9 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
613613
for (const auto &L : ASTListeners)
614614
L->sawDiagnostic(D, Diag);
615615
});
616+
auto VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory);
616617
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> PreambleDiagsEngine =
617-
CompilerInstance::createDiagnostics(&CI.getDiagnosticOpts(),
618+
CompilerInstance::createDiagnostics(*VFS, &CI.getDiagnosticOpts(),
618619
&PreambleDiagnostics,
619620
/*ShouldOwnClient=*/false);
620621
const Config &Cfg = Config::current();
@@ -651,7 +652,6 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
651652
for (const auto &L : ASTListeners)
652653
L->beforeExecute(CI);
653654
});
654-
auto VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory);
655655
llvm::SmallString<32> AbsFileName(FileName);
656656
VFS->makeAbsolute(AbsFileName);
657657
auto StatCache = std::make_shared<PreambleFileStatusCache>(AbsFileName);

clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,6 @@ TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) {
609609
)cpp";
610610
Inputs.ExtraFiles["foo.h"] = "";
611611

612-
auto Clang = std::make_unique<CompilerInstance>(
613-
std::make_shared<PCHContainerOperations>());
614-
Clang->createDiagnostics();
615-
616-
Clang->setInvocation(std::make_unique<CompilerInvocation>());
617-
ASSERT_TRUE(CompilerInvocation::CreateFromArgs(
618-
Clang->getInvocation(), {Filename.data()}, Clang->getDiagnostics(),
619-
"clang"));
620-
621612
// Create unnamed memory buffers for all the files.
622613
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
623614
VFS->addFile(Filename, /*ModificationTime=*/0,
@@ -626,6 +617,16 @@ TEST_F(PragmaIncludeTest, ExportInUnnamedBuffer) {
626617
VFS->addFile(Extra.getKey(), /*ModificationTime=*/0,
627618
llvm::MemoryBuffer::getMemBufferCopy(Extra.getValue(),
628619
/*BufferName=*/""));
620+
621+
auto Clang = std::make_unique<CompilerInstance>(
622+
std::make_shared<PCHContainerOperations>());
623+
Clang->createDiagnostics(*VFS);
624+
625+
Clang->setInvocation(std::make_unique<CompilerInvocation>());
626+
ASSERT_TRUE(CompilerInvocation::CreateFromArgs(
627+
Clang->getInvocation(), {Filename.data()}, Clang->getDiagnostics(),
628+
"clang"));
629+
629630
auto *FM = Clang->createFileManager(VFS);
630631
ASSERT_TRUE(Clang->ExecuteAction(*Inputs.MakeAction()));
631632
EXPECT_THAT(

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,13 +675,17 @@ class CompilerInstance : public ModuleLoader {
675675
/// Note that this routine also replaces the diagnostic client,
676676
/// allocating one if one is not provided.
677677
///
678+
/// \param VFS is used for any IO needed when creating DiagnosticsEngine. It
679+
/// doesn't replace VFS in the CompilerInstance (if any).
680+
///
678681
/// \param Client If non-NULL, a diagnostic client that will be
679682
/// attached to (and, then, owned by) the DiagnosticsEngine inside this AST
680683
/// unit.
681684
///
682685
/// \param ShouldOwnClient If Client is non-NULL, specifies whether
683686
/// the diagnostic object should take ownership of the client.
684-
void createDiagnostics(DiagnosticConsumer *Client = nullptr,
687+
void createDiagnostics(llvm::vfs::FileSystem &VFS,
688+
DiagnosticConsumer *Client = nullptr,
685689
bool ShouldOwnClient = true);
686690

687691
/// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter.
@@ -702,10 +706,11 @@ class CompilerInstance : public ModuleLoader {
702706
/// used by some diagnostics printers (for logging purposes only).
703707
///
704708
/// \return The new object on success, or null on failure.
705-
static IntrusiveRefCntPtr<DiagnosticsEngine> createDiagnostics(
706-
DiagnosticOptions *Opts, DiagnosticConsumer *Client = nullptr,
707-
bool ShouldOwnClient = true, const CodeGenOptions *CodeGenOpts = nullptr,
708-
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
709+
static IntrusiveRefCntPtr<DiagnosticsEngine>
710+
createDiagnostics(llvm::vfs::FileSystem &VFS, DiagnosticOptions *Opts,
711+
DiagnosticConsumer *Client = nullptr,
712+
bool ShouldOwnClient = true,
713+
const CodeGenOptions *CodeGenOpts = nullptr);
709714

710715
/// Create the file manager and replace any existing one with it.
711716
///

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,23 +332,20 @@ static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
332332
}
333333
}
334334

335-
void CompilerInstance::createDiagnostics(DiagnosticConsumer *Client,
335+
void CompilerInstance::createDiagnostics(llvm::vfs::FileSystem &VFS,
336+
DiagnosticConsumer *Client,
336337
bool ShouldOwnClient) {
337-
Diagnostics = createDiagnostics(
338-
&getDiagnosticOpts(), Client, ShouldOwnClient, &getCodeGenOpts(),
339-
FileMgr ? FileMgr->getVirtualFileSystemPtr() : nullptr);
338+
Diagnostics = createDiagnostics(VFS, &getDiagnosticOpts(), Client,
339+
ShouldOwnClient, &getCodeGenOpts());
340340
}
341341

342342
IntrusiveRefCntPtr<DiagnosticsEngine> CompilerInstance::createDiagnostics(
343-
DiagnosticOptions *Opts, DiagnosticConsumer *Client, bool ShouldOwnClient,
344-
const CodeGenOptions *CodeGenOpts,
345-
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
343+
llvm::vfs::FileSystem &VFS, DiagnosticOptions *Opts,
344+
DiagnosticConsumer *Client, bool ShouldOwnClient,
345+
const CodeGenOptions *CodeGenOpts) {
346346
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
347-
IntrusiveRefCntPtr<DiagnosticsEngine>
348-
Diags(new DiagnosticsEngine(DiagID, Opts));
349-
350-
if (!VFS)
351-
VFS = llvm::vfs::getRealFileSystem();
347+
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
348+
new DiagnosticsEngine(DiagID, Opts));
352349

353350
// Create the diagnostic client for reporting errors or for
354351
// implementing -verify.
@@ -372,7 +369,7 @@ IntrusiveRefCntPtr<DiagnosticsEngine> CompilerInstance::createDiagnostics(
372369
Opts->DiagnosticSerializationFile);
373370

374371
// Configure our handling of diagnostics.
375-
ProcessWarningOptions(*Diags, *Opts, *VFS);
372+
ProcessWarningOptions(*Diags, *Opts, VFS);
376373

377374
return Diags;
378375
}
@@ -1240,9 +1237,10 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
12401237
auto &Inv = *Invocation;
12411238
Instance.setInvocation(std::move(Invocation));
12421239

1243-
Instance.createDiagnostics(new ForwardingDiagnosticConsumer(
1244-
ImportingInstance.getDiagnosticClient()),
1245-
/*ShouldOwnClient=*/true);
1240+
Instance.createDiagnostics(
1241+
ImportingInstance.getVirtualFileSystem(),
1242+
new ForwardingDiagnosticConsumer(ImportingInstance.getDiagnosticClient()),
1243+
/*ShouldOwnClient=*/true);
12461244

12471245
if (llvm::is_contained(DiagOpts.SystemHeaderWarningsModules, ModuleName))
12481246
Instance.getDiagnostics().setSuppressSystemWarnings(false);

clang/lib/Frontend/CreateInvocationFromCommandLine.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "llvm/ADT/STLExtras.h"
2323
#include "llvm/ADT/StringRef.h"
2424
#include "llvm/Option/ArgList.h"
25+
#include "llvm/Support/VirtualFileSystem.h"
2526
#include "llvm/TargetParser/Host.h"
2627
using namespace clang;
2728
using namespace llvm::opt;
@@ -32,7 +33,9 @@ clang::createInvocation(ArrayRef<const char *> ArgList,
3233
assert(!ArgList.empty());
3334
auto Diags = Opts.Diags
3435
? std::move(Opts.Diags)
35-
: CompilerInstance::createDiagnostics(new DiagnosticOptions);
36+
: CompilerInstance::createDiagnostics(
37+
Opts.VFS ? *Opts.VFS : *llvm::vfs::getRealFileSystem(),
38+
new DiagnosticOptions);
3639

3740
SmallVector<const char *, 16> Args(ArgList);
3841

clang/lib/Frontend/Rewrite/FrontendActions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ class RewriteIncludesAction::RewriteImportsListener : public ASTReaderListener {
247247
Instance.setInvocation(
248248
std::make_shared<CompilerInvocation>(CI.getInvocation()));
249249
Instance.createDiagnostics(
250+
CI.getVirtualFileSystem(),
250251
new ForwardingDiagnosticConsumer(CI.getDiagnosticClient()),
251252
/*ShouldOwnClient=*/true);
252253
Instance.getFrontendOpts().DisableFree = false;

clang/lib/Interpreter/Interpreter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "IncrementalExecutor.h"
1616
#include "IncrementalParser.h"
1717
#include "InterpreterUtils.h"
18+
#include "llvm/Support/VirtualFileSystem.h"
1819
#ifdef __EMSCRIPTEN__
1920
#include "Wasm.h"
2021
#endif // __EMSCRIPTEN__
@@ -106,7 +107,7 @@ CreateCI(const llvm::opt::ArgStringList &Argv) {
106107
CompilerInvocation::GetResourcesPath(Argv[0], nullptr);
107108

108109
// Create the actual diagnostics engine.
109-
Clang->createDiagnostics();
110+
Clang->createDiagnostics(*llvm::vfs::getRealFileSystem());
110111
if (!Clang->hasDiagnostics())
111112
return llvm::createStringError(llvm::errc::not_supported,
112113
"Initialization failed. "

clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void ModelInjector::onBodySynthesis(const NamedDecl *D) {
7878
CompilerInstance Instance(CI.getPCHContainerOperations());
7979
Instance.setInvocation(std::move(Invocation));
8080
Instance.createDiagnostics(
81+
CI.getVirtualFileSystem(),
8182
new ForwardingDiagnosticConsumer(CI.getDiagnosticClient()),
8283
/*ShouldOwnClient=*/true);
8384

clang/lib/Testing/TestAST.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class StoreDiagnostics : public DiagnosticConsumer {
5555
// Provides "empty" ASTContext etc if we fail before parsing gets started.
5656
void createMissingComponents(CompilerInstance &Clang) {
5757
if (!Clang.hasDiagnostics())
58-
Clang.createDiagnostics();
58+
Clang.createDiagnostics(*llvm::vfs::getRealFileSystem());
5959
if (!Clang.hasFileManager())
6060
Clang.createFileManager();
6161
if (!Clang.hasSourceManager())
@@ -82,9 +82,24 @@ TestAST::TestAST(const TestInputs &In) {
8282
auto RecoverFromEarlyExit =
8383
llvm::make_scope_exit([&] { createMissingComponents(*Clang); });
8484

85+
std::string Filename = In.FileName;
86+
if (Filename.empty())
87+
Filename = getFilenameForTesting(In.Language).str();
88+
89+
// Set up a VFS with only the virtual file visible.
90+
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
91+
if (auto Err = VFS->setCurrentWorkingDirectory(In.WorkingDir))
92+
ADD_FAILURE() << "Failed to setWD: " << Err.message();
93+
VFS->addFile(Filename, /*ModificationTime=*/0,
94+
llvm::MemoryBuffer::getMemBufferCopy(In.Code, Filename));
95+
for (const auto &Extra : In.ExtraFiles)
96+
VFS->addFile(
97+
Extra.getKey(), /*ModificationTime=*/0,
98+
llvm::MemoryBuffer::getMemBufferCopy(Extra.getValue(), Extra.getKey()));
99+
85100
// Extra error conditions are reported through diagnostics, set that up first.
86101
bool ErrorOK = In.ErrorOK || llvm::StringRef(In.Code).contains("error-ok");
87-
Clang->createDiagnostics(new StoreDiagnostics(Diagnostics, !ErrorOK));
102+
Clang->createDiagnostics(*VFS, new StoreDiagnostics(Diagnostics, !ErrorOK));
88103

89104
// Parse cc1 argv, (typically [-std=c++20 input.cc]) into CompilerInvocation.
90105
std::vector<const char *> Argv;
@@ -93,9 +108,6 @@ TestAST::TestAST(const TestInputs &In) {
93108
Argv.push_back(S.c_str());
94109
for (const auto &S : In.ExtraArgs)
95110
Argv.push_back(S.c_str());
96-
std::string Filename = In.FileName;
97-
if (Filename.empty())
98-
Filename = getFilenameForTesting(In.Language).str();
99111
Argv.push_back(Filename.c_str());
100112
Clang->setInvocation(std::make_unique<CompilerInvocation>());
101113
if (!CompilerInvocation::CreateFromArgs(Clang->getInvocation(), Argv,
@@ -105,16 +117,6 @@ TestAST::TestAST(const TestInputs &In) {
105117
}
106118
assert(!Clang->getInvocation().getFrontendOpts().DisableFree);
107119

108-
// Set up a VFS with only the virtual file visible.
109-
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
110-
if (auto Err = VFS->setCurrentWorkingDirectory(In.WorkingDir))
111-
ADD_FAILURE() << "Failed to setWD: " << Err.message();
112-
VFS->addFile(Filename, /*ModificationTime=*/0,
113-
llvm::MemoryBuffer::getMemBufferCopy(In.Code, Filename));
114-
for (const auto &Extra : In.ExtraFiles)
115-
VFS->addFile(
116-
Extra.getKey(), /*ModificationTime=*/0,
117-
llvm::MemoryBuffer::getMemBufferCopy(Extra.getValue(), Extra.getKey()));
118120
Clang->createFileManager(VFS);
119121

120122
// Running the FrontendAction creates the other components: SourceManager,

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ class DependencyScanningAction : public tooling::ToolAction {
322322

323323
// Create the compiler's actual diagnostics engine.
324324
sanitizeDiagOpts(ScanInstance.getDiagnosticOpts());
325-
ScanInstance.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
325+
ScanInstance.createDiagnostics(DriverFileMgr->getVirtualFileSystem(),
326+
DiagConsumer, /*ShouldOwnClient=*/false);
326327
if (!ScanInstance.hasDiagnostics())
327328
return false;
328329

@@ -650,7 +651,7 @@ bool DependencyScanningWorker::computeDependencies(
650651
auto DiagOpts = CreateAndPopulateDiagOpts(FinalCCommandLine);
651652
sanitizeDiagOpts(*DiagOpts);
652653
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
653-
CompilerInstance::createDiagnostics(DiagOpts.release(), &DC,
654+
CompilerInstance::createDiagnostics(*FinalFS, DiagOpts.release(), &DC,
654655
/*ShouldOwnClient=*/false);
655656

656657
// Although `Diagnostics` are used only for command-line parsing, the

clang/lib/Tooling/Tooling.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ bool ToolInvocation::run() {
387387
TextDiagnosticPrinter DiagnosticPrinter(llvm::errs(), DiagOpts);
388388
IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics =
389389
CompilerInstance::createDiagnostics(
390-
&*DiagOpts, DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false);
390+
Files->getVirtualFileSystem(), &*DiagOpts,
391+
DiagConsumer ? DiagConsumer : &DiagnosticPrinter, false);
391392
// Although `Diagnostics` are used only for command-line parsing, the custom
392393
// `DiagConsumer` might expect a `SourceManager` to be present.
393394
SourceManager SrcMgr(*Diagnostics, *Files);
@@ -456,7 +457,8 @@ bool FrontendActionFactory::runInvocation(
456457
std::unique_ptr<FrontendAction> ScopedToolAction(create());
457458

458459
// Create the compiler's actual diagnostics engine.
459-
Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
460+
Compiler.createDiagnostics(Files->getVirtualFileSystem(), DiagConsumer,
461+
/*ShouldOwnClient=*/false);
460462
if (!Compiler.hasDiagnostics())
461463
return false;
462464

@@ -652,7 +654,8 @@ class ASTBuilderAction : public ToolAction {
652654
DiagnosticConsumer *DiagConsumer) override {
653655
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromCompilerInvocation(
654656
Invocation, std::move(PCHContainerOps),
655-
CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts(),
657+
CompilerInstance::createDiagnostics(Files->getVirtualFileSystem(),
658+
&Invocation->getDiagnosticOpts(),
656659
DiagConsumer,
657660
/*ShouldOwnClient=*/false),
658661
Files);

clang/tools/c-index-test/core_main.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/Support/Program.h"
2626
#include "llvm/Support/Signals.h"
2727
#include "llvm/Support/StringSaver.h"
28+
#include "llvm/Support/VirtualFileSystem.h"
2829
#include "llvm/Support/raw_ostream.h"
2930

3031
using namespace clang;
@@ -219,8 +220,9 @@ static bool printSourceSymbols(const char *Executable,
219220
SmallVector<const char *, 4> ArgsWithProgName;
220221
ArgsWithProgName.push_back(Executable);
221222
ArgsWithProgName.append(Args.begin(), Args.end());
222-
IntrusiveRefCntPtr<DiagnosticsEngine>
223-
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
223+
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
224+
CompilerInstance::createDiagnostics(*llvm::vfs::getRealFileSystem(),
225+
new DiagnosticOptions));
224226
CreateInvocationOptions CIOpts;
225227
CIOpts.Diags = Diags;
226228
CIOpts.ProbePrecompiled = true; // FIXME: historical default. Needed?
@@ -273,7 +275,8 @@ static bool printSourceSymbolsFromModule(StringRef modulePath,
273275
auto HSOpts = std::make_shared<HeaderSearchOptions>();
274276

275277
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
276-
CompilerInstance::createDiagnostics(new DiagnosticOptions());
278+
CompilerInstance::createDiagnostics(*llvm::vfs::getRealFileSystem(),
279+
new DiagnosticOptions());
277280
std::unique_ptr<ASTUnit> AU =
278281
ASTUnit::LoadFromASTFile(modulePath, *pchRdr, ASTUnit::LoadASTOnly, Diags,
279282
FileSystemOpts, HSOpts, /*LangOpts=*/nullptr,

clang/tools/clang-import-test/clang-import-test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "llvm/Support/CommandLine.h"
3232
#include "llvm/Support/Error.h"
3333
#include "llvm/Support/Signals.h"
34+
#include "llvm/Support/VirtualFileSystem.h"
3435
#include "llvm/TargetParser/Host.h"
3536

3637
#include <memory>
@@ -164,7 +165,8 @@ std::unique_ptr<CompilerInstance> BuildCompilerInstance() {
164165
auto Ins = std::make_unique<CompilerInstance>();
165166
auto DC = std::make_unique<TestDiagnosticConsumer>();
166167
const bool ShouldOwnClient = true;
167-
Ins->createDiagnostics(DC.release(), ShouldOwnClient);
168+
Ins->createDiagnostics(*llvm::vfs::getRealFileSystem(), DC.release(),
169+
ShouldOwnClient);
168170

169171
auto Inv = std::make_unique<CompilerInvocation>();
170172

0 commit comments

Comments
 (0)