diff options
Diffstat (limited to 'clang/include')
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSerializationKinds.td | 5 | ||||
| -rw-r--r-- | clang/include/clang/Basic/MemoryBufferCache.h | 80 | ||||
| -rw-r--r-- | clang/include/clang/Frontend/ASTUnit.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/Frontend/CompilerInstance.h | 8 | ||||
| -rw-r--r-- | clang/include/clang/Lex/Preprocessor.h | 4 | ||||
| -rw-r--r-- | clang/include/clang/Serialization/ASTReader.h | 3 | ||||
| -rw-r--r-- | clang/include/clang/Serialization/ASTWriter.h | 5 | ||||
| -rw-r--r-- | clang/include/clang/Serialization/Module.h | 6 | ||||
| -rw-r--r-- | clang/include/clang/Serialization/ModuleManager.h | 8 |
9 files changed, 5 insertions, 116 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td b/clang/include/clang/Basic/DiagnosticSerializationKinds.td index 4af4c18ced3..d6e040a4427 100644 --- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td +++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td @@ -176,11 +176,6 @@ def warn_duplicate_module_file_extension : Warning< "duplicate module file extension block name '%0'">, InGroup<ModuleFileExtension>; -def warn_module_system_bit_conflict : Warning< - "module file '%0' was validated as a system module and is now being imported " - "as a non-system module; any difference in diagnostic options will be ignored">, - InGroup<ModuleConflict>; - } // let CategoryName } // let Component diff --git a/clang/include/clang/Basic/MemoryBufferCache.h b/clang/include/clang/Basic/MemoryBufferCache.h deleted file mode 100644 index c79c3c40e4e..00000000000 --- a/clang/include/clang/Basic/MemoryBufferCache.h +++ /dev/null @@ -1,80 +0,0 @@ -//===- MemoryBufferCache.h - Cache for loaded memory buffers ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_BASIC_MEMORYBUFFERCACHE_H -#define LLVM_CLANG_BASIC_MEMORYBUFFERCACHE_H - -#include "llvm/ADT/IntrusiveRefCntPtr.h" -#include "llvm/ADT/StringMap.h" -#include <memory> - -namespace llvm { -class MemoryBuffer; -} // end namespace llvm - -namespace clang { - -/// Manage memory buffers across multiple users. -/// -/// Ensures that multiple users have a consistent view of each buffer. This is -/// used by \a CompilerInstance when building PCMs to ensure that each \a -/// ModuleManager sees the same files. -/// -/// \a finalizeCurrentBuffers() should be called before creating a new user. -/// This locks in the current buffers, ensuring that no buffer that has already -/// been accessed can be purged, preventing use-after-frees. -class MemoryBufferCache : public llvm::RefCountedBase<MemoryBufferCache> { - struct BufferEntry { - std::unique_ptr<llvm::MemoryBuffer> Buffer; - - /// Track the timeline of when this was added to the cache. - unsigned Index; - }; - - /// Cache of buffers. - llvm::StringMap<BufferEntry> Buffers; - - /// Monotonically increasing index. - unsigned NextIndex = 0; - - /// Bumped to prevent "older" buffers from being removed. - unsigned FirstRemovableIndex = 0; - -public: - /// Store the Buffer under the Filename. - /// - /// \pre There is not already buffer is not already in the cache. - /// \return a reference to the buffer as a convenience. - llvm::MemoryBuffer &addBuffer(llvm::StringRef Filename, - std::unique_ptr<llvm::MemoryBuffer> Buffer); - - /// Try to remove a buffer from the cache. - /// - /// \return false on success, iff \c !isBufferFinal(). - bool tryToRemoveBuffer(llvm::StringRef Filename); - - /// Get a pointer to the buffer if it exists; else nullptr. - llvm::MemoryBuffer *lookupBuffer(llvm::StringRef Filename); - - /// Check whether the buffer is final. - /// - /// \return true iff \a finalizeCurrentBuffers() has been called since the - /// buffer was added. This prevents buffers from being removed. - bool isBufferFinal(llvm::StringRef Filename); - - /// Finalize the current buffers in the cache. - /// - /// Should be called when creating a new user to ensure previous uses aren't - /// invalidated. - void finalizeCurrentBuffers(); -}; - -} // end namespace clang - -#endif // LLVM_CLANG_BASIC_MEMORYBUFFERCACHE_H diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h index 2a8df1b7b9a..03961f1a3c4 100644 --- a/clang/include/clang/Frontend/ASTUnit.h +++ b/clang/include/clang/Frontend/ASTUnit.h @@ -51,7 +51,6 @@ class DiagnosticsEngine; class FileEntry; class FileManager; class HeaderSearch; -class MemoryBufferCache; class Preprocessor; class PCHContainerOperations; class PCHContainerReader; @@ -85,7 +84,6 @@ private: IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics; IntrusiveRefCntPtr<FileManager> FileMgr; IntrusiveRefCntPtr<SourceManager> SourceMgr; - IntrusiveRefCntPtr<MemoryBufferCache> PCMCache; std::unique_ptr<HeaderSearch> HeaderInfo; IntrusiveRefCntPtr<TargetInfo> Target; std::shared_ptr<Preprocessor> PP; diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h index bdcec5470a5..91d9198ddf6 100644 --- a/clang/include/clang/Frontend/CompilerInstance.h +++ b/clang/include/clang/Frontend/CompilerInstance.h @@ -44,7 +44,6 @@ class ExternalASTSource; class FileEntry; class FileManager; class FrontendAction; -class MemoryBufferCache; class Module; class Preprocessor; class Sema; @@ -91,9 +90,6 @@ class CompilerInstance : public ModuleLoader { /// The source manager. IntrusiveRefCntPtr<SourceManager> SourceMgr; - /// The cache of PCM files. - IntrusiveRefCntPtr<MemoryBufferCache> PCMCache; - /// The preprocessor. std::shared_ptr<Preprocessor> PP; @@ -182,7 +178,7 @@ public: explicit CompilerInstance( std::shared_ptr<PCHContainerOperations> PCHContainerOps = std::make_shared<PCHContainerOperations>(), - MemoryBufferCache *SharedPCMCache = nullptr); + bool BuildingModule = false); ~CompilerInstance() override; /// @name High-Level Operations @@ -787,8 +783,6 @@ public: } void setExternalSemaSource(IntrusiveRefCntPtr<ExternalSemaSource> ESS); - - MemoryBufferCache &getPCMCache() const { return *PCMCache; } }; } // end namespace clang diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 3efe914daae..26efa8b8a10 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -47,7 +47,6 @@ class ExternalPreprocessorSource; class FileManager; class FileEntry; class HeaderSearch; -class MemoryBufferCache; class PragmaNamespace; class PragmaHandler; class CommentHandler; @@ -103,7 +102,6 @@ class Preprocessor { const TargetInfo *AuxTarget; FileManager &FileMgr; SourceManager &SourceMgr; - MemoryBufferCache &PCMCache; std::unique_ptr<ScratchBuffer> ScratchBuf; HeaderSearch &HeaderInfo; ModuleLoader &TheModuleLoader; @@ -654,7 +652,6 @@ class Preprocessor { public: Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts, DiagnosticsEngine &diags, LangOptions &opts, SourceManager &SM, - MemoryBufferCache &PCMCache, HeaderSearch &Headers, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup = nullptr, bool OwnsHeaderSearch = false, @@ -694,7 +691,6 @@ public: const TargetInfo *getAuxTargetInfo() const { return AuxTarget; } FileManager &getFileManager() const { return FileMgr; } SourceManager &getSourceManager() const { return SourceMgr; } - MemoryBufferCache &getPCMCache() const { return PCMCache; } HeaderSearch &getHeaderSearchInfo() const { return HeaderInfo; } IdentifierTable &getIdentifierTable() { return Identifiers; } diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index cdca2eebcf7..5a1514ad807 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -408,9 +408,6 @@ private: /// \brief The module manager which manages modules and their dependencies ModuleManager ModuleMgr; - /// The cache that manages memory buffers for PCM files. - MemoryBufferCache &PCMCache; - /// \brief A dummy identifier resolver used to merge TU-scope declarations in /// C, for the cases where we don't have a Sema object to provide a real /// identifier resolver. diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h index 4d45c75c8d2..f3c644b9e21 100644 --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -54,7 +54,6 @@ class MacroInfo; class OpaqueValueExpr; class OpenCLOptions; class ASTReader; -class MemoryBufferCache; class Module; class ModuleFileExtension; class ModuleFileExtensionWriter; @@ -110,9 +109,6 @@ private: /// The buffer associated with the bitstream. const SmallVectorImpl<char> &Buffer; - /// \brief The PCM manager which manages memory buffers for pcm files. - MemoryBufferCache &PCMCache; - /// \brief The ASTContext we're writing. ASTContext *Context = nullptr; @@ -516,7 +512,6 @@ public: /// \brief Create a new precompiled header writer that outputs to /// the given bitstream. ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl<char> &Buffer, - MemoryBufferCache &PCMCache, ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions, bool IncludeTimestamps = true); ~ASTWriter() override; diff --git a/clang/include/clang/Serialization/Module.h b/clang/include/clang/Serialization/Module.h index 4e4bf44f349..c1d4a9fd2dd 100644 --- a/clang/include/clang/Serialization/Module.h +++ b/clang/include/clang/Serialization/Module.h @@ -163,9 +163,9 @@ public: /// \brief The generation of which this module file is a part. unsigned Generation; - /// The memory buffer that stores the data associated with - /// this AST file, owned by the PCMCache in the ModuleManager. - llvm::MemoryBuffer *Buffer; + /// \brief The memory buffer that stores the data associated with + /// this AST file. + std::unique_ptr<llvm::MemoryBuffer> Buffer; /// \brief The size of this file, in bits. uint64_t SizeInBits = 0; diff --git a/clang/include/clang/Serialization/ModuleManager.h b/clang/include/clang/Serialization/ModuleManager.h index fae387cac7e..70c9d9e5407 100644 --- a/clang/include/clang/Serialization/ModuleManager.h +++ b/clang/include/clang/Serialization/ModuleManager.h @@ -24,7 +24,6 @@ namespace clang { class GlobalModuleIndex; -class MemoryBufferCache; class ModuleMap; class PCHContainerReader; @@ -52,9 +51,6 @@ class ModuleManager { /// FileEntry *. FileManager &FileMgr; - /// Cache of PCM files. - IntrusiveRefCntPtr<MemoryBufferCache> PCMCache; - /// \brief Knows how to unwrap module containers. const PCHContainerReader &PCHContainerRdr; @@ -127,7 +123,7 @@ public: ModuleReverseIterator; typedef std::pair<uint32_t, StringRef> ModuleOffset; - explicit ModuleManager(FileManager &FileMgr, MemoryBufferCache &PCMCache, + explicit ModuleManager(FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr); ~ModuleManager(); @@ -294,8 +290,6 @@ public: /// \brief View the graphviz representation of the module graph. void viewGraph(); - - MemoryBufferCache &getPCMCache() const { return *PCMCache; } }; } } // end namespace clang::serialization |

