LLVM  8.0.1
StringSet.h
Go to the documentation of this file.
1 //===- StringSet.h - The LLVM Compiler Driver -------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // StringSet - A set-like wrapper for the StringMap.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ADT_STRINGSET_H
15 #define LLVM_ADT_STRINGSET_H
16 
17 #include "llvm/ADT/StringMap.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/Allocator.h"
20 #include <cassert>
21 #include <initializer_list>
22 #include <utility>
23 
24 namespace llvm {
25 
26  /// StringSet - A wrapper for StringMap that provides set-like functionality.
27  template <class AllocatorTy = MallocAllocator>
28  class StringSet : public StringMap<char, AllocatorTy> {
30 
31  public:
32  StringSet() = default;
33  StringSet(std::initializer_list<StringRef> S) {
34  for (StringRef X : S)
35  insert(X);
36  }
37 
38  std::pair<typename base::iterator, bool> insert(StringRef Key) {
39  assert(!Key.empty());
40  return base::insert(std::make_pair(Key, '\0'));
41  }
42 
43  template <typename InputIt>
44  void insert(const InputIt &Begin, const InputIt &End) {
45  for (auto It = Begin; It != End; ++It)
46  base::insert(std::make_pair(*It, '\0'));
47  }
48  };
49 
50 } // end namespace llvm
51 
52 #endif // LLVM_ADT_STRINGSET_H
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
Key
PAL metadata keys.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
StringSet(std::initializer_list< StringRef > S)
Definition: StringSet.h:33
std::pair< typename base::iterator, bool > insert(StringRef Key)
Definition: StringSet.h:38
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:366
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:220
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:28
StringSet()=default
void insert(const InputIt &Begin, const InputIt &End)
Definition: StringSet.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49