llvm.org GIT mirror llvm / 8f4a49f
Make StringSet::insert return pair<iterator, bool> like other self-associative containers StringSet is still a bit dodgy in that it exposes the raw iterator of the StringMap parent, which exposes the weird detail that StringSet actually has a 'value'... but anyway, this is useful for a handful of clients that want to reference the newly inserted/persistent string data in the StringSet/Map/Entry/thing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222302 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 4 years ago
4 changed file(s) with 5 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
2323 typedef llvm::StringMap base;
2424 public:
2525
26 /// insert - Insert the specified key into the set. If the key already
27 /// exists in the set, return false and ignore the request, otherwise insert
28 /// it and return true.
29 bool insert(StringRef Key) {
30 // Get or create the map entry for the key; if it doesn't exist the value
31 // type will be default constructed which we use to detect insert.
32 //
33 // We use '+' as the sentinel value in the map.
26 std::pair insert(StringRef Key) {
3427 assert(!Key.empty());
35 StringMapEntry &Entry = this->GetOrCreateValue(Key);
36 if (Entry.getValue() == '+')
37 return false;
38 Entry.setValue('+');
39 return true;
28 return base::insert(std::make_pair(Key, '\0'));
4029 }
4130 };
4231 }
6161 continue;
6262 getContextName(SP.getContext().resolve(TypeIdentifierMap), Name);
6363 Name = Name + SP.getDisplayName().str();
64 if (!Name.empty() && Processed.insert(Name)) {
64 if (!Name.empty() && Processed.insert(Name).second) {
6565 Out << Name << "\n";
6666 }
6767 }
12181218 if (Prefix == "")
12191219 return false;
12201220
1221 if (!PrefixSet.insert(Prefix))
1221 if (!PrefixSet.insert(Prefix).second)
12221222 return false;
12231223
12241224 if (!ValidateCheckPrefix(Prefix))
453453 SmallVector, 8> Cases;
454454 for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) {
455455 CheckOpcodeMatcher *COM = cast(NewOptionsToMatch[i]);
456 assert(Opcodes.insert(COM->getOpcode().getEnumName()) &&
456 assert(Opcodes.insert(COM->getOpcode().getEnumName()).second &&
457457 "Duplicate opcodes not factored?");
458458 Cases.push_back(std::make_pair(&COM->getOpcode(), COM->getNext()));
459459 }