class ContentCache

Declaration

class ContentCache { /* full declaration omitted */ };

Description

One instance of this struct is kept for every file loaded or used. This object owns the MemoryBuffer object.

Declared at: clang/include/clang/Basic/SourceManager.h:129

Member Variables

private std::unique_ptr<llvm::MemoryBuffer> Buffer
The actual buffer containing the characters from the input file.
public const clang::FileEntry* OrigEntry
FIXME: Turn this into a FileEntryRef and remove Filename.
public const clang::FileEntry* ContentsEntry
Can be different from 'Entry' if we overridden the contents of one file with the contents of another file.
public llvm::StringRef Filename
FIXME: Remove this once OrigEntry is a FileEntryRef with a stable name.
public clang::SrcMgr::LineOffsetMapping SourceLineCache
This is lazily computed. The lines are owned by the SourceManager BumpPointerAllocator object.
public unsigned int BufferOverridden
When true, the original entry may be a virtual file that does not exist.
public unsigned int IsFileVolatile
True if this content cache was initially created for a source file considered to be volatile (likely to change between stat and open).
public unsigned int 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.
public unsigned int IsBufferInvalid

Method Overview

Methods

ContentCache(
    const clang::FileEntry* Ent = nullptr)

Declared at: clang/include/clang/Basic/SourceManager.h:180

Parameters

const clang::FileEntry* Ent = nullptr

ContentCache(const clang::FileEntry* Ent,
             const clang::FileEntry* contentEnt)

Declared at: clang/include/clang/Basic/SourceManager.h:182

Parameters

const clang::FileEntry* Ent
const clang::FileEntry* contentEnt

ContentCache(
    const clang::SrcMgr::ContentCache& RHS)

Description

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.

Declared at: clang/include/clang/Basic/SourceManager.h:189

Parameters

const clang::SrcMgr::ContentCache& RHS

llvm::Optional<StringRef> getBufferDataIfLoaded()
    const

Description

Return a StringRef to the source buffer data, only if it has already been loaded.

Declared at: clang/include/clang/Basic/SourceManager.h:239

llvm::Optional<llvm::MemoryBufferRef>
getBufferIfLoaded() const

Description

Return the buffer, only if it has been loaded.

Declared at: clang/include/clang/Basic/SourceManager.h:231

llvm::Optional<llvm::MemoryBufferRef>
getBufferOrNone(clang::DiagnosticsEngine& Diag,
                clang::FileManager& FM,
                clang::SourceLocation Loc =
                    clang::SourceLocation()) const

Description

Returns the memory buffer for the associated content.

Declared at: clang/include/clang/Basic/SourceManager.h:209

Parameters

clang::DiagnosticsEngine& Diag
Object through which diagnostics will be emitted if the buffer cannot be retrieved.
clang::FileManager& FM
clang::SourceLocation Loc = clang::SourceLocation()
If specified, is the location that invalid file diagnostics will be emitted at.

static const char* getInvalidBOM(
    llvm::StringRef BufStr)

Declared at: clang/include/clang/Basic/SourceManager.h:262

Parameters

llvm::StringRef BufStr

llvm::MemoryBuffer::BufferKind
getMemoryBufferKind() const

Description

Returns the kind of memory used to back the memory buffer for this content cache. This is used for performance analysis.

Declared at: clang/include/clang/Basic/SourceManager.h:228

unsigned int getSize() const

Description

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.

Declared at: clang/include/clang/Basic/SourceManager.h:218

unsigned int getSizeBytesMapped() const

Description

Returns the number of bytes actually mapped for this ContentCache. This can be 0 if the MemBuffer was not actually expanded.

Declared at: clang/include/clang/Basic/SourceManager.h:224

void setBuffer(
    std::unique_ptr<llvm::MemoryBuffer> B)

Description

Set the buffer.

Declared at: clang/include/clang/Basic/SourceManager.h:246

Parameters

std::unique_ptr<llvm::MemoryBuffer> B

void setUnownedBuffer(
    llvm::Optional<llvm::MemoryBufferRef> B)

Description

Set the buffer to one that's not owned (or to nullptr).

Declared at: clang/include/clang/Basic/SourceManager.h:254

Parameters

llvm::Optional<llvm::MemoryBufferRef> B