clang API Documentation
One instance of this struct is kept for every file loaded or used. More...
#include <SourceManager.h>
Public Member Functions | |
ContentCache (const FileEntry *Ent=nullptr) | |
ContentCache (const FileEntry *Ent, const FileEntry *contentEnt) | |
~ContentCache () | |
ContentCache (const ContentCache &RHS) | |
llvm::MemoryBuffer * | getBuffer (DiagnosticsEngine &Diag, const SourceManager &SM, SourceLocation Loc=SourceLocation(), bool *Invalid=nullptr) const |
Returns the memory buffer for the associated content. | |
unsigned | getSize () const |
Returns the size of the content encapsulated by this ContentCache. | |
unsigned | getSizeBytesMapped () const |
Returns the number of bytes actually mapped for this ContentCache. | |
llvm::MemoryBuffer::BufferKind | getMemoryBufferKind () const |
void | setBuffer (std::unique_ptr< llvm::MemoryBuffer > B) |
llvm::MemoryBuffer * | getRawBuffer () const |
Get the underlying buffer, returning NULL if the buffer is not yet available. | |
void | replaceBuffer (llvm::MemoryBuffer *B, bool DoNotFree=false) |
Replace the existing buffer (which will be deleted) with the given buffer. | |
bool | isBufferInvalid () const |
Determine whether the buffer itself is invalid. | |
bool | shouldFreeBuffer () const |
Determine whether the buffer should be freed. | |
Public Attributes | |
const FileEntry * | OrigEntry |
Reference to the file entry representing this ContentCache. | |
const FileEntry * | ContentsEntry |
References the file which the contents were actually loaded from. | |
unsigned * | SourceLineCache |
A bump pointer allocated array of offsets for each source line. | |
unsigned | NumLines: 31 |
The number of lines in this ContentCache. | |
unsigned | BufferOverridden: 1 |
Indicates whether the buffer itself was provided to override the actual file contents. | |
unsigned | IsSystemFile: 1 |
True if this content cache was initially created for a source file considered as a system one. |
One instance of this struct is kept for every file loaded or used.
This object owns the MemoryBuffer object.
Definition at line 85 of file SourceManager.h.
clang::SrcMgr::ContentCache::ContentCache | ( | const FileEntry * | Ent = nullptr | ) | [inline] |
Definition at line 146 of file SourceManager.h.
clang::SrcMgr::ContentCache::ContentCache | ( | const FileEntry * | Ent, |
const FileEntry * | contentEnt | ||
) | [inline] |
Definition at line 153 of file SourceManager.h.
Definition at line 38 of file SourceManager.cpp.
References shouldFreeBuffer().
clang::SrcMgr::ContentCache::ContentCache | ( | const ContentCache & | RHS | ) | [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 163 of file SourceManager.h.
References ContentsEntry, NumLines, OrigEntry, and SourceLineCache.
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 84 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(), clang::SourceManager::getBuffer(), clang::SourceManager::getBufferData(), clang::SourceManager::getCharacterData(), clang::SourceManager::getMemoryBufferForFile(), clang::SourceManager::getPresumedLoc(), clang::ASTImporter::Import(), 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 51 of file SourceManager.cpp.
llvm::MemoryBuffer* clang::SrcMgr::ContentCache::getRawBuffer | ( | ) | const [inline] |
Get the underlying buffer, returning NULL if the buffer is not yet available.
Definition at line 216 of file SourceManager.h.
Referenced by getBuffer().
unsigned ContentCache::getSize | ( | ) | const |
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.
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, that file is not lazily brought in from disk to satisfy this query.
Definition at line 66 of file SourceManager.cpp.
References ContentsEntry, and clang::FileEntry::getSize().
unsigned ContentCache::getSizeBytesMapped | ( | ) | const |
Returns the number of bytes actually mapped for this ContentCache.
This can be 0 if the MemBuffer was not actually expanded.
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 45 of file SourceManager.cpp.
bool clang::SrcMgr::ContentCache::isBufferInvalid | ( | ) | const [inline] |
Determine whether the buffer itself is invalid.
Definition at line 223 of file SourceManager.h.
Referenced by getBuffer().
void ContentCache::replaceBuffer | ( | llvm::MemoryBuffer * | B, |
bool | DoNotFree = false |
||
) |
Replace the existing buffer (which will be deleted) with the given buffer.
Definition at line 71 of file SourceManager.cpp.
References shouldFreeBuffer().
void clang::SrcMgr::ContentCache::setBuffer | ( | std::unique_ptr< llvm::MemoryBuffer > | B | ) | [inline] |
Definition at line 208 of file SourceManager.h.
bool clang::SrcMgr::ContentCache::shouldFreeBuffer | ( | ) | const [inline] |
Determine whether the buffer should be freed.
Definition at line 228 of file SourceManager.h.
Referenced by replaceBuffer(), and ~ContentCache().
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 140 of file SourceManager.h.
Referenced by clang::ASTReader::ReadSLocEntry().
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 122 of file SourceManager.h.
Referenced by ContentCache(), getBuffer(), getSize(), and clang::ASTReader::ReadSLocEntry().
True if this content cache was initially created for a source file considered as a system one.
Definition at line 144 of file SourceManager.h.
Referenced by getBuffer().
The number of lines in this ContentCache.
This is only valid if SourceLineCache is non-null.
Definition at line 133 of file SourceManager.h.
Referenced by ComputeLineNumbers(), ContentCache(), clang::SourceManager::getLineNumber(), and clang::SourceManager::translateLineCol().
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 116 of file SourceManager.h.
Referenced by ContentCache(), clang::SourceManager::disableFileContentsOverride(), clang::SourceManager::getFileEntryForID(), clang::SourceManager::getFileEntryForSLocEntry(), clang::SourceManager::getPresumedLoc(), clang::ASTImporter::Import(), clang::ASTReader::ReadSLocEntry(), and clang::SourceManager::translateFile().
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 128 of file SourceManager.h.
Referenced by ComputeLineNumbers(), ContentCache(), clang::SourceManager::getColumnNumber(), clang::SourceManager::getLineNumber(), clang::Rewriter::IncreaseIndentation(), clang::Rewriter::InsertText(), and clang::SourceManager::translateLineCol().