clang
8.0.0
|
Manage memory buffers across multiple users. More...
#include "clang/Basic/MemoryBufferCache.h"
Public Member Functions | |
llvm::MemoryBuffer & | addBuffer (llvm::StringRef Filename, std::unique_ptr< llvm::MemoryBuffer > Buffer) |
Store the Buffer under the Filename. More... | |
bool | tryToRemoveBuffer (llvm::StringRef Filename) |
Try to remove a buffer from the cache. More... | |
llvm::MemoryBuffer * | lookupBuffer (llvm::StringRef Filename) |
Get a pointer to the buffer if it exists; else nullptr. More... | |
bool | isBufferFinal (llvm::StringRef Filename) |
Check whether the buffer is final. More... | |
void | finalizeCurrentBuffers () |
Finalize the current buffers in the cache. More... | |
Manage memory buffers across multiple users.
Ensures that multiple users have a consistent view of each buffer. This is used by CompilerInstance when building PCMs to ensure that each ModuleManager sees the same files.
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.
Definition at line 32 of file MemoryBufferCache.h.
llvm::MemoryBuffer & MemoryBufferCache::addBuffer | ( | llvm::StringRef | Filename, |
std::unique_ptr< llvm::MemoryBuffer > | Buffer | ||
) |
Store the Buffer under the Filename.
Definition at line 16 of file MemoryBufferCache.cpp.
References Filename.
Referenced by clang::ASTWriter::WriteAST().
void MemoryBufferCache::finalizeCurrentBuffers | ( | ) |
Finalize the current buffers in the cache.
Should be called when creating a new user to ensure previous uses aren't invalidated.
Definition at line 48 of file MemoryBufferCache.cpp.
Referenced by clang::CompilerInstance::CompilerInstance().
bool MemoryBufferCache::isBufferFinal | ( | llvm::StringRef | Filename | ) |
Check whether the buffer is final.
Definition at line 31 of file MemoryBufferCache.cpp.
llvm::MemoryBuffer * MemoryBufferCache::lookupBuffer | ( | llvm::StringRef | Filename | ) |
Get a pointer to the buffer if it exists; else nullptr.
Definition at line 24 of file MemoryBufferCache.cpp.
bool MemoryBufferCache::tryToRemoveBuffer | ( | llvm::StringRef | Filename | ) |
Try to remove a buffer from the cache.
!isBufferFinal
(). Definition at line 38 of file MemoryBufferCache.cpp.