clang
8.0.0
|
One instance of this struct is kept for every file loaded or used. More...
#include "clang/Basic/SourceManager.h"
Public Member Functions | |
ContentCache (const FileEntry *Ent=nullptr) | |
ContentCache (const FileEntry *Ent, const FileEntry *contentEnt) | |
ContentCache (const ContentCache &RHS) | |
The copy ctor does not allow copies where source object has either a non-NULL Buffer or SourceLineCache. More... | |
ContentCache & | operator= (const ContentCache &RHS)=delete |
~ContentCache () | |
llvm::MemoryBuffer * | getBuffer (DiagnosticsEngine &Diag, const SourceManager &SM, SourceLocation Loc=SourceLocation(), bool *Invalid=nullptr) const |
Returns the memory buffer for the associated content. More... | |
unsigned | getSize () const |
Returns the size of the content encapsulated by this ContentCache. More... | |
unsigned | getSizeBytesMapped () const |
Returns the number of bytes actually mapped for this ContentCache. More... | |
llvm::MemoryBuffer::BufferKind | getMemoryBufferKind () const |
Returns the kind of memory used to back the memory buffer for this content cache. More... | |
llvm::MemoryBuffer * | getRawBuffer () const |
Get the underlying buffer, returning NULL if the buffer is not yet available. More... | |
void | replaceBuffer (llvm::MemoryBuffer *B, bool DoNotFree=false) |
Replace the existing buffer (which will be deleted) with the given buffer. More... | |
bool | isBufferInvalid () const |
Determine whether the buffer itself is invalid. More... | |
bool | shouldFreeBuffer () const |
Determine whether the buffer should be freed. More... | |
Public Attributes | |
const FileEntry * | OrigEntry |
Reference to the file entry representing this ContentCache. More... | |
const FileEntry * | ContentsEntry |
References the file which the contents were actually loaded from. More... | |
unsigned * | SourceLineCache = nullptr |
A bump pointer allocated array of offsets for each source line. More... | |
unsigned | NumLines = 0 |
The number of lines in this ContentCache. More... | |
unsigned | BufferOverridden: 1 |
Indicates whether the buffer itself was provided to override the actual file contents. More... | |
unsigned | IsSystemFile: 1 |
True if this content cache was initially created for a source file considered as a system one. More... | |
unsigned | IsTransient: 1 |
True if this file may be transient, that is, if it might not exist at some later point in time when this content entry is used, after serialization and deserialization. More... | |
One instance of this struct is kept for every file loaded or used.
This object owns the MemoryBuffer object.
Definition at line 95 of file SourceManager.h.
|
inline |
Definition at line 153 of file SourceManager.h.
|
inline |
Definition at line 155 of file SourceManager.h.
|
inline |
The copy ctor does not allow copies where source object has either a non-NULL Buffer or SourceLineCache.
Ownership of allocated memory is not transferred, so this is a logical error.
Definition at line 162 of file SourceManager.h.
References ContentsEntry, Diag(), getBuffer(), getMemoryBufferKind(), getSize(), getSizeBytesMapped(), NumLines, operator=(), OrigEntry, SM, SourceLineCache, and ~ContentCache().
ContentCache::~ContentCache | ( | ) |
Definition at line 53 of file SourceManager.cpp.
References shouldFreeBuffer().
Referenced by ContentCache().
llvm::MemoryBuffer * ContentCache::getBuffer | ( | DiagnosticsEngine & | Diag, |
const SourceManager & | SM, | ||
SourceLocation | Loc = SourceLocation() , |
||
bool * | Invalid = nullptr |
||
) | const |
Returns the memory buffer for the associated content.
Diag | Object through which diagnostics will be emitted if the buffer cannot be retrieved. |
Loc | If specified, is the location that invalid file diagnostics will be emitted at. |
Invalid | If non-NULL, will be set true if an error occurred. |
Definition at line 99 of file SourceManager.cpp.
References ContentsEntry, clang::FileManager::getBufferForFile(), clang::SourceManager::getFileManager(), clang::FileEntry::getName(), getRawBuffer(), clang::FileEntry::getSize(), isBufferInvalid(), clang::DiagnosticsEngine::isDiagnosticInFlight(), IsSystemFile, clang::DiagnosticsEngine::Report(), clang::DiagnosticsEngine::SetDelayedDiagnostic(), and clang::SourceManager::userFilesAreVolatile().
Referenced by ComputeLineNumbers(), ContentCache(), emitBlob(), clang::SourceManager::getBuffer(), clang::SourceManager::getBufferData(), clang::SourceManager::getCharacterData(), clang::SourceManager::getMemoryBufferForFile(), clang::SourceManager::getPresumedLoc(), and clang::SourceManager::translateLineCol().
llvm::MemoryBuffer::BufferKind ContentCache::getMemoryBufferKind | ( | ) | const |
Returns the kind of memory used to back the memory buffer for this content cache.
This is used for performance analysis.
Definition at line 66 of file SourceManager.cpp.
Referenced by ContentCache().
|
inline |
Get the underlying buffer, returning NULL if the buffer is not yet available.
Definition at line 213 of file SourceManager.h.
References replaceBuffer().
Referenced by getBuffer().
unsigned ContentCache::getSize | ( | ) | const |
Returns the size of the content encapsulated by this ContentCache.
getSize - Returns the size of the content encapsulated by this ContentCache.
This can be the size of the source file or the size of an arbitrary scratch buffer. If the ContentCache encapsulates a source file this size is retrieved from the file's FileEntry.
This can be the size of the source file or the size of an arbitrary scratch buffer. If the ContentCache encapsulates a source file, that file is not lazily brought in from disk to satisfy this query.
Definition at line 81 of file SourceManager.cpp.
References ContentsEntry, and clang::FileEntry::getSize().
Referenced by ContentCache().
unsigned ContentCache::getSizeBytesMapped | ( | ) | const |
Returns the number of bytes actually mapped for this ContentCache.
getSizeBytesMapped - Returns the number of bytes actually mapped for this ContentCache.
This can be 0 if the MemBuffer was not actually expanded.
Definition at line 60 of file SourceManager.cpp.
Referenced by ContentCache().
|
inline |
Determine whether the buffer itself is invalid.
Definition at line 220 of file SourceManager.h.
Referenced by getBuffer().
|
delete |
Referenced by ContentCache().
Replace the existing buffer (which will be deleted) with the given buffer.
Definition at line 86 of file SourceManager.cpp.
References shouldFreeBuffer().
Referenced by getRawBuffer(), and clang::SourceManager::initializeForReplay().
|
inline |
Determine whether the buffer should be freed.
Definition at line 225 of file SourceManager.h.
Referenced by replaceBuffer(), and ~ContentCache().
unsigned clang::SrcMgr::ContentCache::BufferOverridden |
Indicates whether the buffer itself was provided to override the actual file contents.
When true, the original entry may be a virtual file that does not exist.
Definition at line 142 of file SourceManager.h.
Referenced by emitBlob().
const FileEntry* clang::SrcMgr::ContentCache::ContentsEntry |
References the file which the contents were actually loaded from.
Can be different from 'Entry' if we overridden the contents of one file with the contents of another file.
Definition at line 124 of file SourceManager.h.
Referenced by ContentCache(), emitBlob(), getBuffer(), and getSize().
unsigned clang::SrcMgr::ContentCache::IsSystemFile |
True if this content cache was initially created for a source file considered as a system one.
Definition at line 146 of file SourceManager.h.
Referenced by getBuffer(), and clang::SourceManager::initializeForReplay().
unsigned clang::SrcMgr::ContentCache::IsTransient |
True if this file may be transient, that is, if it might not exist at some later point in time when this content entry is used, after serialization and deserialization.
Definition at line 151 of file SourceManager.h.
Referenced by emitBlob(), and clang::SourceManager::initializeForReplay().
unsigned clang::SrcMgr::ContentCache::NumLines = 0 |
The number of lines in this ContentCache.
This is only valid if SourceLineCache is non-null.
Definition at line 135 of file SourceManager.h.
Referenced by ComputeLineNumbers(), ContentCache(), clang::SourceManager::getLineNumber(), and clang::SourceManager::translateLineCol().
const FileEntry* clang::SrcMgr::ContentCache::OrigEntry |
Reference to the file entry representing this ContentCache.
This reference does not own the FileEntry object.
It is possible for this to be NULL if the ContentCache encapsulates an imaginary text buffer.
Definition at line 118 of file SourceManager.h.
Referenced by ContentCache(), clang::SourceManager::disableFileContentsOverride(), emitBlob(), clang::SourceManager::getFileEntryForID(), clang::SourceManager::getFileEntryForSLocEntry(), clang::SourceManager::getPresumedLoc(), clang::SourceManager::initializeForReplay(), and clang::SourceManager::translateFile().
unsigned* clang::SrcMgr::ContentCache::SourceLineCache = nullptr |
A bump pointer allocated array of offsets for each source line.
This is lazily computed. This is owned by the SourceManager BumpPointerAllocator object.
Definition at line 130 of file SourceManager.h.
Referenced by ComputeLineNumbers(), ContentCache(), clang::SourceManager::getColumnNumber(), clang::SourceManager::getLineNumber(), clang::ScratchBuffer::getToken(), clang::Rewriter::IncreaseIndentation(), clang::Rewriter::InsertText(), and clang::SourceManager::translateLineCol().