LLVM  6.0.0svn
Public Types | Public Member Functions | List of all members
llvm::StringMap< ValueTy, AllocatorTy > Class Template Reference

StringMap - This is an unconventional map that is specialized for handling keys that are "strings", which are basically ranges of bytes. More...

#include "llvm/ADT/StringMap.h"

Inherits llvm::StringMapImpl.

Collaboration diagram for llvm::StringMap< ValueTy, AllocatorTy >:
Collaboration graph
[legend]

Public Types

using MapEntryTy = StringMapEntry< ValueTy >
 
using key_type = const char *
 
using mapped_type = ValueTy
 
using value_type = StringMapEntry< ValueTy >
 
using size_type = size_t
 
using const_iterator = StringMapConstIterator< ValueTy >
 
using iterator = StringMapIterator< ValueTy >
 

Public Member Functions

 StringMap ()
 
 StringMap (unsigned InitialSize)
 
 StringMap (AllocatorTy A)
 
 StringMap (unsigned InitialSize, AllocatorTy A)
 
 StringMap (std::initializer_list< std::pair< StringRef, ValueTy >> List)
 
 StringMap (StringMap &&RHS)
 
 StringMap (const StringMap &RHS)
 
StringMapoperator= (StringMap RHS)
 
 ~StringMap ()
 
AllocatorTy & getAllocator ()
 
const AllocatorTy & getAllocator () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
iterator_range< StringMapKeyIterator< ValueTy > > keys () const
 
iterator find (StringRef Key)
 
const_iterator find (StringRef Key) const
 
ValueTy lookup (StringRef Key) const
 lookup - Return the entry for the specified key, or a default constructed value if no such entry exists. More...
 
ValueTy & operator[] (StringRef Key)
 Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map. More...
 
size_type count (StringRef Key) const
 count - Return 1 if the element is in the map, 0 otherwise. More...
 
bool insert (MapEntryTy *KeyValue)
 insert - Insert the specified key/value pair into the map. More...
 
std::pair< iterator, boolinsert (std::pair< StringRef, ValueTy > KV)
 insert - Inserts the specified key/value pair into the map if the key isn't already in the map. More...
 
template<typename... ArgsTy>
std::pair< iterator, booltry_emplace (StringRef Key, ArgsTy &&... Args)
 Emplace a new element for the specified key into the map if the key isn't already in the map. More...
 
void clear ()
 
void remove (MapEntryTy *KeyValue)
 remove - Remove the specified key/value pair from the map, but do not erase it. More...
 
void erase (iterator I)
 
bool erase (StringRef Key)
 
- Public Member Functions inherited from llvm::StringMapImpl
unsigned getNumBuckets () const
 
unsigned getNumItems () const
 
bool empty () const
 
unsigned size () const
 
void swap (StringMapImpl &Other)
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::StringMapImpl
static StringMapEntryBasegetTombstoneVal ()
 
- Protected Member Functions inherited from llvm::StringMapImpl
 StringMapImpl (unsigned itemSize)
 
 StringMapImpl (StringMapImpl &&RHS)
 
 StringMapImpl (unsigned InitSize, unsigned ItemSize)
 
unsigned RehashTable (unsigned BucketNo=0)
 RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hashtable-size. More...
 
unsigned LookupBucketFor (StringRef Key)
 LookupBucketFor - Look up the bucket that the specified string should end up in. More...
 
int FindKey (StringRef Key) const
 FindKey - Look up the bucket that contains the specified key. More...
 
void RemoveKey (StringMapEntryBase *V)
 RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it. More...
 
StringMapEntryBaseRemoveKey (StringRef Key)
 RemoveKey - Remove the StringMapEntry for the specified key from the table, returning it. More...
 
void init (unsigned Size)
 Allocate the table with the specified number of buckets and otherwise setup the map as empty. More...
 
- Protected Attributes inherited from llvm::StringMapImpl
StringMapEntryBase ** TheTable = nullptr
 
unsigned NumBuckets = 0
 
unsigned NumItems = 0
 
unsigned NumTombstones = 0
 
unsigned ItemSize
 

Detailed Description

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
class llvm::StringMap< ValueTy, AllocatorTy >

StringMap - This is an unconventional map that is specialized for handling keys that are "strings", which are basically ranges of bytes.

