LLVM  10.0.0svn
StringPool.cpp
Go to the documentation of this file.
1 //===-- StringPool.cpp - Interned 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 #include "llvm/ADT/StringRef.h"
15 
16 using namespace llvm;
17 
19 
21  assert(InternTable.empty() && "PooledStringPtr leaked!");
22 }
23 
25  table_t::iterator I = InternTable.find(Key);
26  if (I != InternTable.end())
27  return PooledStringPtr(&*I);
28 
29  entry_t *S = entry_t::Create(Key);
30  S->getValue().Pool = this;
31  InternTable.insert(S);
32 
33  return PooledStringPtr(S);
34 }
friend class PooledStringPtr
Definition: StringPool.h:53
PooledStringPtr intern(StringRef Str)
intern - Adds a string to the pool and returns a reference-counted pointer to it. ...
Definition: StringPool.cpp:24
This class represents lattice values for constants.
Definition: AllocatorList.h:23
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMap.h:158
iterator find(StringRef Key)
Definition: StringMap.h:355
static StringMapEntry * Create(StringRef Key, AllocatorTy &Allocator, InitTy &&... InitVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
Definition: StringMap.h:178
Key
PAL metadata keys.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:393
#define I(x, y, z)
Definition: MD5.cpp:58
bool empty() const
Definition: StringMap.h:110
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
PooledStringPtr - A pointer to an interned string.
Definition: StringPool.h:78
const ValueTy & getValue() const
Definition: StringMap.h:138
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
iterator end()
Definition: StringMap.h:340