LLVM  10.0.0svn
Public Member Functions | Public Attributes | List of all members
llvm::remarks::StringTable Struct Reference

The string table used for serializing remarks. More...

#include "llvm/Remarks/RemarkStringTable.h"

Collaboration diagram for llvm::remarks::StringTable:
Collaboration graph
[legend]

Public Member Functions

 StringTable ()=default
 
 StringTable (const StringTable &)=delete
 Disable copy. More...
 
StringTableoperator= (const StringTable &)=delete
 
 StringTable (StringTable &&)=default
 Should be movable. More...
 
StringTableoperator= (StringTable &&)=default
 
 StringTable (const ParsedStringTable &Other)
 Construct a string table from a ParsedStringTable. More...
 
std::pair< unsigned, StringRefadd (StringRef Str)
 Add a string to the table. It returns an unique ID of the string. More...
 
void internalize (Remark &R)
 Modify R to use strings from this string table. More...
 
void serialize (raw_ostream &OS) const
 Serialize the string table to a stream. More...
 
std::vector< StringRefserialize () const
 Serialize the string table to a vector. More...
 

Public Attributes

StringMap< unsigned, BumpPtrAllocatorStrTab
 The string table containing all the unique strings used in the output. More...
 
size_t SerializedSize = 0
 Total size of the string table when serialized. More...
 

Detailed Description

The string table used for serializing remarks.

This table can be for example serialized in a section to be consumed after the compilation.

Definition at line 35 of file RemarkStringTable.h.

Constructor & Destructor Documentation

◆ StringTable() [1/4]

llvm::remarks::StringTable::StringTable ( )
default

◆ StringTable() [2/4]

llvm::remarks::StringTable::StringTable ( const StringTable )
delete

Disable copy.

◆ StringTable() [3/4]

llvm::remarks::StringTable::StringTable ( StringTable &&  )
default

Should be movable.

◆ StringTable() [4/4]

StringTable::StringTable ( const ParsedStringTable Other)

Construct a string table from a ParsedStringTable.

Definition at line 23 of file RemarkStringTable.cpp.

References add(), llvm::numbers::e, llvm_unreachable, and llvm::remarks::ParsedStringTable::size().

Member Function Documentation

◆ add()

std::pair< unsigned, StringRef > StringTable::add ( StringRef  Str)

Add a string to the table. It returns an unique ID of the string.

Definition at line 31 of file RemarkStringTable.cpp.

References SerializedSize, and StrTab.

Referenced by llvm::remarks::BitstreamRemarkSerializerHelper::emitRemarkBlock(), internalize(), and StringTable().

◆ internalize()

void StringTable::internalize ( Remark R)

Modify R to use strings from this string table.

If the string table does not contain the strings, it adds them.

Definition at line 41 of file RemarkStringTable.cpp.

References add(), Arg, llvm::remarks::Remark::Args, llvm::remarks::Remark::FunctionName, llvm::remarks::Argument::Key, llvm::remarks::Argument::Loc, llvm::remarks::Remark::Loc, llvm::remarks::Remark::PassName, llvm::remarks::Remark::RemarkName, and llvm::remarks::Argument::Val.

◆ operator=() [1/2]

StringTable& llvm::remarks::StringTable::operator= ( const StringTable )
delete

◆ operator=() [2/2]

StringTable& llvm::remarks::StringTable::operator= ( StringTable &&  )
default

◆ serialize() [1/2]

void StringTable::serialize ( raw_ostream OS) const

Serialize the string table to a stream.

It is serialized as a little endian uint64 (the size of the table in bytes) followed by a sequence of NULL-terminated strings, where the N-th string is the string with the ID N in the StrTab map.

Definition at line 56 of file RemarkStringTable.cpp.

References serialize(), and llvm::raw_ostream::write().

Referenced by llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaStrTab().

◆ serialize() [2/2]

std::vector< StringRef > StringTable::serialize ( ) const

Serialize the string table to a vector.

This allows users to do the actual writing to file/memory/other. The string with the ID == N should be the N-th element in the vector.

Definition at line 65 of file RemarkStringTable.cpp.

Referenced by serialize().

Member Data Documentation

◆ SerializedSize

size_t llvm::remarks::StringTable::SerializedSize = 0

Total size of the string table when serialized.

Definition at line 40 of file RemarkStringTable.h.

Referenced by add(), and emitStrTab().

◆ StrTab

StringMap<unsigned, BumpPtrAllocator> llvm::remarks::StringTable::StrTab

The string table containing all the unique strings used in the output.

It maps a string to an unique ID.

Definition at line 38 of file RemarkStringTable.h.

Referenced by add(), llvm::yaml::MappingTraits< remarks::Remark * >::mapping(), llvm::yaml::MappingTraits< RemarkLocation >::mapping(), and llvm::yaml::MappingTraits< Argument >::mapping().


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