LLVM 22.0.0git
llvm::StringTable Class Reference

A table of densely packed, null-terminated strings indexed by offset. More...

#include "llvm/ADT/StringTable.h"

Classes

class  Iterator
class  Offset

Public Member Functions

template<size_t N>
constexpr StringTable (const char(&RawTable)[N])
constexpr const chargetCString (Offset O) const
constexpr StringRef operator[] (Offset O) const
constexpr size_t size () const
 Returns the byte size of the table.
constexpr Iterator begin () const
constexpr Iterator end () const

Detailed Description

A table of densely packed, null-terminated strings indexed by offset.

This table abstracts a densely concatenated list of null-terminated strings, each of which can be referenced using an offset into the table.

This requires and ensures that the string at offset 0 is also the empty string. This helps allow zero-initialized offsets form empty strings and avoids non-zero initialization when using a string literal pointer would allow a null pointer.

The primary use case is having a single global string literal for the table contents, and offsets into it in other global data structures to avoid dynamic relocations of individual string literal pointers in those global data structures.

Definition at line 33 of file StringTable.h.

Constructor & Destructor Documentation

◆ StringTable()

template<size_t N>
llvm::StringTable::StringTable ( const char(&) RawTable[N])
inlineconstexpr

Definition at line 72 of file StringTable.h.

References assert(), and N.

Member Function Documentation

◆ begin()

Iterator llvm::StringTable::begin ( ) const
inlineconstexpr

Definition at line 146 of file StringTable.h.

◆ end()

Iterator llvm::StringTable::end ( ) const
inlineconstexpr

Definition at line 147 of file StringTable.h.

References size().

◆ getCString()

const char * llvm::StringTable::getCString ( Offset O) const
inlineconstexpr

Definition at line 90 of file StringTable.h.

References assert().

Referenced by operator[]().

◆ operator[]()

StringRef llvm::StringTable::operator[] ( Offset O) const
inlineconstexpr

Definition at line 98 of file StringTable.h.

References getCString().

◆ size()

size_t llvm::StringTable::size ( ) const
inlineconstexpr

Returns the byte size of the table.

Definition at line 101 of file StringTable.h.

Referenced by end(), llvm::object::MachOObjectFile::getIndirectName(), and writeSymbolTable().


The documentation for this class was generated from the following file: