LLVM 20.0.0git
Classes | Public Member Functions | List of all members
llvm::StringTable Class Reference

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

#include "llvm/ADT/StringTable.h"

Classes

class  Offset
 

Public Member Functions

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

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 31 of file StringTable.h.

Constructor & Destructor Documentation

◆ StringTable()

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

Member Function Documentation

◆ operator[]()

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

Definition at line 80 of file StringTable.h.

References assert(), llvm::StringRef::data(), and llvm::StringRef::size().

◆ size()

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

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