This does some funky memory allocation and hashing things to make it extremely efficient, storing the string data after the value in the map.

Definition at line 224 of file StringMap.h.

Member Typedef Documentation

◆ const_iterator

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
using llvm::StringMap< ValueTy, AllocatorTy >::const_iterator = StringMapConstIterator<ValueTy>

Definition at line 316 of file StringMap.h.

◆ iterator

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
using llvm::StringMap< ValueTy, AllocatorTy >::iterator = StringMapIterator<ValueTy>

Definition at line 317 of file StringMap.h.

◆ key_type

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
using llvm::StringMap< ValueTy, AllocatorTy >::key_type = const char*

Definition at line 311 of file StringMap.h.

◆ MapEntryTy

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
using llvm::StringMap< ValueTy, AllocatorTy >::MapEntryTy = StringMapEntry<ValueTy>

Definition at line 228 of file StringMap.h.

◆ mapped_type

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
using llvm::StringMap< ValueTy, AllocatorTy >::mapped_type = ValueTy

Definition at line 312 of file StringMap.h.

◆ size_type

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
using llvm::StringMap< ValueTy, AllocatorTy >::size_type = size_t

Definition at line 314 of file StringMap.h.

◆ value_type

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
using llvm::StringMap< ValueTy, AllocatorTy >::value_type = StringMapEntry<ValueTy>

Definition at line 313 of file StringMap.h.

Constructor & Destructor Documentation

◆ StringMap() [1/7]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
llvm::StringMap< ValueTy, AllocatorTy >::StringMap ( )
inline

Definition at line 230 of file StringMap.h.

◆ StringMap() [2/7]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
llvm::StringMap< ValueTy, AllocatorTy >::StringMap ( unsigned  InitialSize)
inlineexplicit

Definition at line 232 of file StringMap.h.

◆ StringMap() [3/7]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
llvm::StringMap< ValueTy, AllocatorTy >::StringMap ( AllocatorTy  A)
inlineexplicit

Definition at line 235 of file StringMap.h.

◆ StringMap() [4/7]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
llvm::StringMap< ValueTy, AllocatorTy >::StringMap ( unsigned  InitialSize,
AllocatorTy  A 
)
inline

Definition at line 238 of file StringMap.h.

◆ StringMap() [5/7]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
llvm::StringMap< ValueTy, AllocatorTy >::StringMap ( std::initializer_list< std::pair< StringRef, ValueTy >>  List)
inline

Definition at line 242 of file StringMap.h.

◆ StringMap() [6/7]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
llvm::StringMap< ValueTy, AllocatorTy >::StringMap ( StringMap< ValueTy, AllocatorTy > &&  RHS)
inline

Definition at line 249 of file StringMap.h.

◆ StringMap() [7/7]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
llvm::StringMap< ValueTy, AllocatorTy >::StringMap ( const StringMap< ValueTy, AllocatorTy > &  RHS)
inline

Definition at line 252 of file StringMap.h.

◆ ~StringMap()

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
llvm::StringMap< ValueTy, AllocatorTy >::~StringMap ( )
inline

Definition at line 293 of file StringMap.h.

Member Function Documentation

◆ begin() [1/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
iterator llvm::StringMap< ValueTy, AllocatorTy >::begin ( )
inline

◆ begin() [2/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
const_iterator llvm::StringMap< ValueTy, AllocatorTy >::begin ( ) const
inline

Definition at line 325 of file StringMap.h.

◆ clear()

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
void llvm::StringMap< ValueTy, AllocatorTy >::clear ( )
inline

◆ count()

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
size_type llvm::StringMap< ValueTy, AllocatorTy >::count ( StringRef  Key) const
inline

count - Return 1 if the element is in the map, 0 otherwise.

Definition at line 363 of file StringMap.h.

Referenced by llvm::LTOCodeGenerator::compile(), HandlePrefixedOrGroupedOption(), llvm::ModuleSummaryIndex::hasExportedFunctions(), and llvm::lto::ThinBackendProc::~ThinBackendProc().

◆ end() [1/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
iterator llvm::StringMap< ValueTy, AllocatorTy >::end ( )
inline

Definition at line 322 of file StringMap.h.

Referenced by llvm::pdb::NamedStreamMap::commit(), llvm::LTOCodeGenerator::compile(), createGlobalFwdRef(), llvm::RecordStreamer::end(), llvm::codeview::DebugStringTableSubsection::end(), llvm::ValueSymbolTable::end(), llvm::pdb::NamedStreamMap::entries(), llvm::pdb::NamedStreamMap::finalize(), llvm::DwarfAccelTable::FinalizeTable(), llvm::pdb::NamedStreamMap::get(), llvm::ConstantDataSequential::getImpl(), llvm::LLVMContext::getMDKindNames(), getMinVisibility(), llvm::ModuleSummaryIndex::getModuleHash(), llvm::LLVMContextImpl::getOperandBundleTagID(), getOptionPred(), llvm::PassRegistry::getPassInfo(), getSignature(), llvm::pdb::DbiStreamBuilder::getSourceFileNameIndex(), llvm::codeview::DebugStringTableSubsection::getStringId(), llvm::RuntimeDyldImpl::getSymbol(), llvm::RuntimeDyldImpl::getSymbolLocalAddress(), llvm::RecordStreamer::getSymbolState(), llvm::DWARFVerifier::handleDebugInfo(), handleSymverAliases(), llvm::MIRParserImpl::initializeJumpTableInfo(), llvm::SpecialCaseList::inSectionBlame(), llvm::StringPool::intern(), llvm::ThinLTOCodeGenerator::internalize(), isImplicitOperandIn(), isOperator(), LookupNearestOption(), llvm::SpecialCaseList::Matcher::match(), llvm::opt::OptTable::OptTable(), llvm::SpecialCaseList::parse(), llvm::LLParser::parseTypeAtBeginning(), llvm::TimeRecord::print(), llvm::DwarfAccelTable::print(), llvm::RuntimeDyldMachOARM::processRelocationRef(), llvm::RuntimeDyldELF::processRelocationRef(), llvm::ThinLTOCodeGenerator::promote(), llvm::ImportedFunctionsInliningStatistics::recordInline(), llvm::RuntimeDyldELF::resolveRelocation(), llvm::ThinLTOCodeGenerator::run(), SortCallTargets(), sortOpts(), and llvm::object::WasmObjectFile::WasmObjectFile().

◆ end() [2/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
const_iterator llvm::StringMap< ValueTy, AllocatorTy >::end ( ) const
inline

Definition at line 328 of file StringMap.h.

◆ erase() [1/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
void llvm::StringMap< ValueTy, AllocatorTy >::erase ( iterator  I)
inline

◆ erase() [2/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
bool llvm::StringMap< ValueTy, AllocatorTy >::erase ( StringRef  Key)
inline

Definition at line 446 of file StringMap.h.

◆ find() [1/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
iterator llvm::StringMap< ValueTy, AllocatorTy >::find ( StringRef  Key)
inline

Definition at line 337 of file StringMap.h.

Referenced by llvm::RuntimeDyldCheckerImpl::checkAllRulesInBuffer(), llvm::pdb::NamedStreamMap::commit(), llvm::LTOCodeGenerator::compile(), createGlobalFwdRef(), llvm::pdb::NamedStreamMap::finalize(), llvm::RuntimeDyldMachOX86_64::finalizeSection(), llvm::RuntimeDyldMachOAArch64::finalizeSection(), llvm::sampleprof::FunctionSamples::findFunctionSamplesMapAt(), llvm::pdb::NamedStreamMap::get(), llvm::ConstantDataSequential::getImpl(), getMinVisibility(), llvm::ModuleSummaryIndex::getModuleHash(), llvm::LLVMContextImpl::getOperandBundleTagID(), getOptionPred(), llvm::PassRegistry::getPassInfo(), getSignature(), llvm::pdb::DbiStreamBuilder::getSourceFileNameIndex(), llvm::codeview::DebugStringTableSubsection::getStringId(), llvm::RuntimeDyldImpl::getSymbol(), llvm::RuntimeDyldImpl::getSymbolLocalAddress(), llvm::RecordStreamer::getSymbolState(), llvm::DWARFVerifier::handleDebugInfo(), HandlePrefixedOrGroupedOption(), handleSymverAliases(), llvm::MIRParserImpl::initializeJumpTableInfo(), llvm::SpecialCaseList::inSectionBlame(), llvm::StringPool::intern(), llvm::ThinLTOCodeGenerator::internalize(), isImplicitOperandIn(), isOperator(), llvm::SpecialCaseList::Matcher::match(), llvm::SpecialCaseList::parse(), llvm::LLParser::parseTypeAtBeginning(), llvm::RuntimeDyldMachOARM::processRelocationRef(), llvm::RuntimeDyldELF::processRelocationRef(), llvm::ThinLTOCodeGenerator::promote(), llvm::ImportedFunctionsInliningStatistics::recordInline(), llvm::RuntimeDyldELF::resolveRelocation(), llvm::ThinLTOCodeGenerator::run(), llvm::object::WasmObjectFile::WasmObjectFile(), and llvm::lto::ThinBackendProc::~ThinBackendProc().

◆ find() [2/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
const_iterator llvm::StringMap< ValueTy, AllocatorTy >::find ( StringRef  Key) const
inline

Definition at line 343 of file StringMap.h.

◆ getAllocator() [1/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
AllocatorTy& llvm::StringMap< ValueTy, AllocatorTy >::getAllocator ( )
inline

Definition at line 308 of file StringMap.h.

Referenced by llvm::StructType::setName().

◆ getAllocator() [2/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
const AllocatorTy& llvm::StringMap< ValueTy, AllocatorTy >::getAllocator ( ) const
inline

Definition at line 309 of file StringMap.h.

◆ insert() [1/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
bool llvm::StringMap< ValueTy, AllocatorTy >::insert ( MapEntryTy KeyValue)
inline

◆ insert() [2/2]

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
std::pair<iterator, bool> llvm::StringMap< ValueTy, AllocatorTy >::insert ( std::pair< StringRef, ValueTy >  KV)
inline

insert - Inserts the specified key/value pair into the map if the key isn't already in the map.

The bool component of the returned pair is true if and only if the insertion takes place, and the iterator component of the pair points to the element with key equivalent to the key of the pair.

Definition at line 390 of file StringMap.h.

◆ keys()

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
iterator_range<StringMapKeyIterator<ValueTy> > llvm::StringMap< ValueTy, AllocatorTy >::keys ( ) const
inline

Definition at line 332 of file StringMap.h.

◆ lookup()

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
ValueTy llvm::StringMap< ValueTy, AllocatorTy >::lookup ( StringRef  Key) const
inline

lookup - Return the entry for the specified key, or a default constructed value if no such entry exists.

Definition at line 351 of file StringMap.h.

Referenced by llvm::gatherImportedSummariesForModule(), getGNUBinOpPrecedence(), llvm::ModuleSummaryIndex::getModuleId(), llvm::ValueSymbolTable::lookup(), and llvm::MCContext::lookupSymbol().

◆ operator=()

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
StringMap& llvm::StringMap< ValueTy, AllocatorTy >::operator= ( StringMap< ValueTy, AllocatorTy >  RHS)
inline

Definition at line 287 of file StringMap.h.

◆ operator[]()

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
ValueTy& llvm::StringMap< ValueTy, AllocatorTy >::operator[] ( StringRef  Key)
inline

Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map.

Definition at line 360 of file StringMap.h.

◆ remove()

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
void llvm::StringMap< ValueTy, AllocatorTy >::remove ( MapEntryTy KeyValue)
inline

remove - Remove the specified key/value pair from the map, but do not erase it.

This aborts if the key is not in the map.

Definition at line 436 of file StringMap.h.

Referenced by llvm::StructType::setName(), and llvm::ValueSymbolTable::~ValueSymbolTable().

◆ try_emplace()

template<typename ValueTy, typename AllocatorTy = MallocAllocator>
template<typename... ArgsTy>
std::pair<iterator, bool> llvm::StringMap< ValueTy, AllocatorTy >::try_emplace ( StringRef  Key,
ArgsTy &&...  Args 
)
inline

Emplace a new element for the specified key into the map if the key isn't already in the map.

The bool component of the returned pair is true if and only if the insertion takes place, and the iterator component of the pair points to the element with key equivalent to the key of the pair.

Definition at line 399 of file StringMap.h.

Referenced by llvm::lto::createWriteIndexesThinBackend(), and llvm::object::WasmObjectFile::WasmObjectFile().


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