Author: sammccall Date: Thu Apr 4 05:56:03 2019 New Revision: 357689 URL: http://llvm.org/viewvc/llvm-project?rev=357689&view=rev Log: [clangd] Stop passing around PCHContainerOperations, just create it in place. NFC
Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/ClangdServer.h clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/clangd/ClangdUnit.h clang-tools-extra/trunk/clangd/CodeComplete.cpp clang-tools-extra/trunk/clangd/CodeComplete.h clang-tools-extra/trunk/clangd/Compiler.cpp clang-tools-extra/trunk/clangd/Compiler.h clang-tools-extra/trunk/clangd/TUScheduler.cpp clang-tools-extra/trunk/clangd/TUScheduler.h clang-tools-extra/trunk/clangd/index/Background.cpp clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp clang-tools-extra/trunk/unittests/clangd/TestTU.cpp Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Thu Apr 4 05:56:03 2019 @@ -114,7 +114,6 @@ ClangdServer::ClangdServer(const GlobalC ClangTidyOptProvider(Opts.ClangTidyOptProvider), SuggestMissingIncludes(Opts.SuggestMissingIncludes), WorkspaceRoot(Opts.WorkspaceRoot), - PCHs(std::make_shared<PCHContainerOperations>()), // Pass a callback into `WorkScheduler` to extract symbols from a newly // parsed file and rebuild the file index synchronously each time an AST // is parsed. @@ -176,11 +175,8 @@ void ClangdServer::codeComplete(PathRef if (!CodeCompleteOpts.Index) // Respect overridden index. CodeCompleteOpts.Index = Index; - // Copy PCHs to avoid accessing this->PCHs concurrently - std::shared_ptr<PCHContainerOperations> PCHs = this->PCHs; auto FS = FSProvider.getFileSystem(); - - auto Task = [PCHs, Pos, FS, CodeCompleteOpts, + auto Task = [Pos, FS, CodeCompleteOpts, this](Path File, Callback<CodeCompleteResult> CB, llvm::Expected<InputsAndPreamble> IP) { if (!IP) @@ -200,7 +196,7 @@ void ClangdServer::codeComplete(PathRef // FIXME(ibiryukov): even if Preamble is non-null, we may want to check // both the old and the new version in case only one of them matches. CodeCompleteResult Result = clangd::codeComplete( - File, IP->Command, IP->Preamble, IP->Contents, Pos, FS, PCHs, + File, IP->Command, IP->Preamble, IP->Contents, Pos, FS, CodeCompleteOpts, SpecFuzzyFind ? SpecFuzzyFind.getPointer() : nullptr); { clang::clangd::trace::Span Tracer("Completion results callback"); @@ -225,17 +221,16 @@ void ClangdServer::codeComplete(PathRef void ClangdServer::signatureHelp(PathRef File, Position Pos, Callback<SignatureHelp> CB) { - auto PCHs = this->PCHs; auto FS = FSProvider.getFileSystem(); auto *Index = this->Index; - auto Action = [Pos, FS, PCHs, Index](Path File, Callback<SignatureHelp> CB, - llvm::Expected<InputsAndPreamble> IP) { + auto Action = [Pos, FS, Index](Path File, Callback<SignatureHelp> CB, + llvm::Expected<InputsAndPreamble> IP) { if (!IP) return CB(IP.takeError()); auto PreambleData = IP->Preamble; CB(clangd::signatureHelp(File, IP->Command, PreambleData, IP->Contents, Pos, - FS, PCHs, Index)); + FS, Index)); }; // Unlike code completion, we wait for an up-to-date preamble here. Modified: clang-tools-extra/trunk/clangd/ClangdServer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.h (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.h Thu Apr 4 05:56:03 2019 @@ -36,8 +36,6 @@ #include <utility> namespace clang { -class PCHContainerOperations; - namespace clangd { // FIXME: find a better name. @@ -300,7 +298,6 @@ private: mutable std::mutex CachedCompletionFuzzyFindRequestMutex; llvm::Optional<std::string> WorkspaceRoot; - std::shared_ptr<PCHContainerOperations> PCHs; // WorkScheduler has to be the last member, because its destructor has to be // called before all other members to stop the worker thread that references // ClangdServer. Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Apr 4 05:56:03 2019 @@ -32,6 +32,7 @@ #include "clang/Lex/PreprocessorOptions.h" #include "clang/Sema/Sema.h" #include "clang/Serialization/ASTWriter.h" +#include "clang/Serialization/PCHContainerOperations.h" #include "clang/Tooling/CompilationDatabase.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" @@ -246,7 +247,6 @@ llvm::Optional<ParsedAST> ParsedAST::build(std::unique_ptr<CompilerInvocation> CI, std::shared_ptr<const PreambleData> Preamble, std::unique_ptr<llvm::MemoryBuffer> Buffer, - std::shared_ptr<PCHContainerOperations> PCHs, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, const SymbolIndex *Index, const ParseOptions &Opts) { assert(CI); @@ -259,9 +259,8 @@ ParsedAST::build(std::unique_ptr<Compile StoreDiags ASTDiags; std::string Content = Buffer->getBuffer(); - auto Clang = - prepareCompilerInstance(std::move(CI), PreamblePCH, std::move(Buffer), - std::move(PCHs), VFS, ASTDiags); + auto Clang = prepareCompilerInstance(std::move(CI), PreamblePCH, + std::move(Buffer), VFS, ASTDiags); if (!Clang) return None; @@ -488,8 +487,7 @@ std::shared_ptr<const PreambleData> buildPreamble(PathRef FileName, CompilerInvocation &CI, std::shared_ptr<const PreambleData> OldPreamble, const tooling::CompileCommand &OldCompileCommand, - const ParseInputs &Inputs, - std::shared_ptr<PCHContainerOperations> PCHs, bool StoreInMemory, + const ParseInputs &Inputs, bool StoreInMemory, PreambleParsedCallback PreambleCallback) { // Note that we don't need to copy the input contents, preamble can live // without those. @@ -534,7 +532,8 @@ buildPreamble(PathRef FileName, Compiler auto StatCache = llvm::make_unique<PreambleFileStatusCache>(AbsFileName); auto BuiltPreamble = PrecompiledPreamble::Build( CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, - StatCache->getProducingFS(Inputs.FS), PCHs, StoreInMemory, + StatCache->getProducingFS(Inputs.FS), + std::make_shared<PCHContainerOperations>(), StoreInMemory, SerializedDeclsCollector); // When building the AST for the main file, we do want the function @@ -560,8 +559,7 @@ buildPreamble(PathRef FileName, Compiler llvm::Optional<ParsedAST> buildAST(PathRef FileName, std::unique_ptr<CompilerInvocation> Invocation, const ParseInputs &Inputs, - std::shared_ptr<const PreambleData> Preamble, - std::shared_ptr<PCHContainerOperations> PCHs) { + std::shared_ptr<const PreambleData> Preamble) { trace::Span Tracer("BuildAST"); SPAN_ATTACH(Tracer, "File", FileName); @@ -577,7 +575,7 @@ buildAST(PathRef FileName, std::unique_p return ParsedAST::build(llvm::make_unique<CompilerInvocation>(*Invocation), Preamble, llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents), - PCHs, std::move(VFS), Inputs.Index, Inputs.Opts); + std::move(VFS), Inputs.Index, Inputs.Opts); } SourceLocation getBeginningOfIdentifier(ParsedAST &Unit, const Position &Pos, Modified: clang-tools-extra/trunk/clangd/ClangdUnit.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.h?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdUnit.h (original) +++ clang-tools-extra/trunk/clangd/ClangdUnit.h Thu Apr 4 05:56:03 2019 @@ -37,7 +37,6 @@ class FileSystem; } // namespace llvm namespace clang { -class PCHContainerOperations; namespace tooling { struct CompileCommand; @@ -73,7 +72,6 @@ public: build(std::unique_ptr<clang::CompilerInvocation> CI, std::shared_ptr<const PreambleData> Preamble, std::unique_ptr<llvm::MemoryBuffer> Buffer, - std::shared_ptr<PCHContainerOperations> PCHs, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, const SymbolIndex *Index, const ParseOptions &Opts); @@ -146,8 +144,7 @@ std::shared_ptr<const PreambleData> buildPreamble(PathRef FileName, CompilerInvocation &CI, std::shared_ptr<const PreambleData> OldPreamble, const tooling::CompileCommand &OldCompileCommand, - const ParseInputs &Inputs, - std::shared_ptr<PCHContainerOperations> PCHs, bool StoreInMemory, + const ParseInputs &Inputs, bool StoreInMemory, PreambleParsedCallback PreambleCallback); /// Build an AST from provided user inputs. This function does not check if @@ -156,8 +153,7 @@ buildPreamble(PathRef FileName, Compiler llvm::Optional<ParsedAST> buildAST(PathRef FileName, std::unique_ptr<CompilerInvocation> Invocation, const ParseInputs &Inputs, - std::shared_ptr<const PreambleData> Preamble, - std::shared_ptr<PCHContainerOperations> PCHs); + std::shared_ptr<const PreambleData> Preamble); /// Get the beginning SourceLocation at a specified \p Pos. /// May be invalid if Pos is, or if there's no identifier. Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Apr 4 05:56:03 2019 @@ -985,7 +985,6 @@ struct SemaCompleteInput { llvm::StringRef Contents; Position Pos; llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS; - std::shared_ptr<PCHContainerOperations> PCHs; }; // Invokes Sema code completion on a file. @@ -1044,8 +1043,7 @@ bool semaCodeComplete(std::unique_ptr<Co std::move(CI), (Input.Preamble && !CompletingInPreamble) ? &Input.Preamble->Preamble : nullptr, - std::move(ContentsBuffer), std::move(Input.PCHs), std::move(VFS), - DummyDiagsConsumer); + std::move(ContentsBuffer), std::move(VFS), DummyDiagsConsumer); Clang->getPreprocessorOpts().SingleFileParseMode = CompletingInPreamble; Clang->setCodeCompletionConsumer(Consumer.release()); @@ -1568,12 +1566,11 @@ CodeCompleteResult codeComplete(PathRef FileName, const tooling::CompileCommand &Command, const PreambleData *Preamble, llvm::StringRef Contents, Position Pos, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, - std::shared_ptr<PCHContainerOperations> PCHs, CodeCompleteOptions Opts, SpeculativeFuzzyFind *SpecFuzzyFind) { return CodeCompleteFlow(FileName, Preamble ? Preamble->Includes : IncludeStructure(), SpecFuzzyFind, Opts) - .run({FileName, Command, Preamble, Contents, Pos, VFS, PCHs}); + .run({FileName, Command, Preamble, Contents, Pos, VFS}); } SignatureHelp signatureHelp(PathRef FileName, @@ -1581,7 +1578,6 @@ SignatureHelp signatureHelp(PathRef File const PreambleData *Preamble, llvm::StringRef Contents, Position Pos, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, - std::shared_ptr<PCHContainerOperations> PCHs, const SymbolIndex *Index) { SignatureHelp Result; clang::CodeCompleteOptions Options; @@ -1592,9 +1588,7 @@ SignatureHelp signatureHelp(PathRef File IncludeStructure PreambleInclusions; // Unused for signatureHelp semaCodeComplete( llvm::make_unique<SignatureHelpCollector>(Options, Index, Result), - Options, - {FileName, Command, Preamble, Contents, Pos, std::move(VFS), - std::move(PCHs)}); + Options, {FileName, Command, Preamble, Contents, Pos, std::move(VFS)}); return Result; } Modified: clang-tools-extra/trunk/clangd/CodeComplete.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.h?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/CodeComplete.h (original) +++ clang-tools-extra/trunk/clangd/CodeComplete.h Thu Apr 4 05:56:03 2019 @@ -35,7 +35,6 @@ namespace clang { class NamedDecl; -class PCHContainerOperations; namespace clangd { struct CodeCompleteOptions { @@ -226,7 +225,6 @@ CodeCompleteResult codeComplete(PathRef const PreambleData *Preamble, StringRef Contents, Position Pos, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, - std::shared_ptr<PCHContainerOperations> PCHs, CodeCompleteOptions Opts, SpeculativeFuzzyFind *SpecFuzzyFind = nullptr); @@ -236,7 +234,6 @@ SignatureHelp signatureHelp(PathRef File const PreambleData *Preamble, StringRef Contents, Position Pos, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, - std::shared_ptr<PCHContainerOperations> PCHs, const SymbolIndex *Index); // For index-based completion, we only consider: Modified: clang-tools-extra/trunk/clangd/Compiler.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Compiler.cpp?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/Compiler.cpp (original) +++ clang-tools-extra/trunk/clangd/Compiler.cpp Thu Apr 4 05:56:03 2019 @@ -10,6 +10,7 @@ #include "Logger.h" #include "clang/Basic/TargetInfo.h" #include "clang/Lex/PreprocessorOptions.h" +#include "clang/Serialization/PCHContainerOperations.h" #include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" @@ -71,7 +72,6 @@ std::unique_ptr<CompilerInstance> prepareCompilerInstance(std::unique_ptr<clang::CompilerInvocation> CI, const PrecompiledPreamble *Preamble, std::unique_ptr<llvm::MemoryBuffer> Buffer, - std::shared_ptr<PCHContainerOperations> PCHs, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, DiagnosticConsumer &DiagsClient) { assert(VFS && "VFS is null"); @@ -88,7 +88,8 @@ prepareCompilerInstance(std::unique_ptr< CI->getFrontendOpts().Inputs[0].getFile(), Buffer.get()); } - auto Clang = llvm::make_unique<CompilerInstance>(PCHs); + auto Clang = llvm::make_unique<CompilerInstance>( + std::make_shared<PCHContainerOperations>()); Clang->setInvocation(std::move(CI)); Clang->createDiagnostics(&DiagsClient, false); Modified: clang-tools-extra/trunk/clangd/Compiler.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Compiler.h?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/Compiler.h (original) +++ clang-tools-extra/trunk/clangd/Compiler.h Thu Apr 4 05:56:03 2019 @@ -67,7 +67,6 @@ buildCompilerInvocation(const ParseInput std::unique_ptr<CompilerInstance> prepareCompilerInstance( std::unique_ptr<clang::CompilerInvocation>, const PrecompiledPreamble *, std::unique_ptr<llvm::MemoryBuffer> MainFile, - std::shared_ptr<PCHContainerOperations>, IntrusiveRefCntPtr<llvm::vfs::FileSystem>, DiagnosticConsumer &); } // namespace clangd Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original) +++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Thu Apr 4 05:56:03 2019 @@ -47,7 +47,6 @@ #include "Trace.h" #include "index/CanonicalIncludes.h" #include "clang/Frontend/CompilerInvocation.h" -#include "clang/Frontend/PCHContainerOperations.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/Support/Errc.h" #include "llvm/Support/Path.h" @@ -157,7 +156,6 @@ class ASTWorker { ASTWorker(PathRef FileName, TUScheduler::ASTCache &LRUCache, Semaphore &Barrier, bool RunSync, steady_clock::duration UpdateDebounce, - std::shared_ptr<PCHContainerOperations> PCHs, bool StorePreamblesInMemory, ParsingCallbacks &Callbacks); public: @@ -170,7 +168,6 @@ public: TUScheduler::ASTCache &IdleASTs, AsyncTaskRunner *Tasks, Semaphore &Barrier, steady_clock::duration UpdateDebounce, - std::shared_ptr<PCHContainerOperations> PCHs, bool StorePreamblesInMemory, ParsingCallbacks &Callbacks); ~ASTWorker(); @@ -236,8 +233,6 @@ private: const bool StorePreambleInMemory; /// Callback invoked when preamble or main file AST is built. ParsingCallbacks &Callbacks; - /// Helper class required to build the ASTs. - const std::shared_ptr<PCHContainerOperations> PCHs; /// Only accessed by the worker thread. TUStatus Status; @@ -314,12 +309,11 @@ ASTWorkerHandle ASTWorker::create(PathRe TUScheduler::ASTCache &IdleASTs, AsyncTaskRunner *Tasks, Semaphore &Barrier, steady_clock::duration UpdateDebounce, - std::shared_ptr<PCHContainerOperations> PCHs, bool StorePreamblesInMemory, ParsingCallbacks &Callbacks) { - std::shared_ptr<ASTWorker> Worker(new ASTWorker( - FileName, IdleASTs, Barrier, /*RunSync=*/!Tasks, UpdateDebounce, - std::move(PCHs), StorePreamblesInMemory, Callbacks)); + std::shared_ptr<ASTWorker> Worker( + new ASTWorker(FileName, IdleASTs, Barrier, /*RunSync=*/!Tasks, + UpdateDebounce, StorePreamblesInMemory, Callbacks)); if (Tasks) Tasks->runAsync("worker:" + llvm::sys::path::filename(FileName), [Worker]() { Worker->run(); }); @@ -330,13 +324,11 @@ ASTWorkerHandle ASTWorker::create(PathRe ASTWorker::ASTWorker(PathRef FileName, TUScheduler::ASTCache &LRUCache, Semaphore &Barrier, bool RunSync, steady_clock::duration UpdateDebounce, - std::shared_ptr<PCHContainerOperations> PCHs, bool StorePreamblesInMemory, ParsingCallbacks &Callbacks) : IdleASTs(LRUCache), RunSync(RunSync), UpdateDebounce(UpdateDebounce), FileName(FileName), StorePreambleInMemory(StorePreamblesInMemory), - Callbacks(Callbacks), - PCHs(std::move(PCHs)), Status{TUAction(TUAction::Idle, ""), - TUStatus::BuildDetails()}, + Callbacks(Callbacks), Status{TUAction(TUAction::Idle, ""), + TUStatus::BuildDetails()}, Barrier(Barrier), Done(false) {} ASTWorker::~ASTWorker() { @@ -384,7 +376,7 @@ void ASTWorker::update(ParseInputs Input std::shared_ptr<const PreambleData> OldPreamble = getPossiblyStalePreamble(); std::shared_ptr<const PreambleData> NewPreamble = buildPreamble( - FileName, *Invocation, OldPreamble, OldCommand, Inputs, PCHs, + FileName, *Invocation, OldPreamble, OldCommand, Inputs, StorePreambleInMemory, [this](ASTContext &Ctx, std::shared_ptr<clang::Preprocessor> PP, const CanonicalIncludes &CanonIncludes) { @@ -441,7 +433,7 @@ void ASTWorker::update(ParseInputs Input llvm::Optional<std::unique_ptr<ParsedAST>> AST = IdleASTs.take(this); if (!AST) { llvm::Optional<ParsedAST> NewAST = - buildAST(FileName, std::move(Invocation), Inputs, NewPreamble, PCHs); + buildAST(FileName, std::move(Invocation), Inputs, NewPreamble); AST = NewAST ? llvm::make_unique<ParsedAST>(std::move(*NewAST)) : nullptr; if (!(*AST)) { // buildAST fails. TUStatus::BuildDetails Details; @@ -489,7 +481,7 @@ void ASTWorker::runWithAST( Invocation ? buildAST(FileName, llvm::make_unique<CompilerInvocation>(*Invocation), - FileInputs, getPossiblyStalePreamble(), PCHs) + FileInputs, getPossiblyStalePreamble()) : None; AST = NewAST ? llvm::make_unique<ParsedAST>(std::move(*NewAST)) : nullptr; } @@ -790,7 +782,6 @@ TUScheduler::TUScheduler(unsigned AsyncT std::chrono::steady_clock::duration UpdateDebounce, ASTRetentionPolicy RetentionPolicy) : StorePreamblesInMemory(StorePreamblesInMemory), - PCHOps(std::make_shared<PCHContainerOperations>()), Callbacks(Callbacks ? move(Callbacks) : llvm::make_unique<ParsingCallbacks>()), Barrier(AsyncThreadsCount), @@ -830,7 +821,7 @@ void TUScheduler::update(PathRef File, P // Create a new worker to process the AST-related tasks. ASTWorkerHandle Worker = ASTWorker::create( File, *IdleASTs, WorkerThreads ? WorkerThreads.getPointer() : nullptr, - Barrier, UpdateDebounce, PCHOps, StorePreamblesInMemory, *Callbacks); + Barrier, UpdateDebounce, StorePreamblesInMemory, *Callbacks); FD = std::unique_ptr<FileData>(new FileData{ Inputs.Contents, Inputs.CompileCommand, std::move(Worker)}); } else { Modified: clang-tools-extra/trunk/clangd/TUScheduler.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.h?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/TUScheduler.h (original) +++ clang-tools-extra/trunk/clangd/TUScheduler.h Thu Apr 4 05:56:03 2019 @@ -211,7 +211,6 @@ public: private: const bool StorePreamblesInMemory; - const std::shared_ptr<PCHContainerOperations> PCHOps; std::unique_ptr<ParsingCallbacks> Callbacks; // not nullptr Semaphore Barrier; llvm::StringMap<std::unique_ptr<FileData>> Files; Modified: clang-tools-extra/trunk/clangd/index/Background.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/index/Background.cpp (original) +++ clang-tools-extra/trunk/clangd/index/Background.cpp Thu Apr 4 05:56:03 2019 @@ -409,9 +409,8 @@ llvm::Error BackgroundIndex::index(tooli return llvm::createStringError(llvm::inconvertibleErrorCode(), "Couldn't build compiler invocation"); IgnoreDiagnostics IgnoreDiags; - auto Clang = prepareCompilerInstance( - std::move(CI), /*Preamble=*/nullptr, std::move(*Buf), - std::make_shared<PCHContainerOperations>(), Inputs.FS, IgnoreDiags); + auto Clang = prepareCompilerInstance(std::move(CI), /*Preamble=*/nullptr, + std::move(*Buf), Inputs.FS, IgnoreDiags); if (!Clang) return llvm::createStringError(llvm::inconvertibleErrorCode(), "Couldn't build compiler instance"); Modified: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp Thu Apr 4 05:56:03 2019 @@ -16,7 +16,6 @@ #include "index/FileIndex.h" #include "index/Index.h" #include "clang/Frontend/CompilerInvocation.h" -#include "clang/Frontend/PCHContainerOperations.h" #include "clang/Frontend/Utils.h" #include "clang/Index/IndexSymbol.h" #include "clang/Lex/Preprocessor.h" @@ -231,14 +230,14 @@ TEST(FileIndexTest, HasSystemHeaderMappi // Prepare preamble. auto CI = buildCompilerInvocation(PI); - auto PreambleData = buildPreamble( - MainFile, *buildCompilerInvocation(PI), /*OldPreamble=*/nullptr, - tooling::CompileCommand(), PI, std::make_shared<PCHContainerOperations>(), - /*StoreInMemory=*/true, - [&](ASTContext &Ctx, std::shared_ptr<Preprocessor> PP, - const CanonicalIncludes &Includes) { - Index.updatePreamble(MainFile, Ctx, PP, Includes); - }); + auto PreambleData = + buildPreamble(MainFile, *buildCompilerInvocation(PI), + /*OldPreamble=*/nullptr, tooling::CompileCommand(), PI, + /*StoreInMemory=*/true, + [&](ASTContext &Ctx, std::shared_ptr<Preprocessor> PP, + const CanonicalIncludes &Includes) { + Index.updatePreamble(MainFile, Ctx, PP, Includes); + }); auto Symbols = runFuzzyFind(Index, ""); EXPECT_THAT(Symbols, ElementsAre(_)); EXPECT_THAT(Symbols.begin()->IncludeHeaders.front().IncludeHeader, @@ -306,7 +305,7 @@ TEST(FileIndexTest, RebuildWithPreamble) bool IndexUpdated = false; buildPreamble( FooCpp, *CI, /*OldPreamble=*/nullptr, tooling::CompileCommand(), PI, - std::make_shared<PCHContainerOperations>(), /*StoreInMemory=*/true, + /*StoreInMemory=*/true, [&](ASTContext &Ctx, std::shared_ptr<Preprocessor> PP, const CanonicalIncludes &CanonIncludes) { EXPECT_FALSE(IndexUpdated) << "Expected only a single index update"; @@ -392,17 +391,16 @@ TEST(FileIndexTest, ReferencesInMainFile // Prepare preamble. auto CI = buildCompilerInvocation(PI); - auto PreambleData = buildPreamble( - MainFile, *buildCompilerInvocation(PI), /*OldPreamble=*/nullptr, - tooling::CompileCommand(), PI, std::make_shared<PCHContainerOperations>(), - /*StoreInMemory=*/true, - [&](ASTContext &Ctx, std::shared_ptr<Preprocessor> PP, - const CanonicalIncludes &) {}); + auto PreambleData = + buildPreamble(MainFile, *buildCompilerInvocation(PI), + /*OldPreamble=*/nullptr, tooling::CompileCommand(), PI, + /*StoreInMemory=*/true, + [&](ASTContext &Ctx, std::shared_ptr<Preprocessor> PP, + const CanonicalIncludes &) {}); // Build AST for main file with preamble. auto AST = ParsedAST::build(createInvocationFromCommandLine(Cmd), PreambleData, - llvm::MemoryBuffer::getMemBufferCopy(Main.code()), - std::make_shared<PCHContainerOperations>(), PI.FS, + llvm::MemoryBuffer::getMemBufferCopy(Main.code()), PI.FS, /*Index=*/nullptr, ParseOptions()); ASSERT_TRUE(AST); FileIndex Index; Modified: clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/HeadersTests.cpp Thu Apr 4 05:56:03 2019 @@ -51,8 +51,8 @@ private: CI->getDiagnosticOpts().IgnoreWarnings = true; auto Clang = prepareCompilerInstance( std::move(CI), /*Preamble=*/nullptr, - llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile), - std::make_shared<PCHContainerOperations>(), VFS, IgnoreDiags); + llvm::MemoryBuffer::getMemBuffer(FS.Files[MainFile], MainFile), VFS, + IgnoreDiags); EXPECT_FALSE(Clang->getFrontendOpts().Inputs.empty()); return Clang; Modified: clang-tools-extra/trunk/unittests/clangd/TestTU.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TestTU.cpp?rev=357689&r1=357688&r2=357689&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/TestTU.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/TestTU.cpp Thu Apr 4 05:56:03 2019 @@ -12,7 +12,6 @@ #include "index/MemIndex.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Frontend/CompilerInvocation.h" -#include "clang/Frontend/PCHContainerOperations.h" #include "clang/Frontend/Utils.h" namespace clang { @@ -40,16 +39,15 @@ ParsedAST TestTU::build() const { Inputs.Index = ExternalIndex; if (Inputs.Index) Inputs.Opts.SuggestMissingIncludes = true; - auto PCHs = std::make_shared<PCHContainerOperations>(); auto CI = buildCompilerInvocation(Inputs); assert(CI && "Failed to build compilation invocation."); auto Preamble = buildPreamble(FullFilename, *CI, /*OldPreamble=*/nullptr, - /*OldCompileCommand=*/Inputs.CompileCommand, Inputs, PCHs, + /*OldCompileCommand=*/Inputs.CompileCommand, Inputs, /*StoreInMemory=*/true, /*PreambleCallback=*/nullptr); auto AST = buildAST(FullFilename, createInvocationFromCommandLine(Cmd), - Inputs, Preamble, PCHs); + Inputs, Preamble); if (!AST.hasValue()) { ADD_FAILURE() << "Failed to build code:\n" << Code; llvm_unreachable("Failed to build TestTU!"); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits