LLVM  8.0.1
StringPool.cpp
Go to the documentation of this file.
1 //===-- StringPool.cpp - Interned string pool -----------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the StringPool class.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/StringRef.h"
16 
17 using namespace llvm;
18 
20 
22  assert(InternTable.empty() && "PooledStringPtr leaked!");
23 }
24 
26  table_t::iterator I = InternTable.find(Key);
27  if (I != InternTable.end())
28  return PooledStringPtr(&*I);
29 
30  entry_t *S = entry_t::Create(Key);
31  S->getValue().Pool = this;
32  InternTable.insert(S);
33 
34  return PooledStringPtr(S);
35 }
friend class PooledStringPtr
Definition: StringPool.h:54
PooledStringPtr intern(StringRef Str)
intern - Adds a string to the pool and returns a reference-counted pointer to it. ...
Definition: StringPool.cpp:25
This class represents lattice values for constants.
Definition: AllocatorList.h:24
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMap.h:126
iterator find(StringRef Key)
Definition: StringMap.h:333
const ValueTy & getValue() const
Definition: StringMap.h:141
static StringMapEntry * Create(StringRef Key, AllocatorTy &Allocator, InitTy &&... InitVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
Definition: StringMap.h:156
Key
PAL metadata keys.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:366
#define I(x, y, z)
Definition: MD5.cpp:58
bool empty() const
Definition: StringMap.h:111
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
PooledStringPtr - A pointer to an interned string.
Definition: StringPool.h:79
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
iterator end()
Definition: StringMap.h:318