LLVM  11.0.0git
StringPool.cpp
Go to the documentation of this file.
1 //===-- StringPool.cpp - Intern'd string pool -----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the StringPool class.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 using namespace llvm;
15 
17 
19  assert(internTable.empty() && "PooledStringPtr leaked!");
20 }
21 
23  auto it = internTable.find(key);
24  if (it != internTable.end())
25  return PooledStringPtr(&*it);
26 
28  auto *entry = Entry::Create(key, allocator);
29  entry->getValue().pool = this;
30  internTable.insert(entry);
31 
32  return PooledStringPtr(entry);
33 }
friend class PooledStringPtr
Definition: StringPool.h:52
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static StringMapEntry * Create(StringRef key, AllocatorTy &allocator, InitTy &&... initVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
iterator find(StringRef Key)
Definition: StringMap.h:216
PooledStringPtr intern(StringRef string)
intern - Adds a string to the pool and returns a reference-counted pointer to it. ...
Definition: StringPool.cpp:22
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:254
bool empty() const
Definition: StringMap.h:90
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
PooledStringPtr - A pointer to an interned string.
Definition: StringPool.h:74
print Instructions which execute on loop entry
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
iterator end()
Definition: StringMap.h:203