diff --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp --- a/clang-tools-extra/clangd/Preamble.cpp +++ b/clang-tools-extra/clangd/Preamble.cpp @@ -378,8 +378,7 @@ auto VFS = Inputs.TFS->view(Inputs.CompileCommand.Directory); return compileCommandsAreEqual(Inputs.CompileCommand, Preamble.CompileCommand) && - Preamble.Preamble.CanReuse(CI, ContentsBuffer.get(), Bounds, - VFS.get()); + Preamble.Preamble.CanReuse(CI, *ContentsBuffer, Bounds, *VFS); } void escapeBackslashAndQuotes(llvm::StringRef Text, llvm::raw_ostream &OS) { diff --git a/clang/include/clang/Frontend/PrecompiledPreamble.h b/clang/include/clang/Frontend/PrecompiledPreamble.h --- a/clang/include/clang/Frontend/PrecompiledPreamble.h +++ b/clang/include/clang/Frontend/PrecompiledPreamble.h @@ -105,8 +105,8 @@ /// Check whether PrecompiledPreamble can be reused for the new contents(\p /// MainFileBuffer) of the main file. bool CanReuse(const CompilerInvocation &Invocation, - const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds, - llvm::vfs::FileSystem *VFS) const; + const llvm::MemoryBufferRef &MainFileBuffer, + PreambleBounds Bounds, llvm::vfs::FileSystem &VFS) const; /// Changes options inside \p CI to use PCH from this preamble. Also remaps /// main file to \p MainFileBuffer and updates \p VFS to ensure the preamble diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -1317,8 +1317,8 @@ return nullptr; if (Preamble) { - if (Preamble->CanReuse(PreambleInvocationIn, MainFileBuffer.get(), Bounds, - VFS.get())) { + if (Preamble->CanReuse(PreambleInvocationIn, *MainFileBuffer, Bounds, + *VFS)) { // Okay! We can re-use the precompiled preamble. // Set the state of the diagnostic object to mimic its state diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp --- a/clang/lib/Frontend/PrecompiledPreamble.cpp +++ b/clang/lib/Frontend/PrecompiledPreamble.cpp @@ -501,12 +501,12 @@ } bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation, - const llvm::MemoryBuffer *MainFileBuffer, + const llvm::MemoryBufferRef &MainFileBuffer, PreambleBounds Bounds, - llvm::vfs::FileSystem *VFS) const { + llvm::vfs::FileSystem &VFS) const { assert( - Bounds.Size <= MainFileBuffer->getBufferSize() && + Bounds.Size <= MainFileBuffer.getBufferSize() && "Buffer is too large. Bounds were calculated from a different buffer?"); auto PreambleInvocation = std::make_shared(Invocation); @@ -520,7 +520,7 @@ if (PreambleBytes.size() != Bounds.Size || PreambleEndsAtStartOfLine != Bounds.PreambleEndsAtStartOfLine || !std::equal(PreambleBytes.begin(), PreambleBytes.end(), - MainFileBuffer->getBuffer().begin())) + MainFileBuffer.getBuffer().begin())) return false; // The preamble has not changed. We may be able to re-use the precompiled // preamble. @@ -532,14 +532,14 @@ llvm::StringSet<> OverriddenAbsPaths; // Either by buffers or files. for (const auto &R : PreprocessorOpts.RemappedFiles) { llvm::vfs::Status Status; - if (!moveOnNoError(VFS->status(R.second), Status)) { + if (!moveOnNoError(VFS.status(R.second), Status)) { // If we can't stat the file we're remapping to, assume that something // horrible happened. return false; } // If a mapped file was previously missing, then it has changed. llvm::SmallString<128> MappedPath(R.first); - if (!VFS->makeAbsolute(MappedPath)) + if (!VFS.makeAbsolute(MappedPath)) OverriddenAbsPaths.insert(MappedPath); OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile( @@ -552,13 +552,13 @@ const PrecompiledPreamble::PreambleFileHash PreambleHash = PreambleFileHash::createForMemoryBuffer(RB.second->getMemBufferRef()); llvm::vfs::Status Status; - if (moveOnNoError(VFS->status(RB.first), Status)) + if (moveOnNoError(VFS.status(RB.first), Status)) OverriddenFiles[Status.getUniqueID()] = PreambleHash; else OverridenFileBuffers[RB.first] = PreambleHash; llvm::SmallString<128> MappedPath(RB.first); - if (!VFS->makeAbsolute(MappedPath)) + if (!VFS.makeAbsolute(MappedPath)) OverriddenAbsPaths.insert(MappedPath); } @@ -574,7 +574,7 @@ } llvm::vfs::Status Status; - if (!moveOnNoError(VFS->status(F.first()), Status)) { + if (!moveOnNoError(VFS.status(F.first()), Status)) { // If the file's buffer is not remapped and we can't stat it, // assume that something horrible happened. return false; @@ -603,7 +603,7 @@ return false; // If a file previously recorded as missing exists as a regular file, then // consider the preamble out-of-date. - if (auto Status = VFS->status(F.getKey())) { + if (auto Status = VFS.status(F.getKey())) { if (Status->isRegularFile()) return false; }