clang 20.0.0git
|
One instance of this struct is kept for every file loaded or used. More...
#include "clang/Basic/SourceManager.h"
Public Member Functions | |
ContentCache () | |
ContentCache (FileEntryRef Ent) | |
ContentCache (FileEntryRef Ent, FileEntryRef contentEnt) | |
ContentCache (const ContentCache &RHS) | |
The copy ctor does not allow copies where source object has either a non-NULL Buffer or SourceLineCache. | |
ContentCache & | operator= (const ContentCache &RHS)=delete |
std::optional< llvm::MemoryBufferRef > | getBufferOrNone (DiagnosticsEngine &Diag, FileManager &FM, SourceLocation Loc=SourceLocation()) 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 |
Returns the kind of memory used to back the memory buffer for this content cache. | |
std::optional< llvm::MemoryBufferRef > | getBufferIfLoaded () const |
Return the buffer, only if it has been loaded. | |
std::optional< StringRef > | getBufferDataIfLoaded () const |
Return a StringRef to the source buffer data, only if it has already been loaded. | |
void | setBuffer (std::unique_ptr< llvm::MemoryBuffer > B) |
Set the buffer. | |
void | setUnownedBuffer (std::optional< llvm::MemoryBufferRef > B) |
Set the buffer to one that's not owned (or to nullptr). | |
Static Public Member Functions | |
static const char * | getInvalidBOM (StringRef BufStr) |
Public Attributes | |
OptionalFileEntryRef | OrigEntry |
Reference to the file entry representing this ContentCache. | |
OptionalFileEntryRef | ContentsEntry |
References the file which the contents were actually loaded from. | |
StringRef | Filename |
The filename that is used to access OrigEntry. | |
LineOffsetMapping | SourceLineCache |
A bump pointer allocated array of offsets for each source line. | |
unsigned | BufferOverridden: 1 |
Indicates whether the buffer itself was provided to override the actual file contents. | |
unsigned | IsFileVolatile: 1 |
True if this content cache was initially created for a source file considered to be volatile (likely to change between stat and open). | |
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. | |
unsigned | IsBufferInvalid: 1 |
One instance of this struct is kept for every file loaded or used.
This object owns the MemoryBuffer object.
Definition at line 131 of file SourceManager.h.
|
inline |
Definition at line 187 of file SourceManager.h.
|
inline |
Definition at line 192 of file SourceManager.h.
|
inline |
Definition at line 194 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 201 of file SourceManager.h.
References ContentsEntry, OrigEntry, and SourceLineCache.
|
inline |
Return a StringRef to the source buffer data, only if it has already been loaded.
Definition at line 251 of file SourceManager.h.
Referenced by clang::SourceManager::getBufferDataIfLoaded().
|
inline |
Return the buffer, only if it has been loaded.
Definition at line 243 of file SourceManager.h.
Referenced by clang::ASTReader::ReadSLocEntry().
std::optional< llvm::MemoryBufferRef > ContentCache::getBufferOrNone | ( | DiagnosticsEngine & | Diag, |
FileManager & | FM, | ||
SourceLocation | Loc = SourceLocation() |
||
) | 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. |
Definition at line 111 of file SourceManager.cpp.
References ContentsEntry, Diag(), clang::FileManager::getBufferForFile(), getInvalidBOM(), clang::FileEntryRef::getName(), clang::FileEntryRef::getSize(), IsBufferInvalid, IsFileVolatile, clang::FileEntryRef::isNamedPipe(), and Loc.
Referenced by clang::SourceManager::createFileID(), clang::SourceManager::getBufferDataOrNone(), clang::SourceManager::getCharacterData(), clang::SourceManager::getLineNumber(), clang::SourceManager::getMemoryBufferForFileOrNone(), and clang::SourceManager::translateLineCol().
|
static |
Definition at line 87 of file SourceManager.cpp.
Referenced by getBufferOrNone().
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 70 of file SourceManager.cpp.
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 82 of file SourceManager.cpp.
References ContentsEntry, and clang::FileEntryRef::getSize().
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 64 of file SourceManager.cpp.
|
delete |
|
inline |
Set the buffer.
Definition at line 258 of file SourceManager.h.
References IsBufferInvalid.
Referenced by clang::SourceManager::overrideFileContents(), and setUnownedBuffer().
|
inline |
Set the buffer to one that's not owned (or to nullptr).
Definition at line 266 of file SourceManager.h.
References setBuffer().
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 171 of file SourceManager.h.
Referenced by clang::SourceManager::overrideFileContents(), and clang::ASTReader::ReadSLocEntry().
OptionalFileEntryRef 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 152 of file SourceManager.h.
Referenced by ContentCache(), clang::SourceManager::createFileID(), getBufferOrNone(), getSize(), and clang::ASTReader::ReadSLocEntry().
StringRef clang::SrcMgr::ContentCache::Filename |
The filename that is used to access OrigEntry.
FIXME: Remove this once OrigEntry is a FileEntryRef with a stable name.
Definition at line 157 of file SourceManager.h.
Referenced by clang::SrcMgr::FileInfo::get(), and clang::SrcMgr::FileInfo::getName().
|
mutable |
Definition at line 185 of file SourceManager.h.
Referenced by getBufferOrNone(), and setBuffer().
unsigned clang::SrcMgr::ContentCache::IsFileVolatile |
True if this content cache was initially created for a source file considered to be volatile (likely to change between stat and open).
Definition at line 176 of file SourceManager.h.
Referenced by getBufferOrNone().
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 182 of file SourceManager.h.
Referenced by clang::SourceManager::setFileIsTransient().
OptionalFileEntryRef 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.
FIXME: Make non-optional using a virtual file as needed, remove Filename
and use OrigEntry.getNameAsRequested()
instead.
Definition at line 146 of file SourceManager.h.
Referenced by ContentCache(), clang::SourceManager::getFileEntryForSLocEntry(), clang::SourceManager::getNonBuiltinFilenameForID(), clang::SourceManager::initializeForReplay(), clang::ASTReader::ReadSLocEntry(), and clang::SourceManager::translateFile().
|
mutable |
A bump pointer allocated array of offsets for each source line.
This is lazily computed. The lines are owned by the SourceManager BumpPointerAllocator object.
Definition at line 163 of file SourceManager.h.
Referenced by ContentCache(), clang::SourceManager::getColumnNumber(), clang::SourceManager::getLineNumber(), clang::ScratchBuffer::getToken(), clang::Rewriter::IncreaseIndentation(), clang::Rewriter::InsertText(), and clang::SourceManager::translateLineCol().