LLVM 20.0.0git
Public Types | Public Member Functions | List of all members
llvm::StringTableBuilder Class Reference

Utility for building string tables with deduplicated suffixes. More...

#include "llvm/MC/StringTableBuilder.h"

Public Types

enum  Kind {
  ELF , WinCOFF , MachO , MachO64 ,
  MachOLinked , MachO64Linked , RAW , DWARF ,
  XCOFF , DXContainer
}
 

Public Member Functions

 StringTableBuilder (Kind K, Align Alignment=Align(1))
 
 ~StringTableBuilder ()
 
size_t add (CachedHashStringRef S)
 Add a string to the builder.
 
size_t add (StringRef S)
 
void finalize ()
 Analyze the strings and build the final table.
 
void finalizeInOrder ()
 Finalize the string table without reording it.
 
size_t getOffset (CachedHashStringRef S) const
 Get the offest of a string in the string table.
 
size_t getOffset (StringRef S) const
 
bool contains (StringRef S) const
 Check if a string is contained in the string table.
 
bool contains (CachedHashStringRef S) const
 
size_t getSize () const
 
void clear ()
 
void write (raw_ostream &OS) const
 
void write (uint8_t *Buf) const
 
bool isFinalized () const
 

Detailed Description

Utility for building string tables with deduplicated suffixes.

Definition at line 24 of file StringTableBuilder.h.

Member Enumeration Documentation

◆ Kind

Enumerator
ELF 
WinCOFF 
MachO 
MachO64 
MachOLinked 
MachO64Linked 
RAW 
DWARF 
XCOFF 
DXContainer 

Definition at line 26 of file StringTableBuilder.h.

Constructor & Destructor Documentation

◆ StringTableBuilder()

StringTableBuilder::StringTableBuilder ( Kind  K,
Align  Alignment = Align(1) 
)

Definition at line 56 of file StringTableBuilder.cpp.

◆ ~StringTableBuilder()

StringTableBuilder::~StringTableBuilder ( )
default

Member Function Documentation

◆ add() [1/2]

size_t StringTableBuilder::add ( CachedHashStringRef  S)

◆ add() [2/2]

size_t llvm::StringTableBuilder::add ( StringRef  S)
inline

Definition at line 57 of file StringTableBuilder.h.

References add().

Referenced by add().

◆ clear()

void StringTableBuilder::clear ( )

◆ contains() [1/2]

bool llvm::StringTableBuilder::contains ( CachedHashStringRef  S) const
inline

◆ contains() [2/2]

bool llvm::StringTableBuilder::contains ( StringRef  S) const
inline

Check if a string is contained in the string table.

Since this class doesn't store the string values, this function can be used to check if storage needs to be done prior to adding the string.

Definition at line 77 of file StringTableBuilder.h.

References contains().

Referenced by contains(), and llvm::gsym::GsymCreator::insertString().

◆ finalize()

void StringTableBuilder::finalize ( )

Analyze the strings and build the final table.

No more strings can be added after this point.

Definition at line 129 of file StringTableBuilder.cpp.

References assert(), and DWARF.

Referenced by llvm::MachObjectWriter::computeSymbolTable(), llvm::mcdxbc::PSVRuntimeInfo::finalize(), llvm::objcopy::elf::StringTableSection::prepareForLayout(), llvm::object::OffloadBinary::write(), and llvm::WinCOFFWriter::writeObject().

◆ finalizeInOrder()

void StringTableBuilder::finalizeInOrder ( )

Finalize the string table without reording it.

In this mode, offsets returned by add will still be valid.

Definition at line 134 of file StringTableBuilder.cpp.

Referenced by llvm::gsym::GsymCreator::finalize(), llvm::MCDwarfLineStr::getFinalizedData(), upgrade(), llvm::mcdxbc::Signature::write(), and llvm::BitcodeWriter::writeStrtab().

◆ getOffset() [1/2]

size_t StringTableBuilder::getOffset ( CachedHashStringRef  S) const

Get the offest of a string in the string table.

Can only be used after the table is finalized.

Definition at line 195 of file StringTableBuilder.cpp.

References assert(), I, and isFinalized().

Referenced by llvm::MachObjectWriter::computeSymbolTable(), llvm::mcdxbc::PSVRuntimeInfo::finalize(), llvm::objcopy::elf::StringTableSection::findIndex(), getOffset(), and llvm::object::OffloadBinary::write().

◆ getOffset() [2/2]

size_t llvm::StringTableBuilder::getOffset ( StringRef  S) const
inline

Definition at line 70 of file StringTableBuilder.h.

References getOffset().

◆ getSize()

size_t llvm::StringTableBuilder::getSize ( ) const
inline

◆ isFinalized()

bool llvm::StringTableBuilder::isFinalized ( ) const
inline

Definition at line 86 of file StringTableBuilder.h.

Referenced by add(), llvm::MCDwarfLineStr::getFinalizedData(), getOffset(), and write().

◆ write() [1/2]

void StringTableBuilder::write ( raw_ostream OS) const

◆ write() [2/2]

void StringTableBuilder::write ( uint8_t *  Buf) const

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