File indexing completed on 2026-05-10 08:43:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_ADT_STRINGSET_H
0015 #define LLVM_ADT_STRINGSET_H
0016
0017 #include "llvm/ADT/StringMap.h"
0018
0019 namespace llvm {
0020
0021
0022 template <class AllocatorTy = MallocAllocator>
0023 class StringSet : public StringMap<std::nullopt_t, AllocatorTy> {
0024 using Base = StringMap<std::nullopt_t, AllocatorTy>;
0025
0026 public:
0027 StringSet() = default;
0028 StringSet(std::initializer_list<StringRef> initializer) {
0029 for (StringRef str : initializer)
0030 insert(str);
0031 }
0032 template <typename Container> explicit StringSet(Container &&C) {
0033 for (auto &&Str : C)
0034 insert(Str);
0035 }
0036 explicit StringSet(AllocatorTy a) : Base(a) {}
0037
0038 std::pair<typename Base::iterator, bool> insert(StringRef key) {
0039 return Base::try_emplace(key);
0040 }
0041
0042 template <typename InputIt>
0043 void insert(InputIt begin, InputIt end) {
0044 for (auto it = begin; it != end; ++it)
0045 insert(*it);
0046 }
0047
0048 template <typename ValueTy>
0049 std::pair<typename Base::iterator, bool>
0050 insert(const StringMapEntry<ValueTy> &mapEntry) {
0051 return insert(mapEntry.getKey());
0052 }
0053
0054
0055 bool contains(StringRef key) const { return Base::FindKey(key) != -1; }
0056 };
0057
0058 }
0059
0060 #endif