summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-11-19 02:56:00 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-11-19 02:56:00 +0000
commit0356975cb2119af0343819383bd6db2464c65766 (patch)
treec9e8205fcf88eaefb8ad1b5a27301ebf5832042e /llvm
parent51a4511b72721080b7afe59cf9dd0bf3b9252fad (diff)
downloadbcm5719-llvm-0356975cb2119af0343819383bd6db2464c65766.tar.gz
bcm5719-llvm-0356975cb2119af0343819383bd6db2464c65766.zip
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. llvm-svn: 222302
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/ADT/StringSet.h15
-rw-r--r--llvm/tools/opt/BreakpointPrinter.cpp2
-rw-r--r--llvm/utils/FileCheck/FileCheck.cpp2
-rw-r--r--llvm/utils/TableGen/DAGISelMatcherOpt.cpp2
4 files changed, 5 insertions, 16 deletions
diff --git a/llvm/include/llvm/ADT/StringSet.h b/llvm/include/llvm/ADT/StringSet.h
index 7bea577f34d..3e0cc200b6d 100644
--- a/llvm/include/llvm/ADT/StringSet.h
+++ b/llvm/include/llvm/ADT/StringSet.h
@@ -24,20 +24,9 @@ namespace llvm {
typedef llvm::StringMap<char, AllocatorTy> base;
public:
- /// insert - Insert the specified key into the set. If the key already
- /// exists in the set, return false and ignore the request, otherwise insert
- /// it and return true.
- bool insert(StringRef Key) {
- // Get or create the map entry for the key; if it doesn't exist the value
- // type will be default constructed which we use to detect insert.
- //
- // We use '+' as the sentinel value in the map.
+ std::pair<typename base::iterator, bool> insert(StringRef Key) {
assert(!Key.empty());
- StringMapEntry<char> &Entry = this->GetOrCreateValue(Key);
- if (Entry.getValue() == '+')
- return false;
- Entry.setValue('+');
- return true;
+ return base::insert(std::make_pair(Key, '\0'));
}
};
}
diff --git a/llvm/tools/opt/BreakpointPrinter.cpp b/llvm/tools/opt/BreakpointPrinter.cpp
index 44f4a11773e..3cbc0ae50f1 100644
--- a/llvm/tools/opt/BreakpointPrinter.cpp
+++ b/llvm/tools/opt/BreakpointPrinter.cpp
@@ -62,7 +62,7 @@ struct BreakpointPrinter : public ModulePass {
continue;
getContextName(SP.getContext().resolve(TypeIdentifierMap), Name);
Name = Name + SP.getDisplayName().str();
- if (!Name.empty() && Processed.insert(Name)) {
+ if (!Name.empty() && Processed.insert(Name).second) {
Out << Name << "\n";
}
}
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 9606e64d6f8..59affa1ada1 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -1219,7 +1219,7 @@ static bool ValidateCheckPrefixes() {
if (Prefix == "")
return false;
- if (!PrefixSet.insert(Prefix))
+ if (!PrefixSet.insert(Prefix).second)
return false;
if (!ValidateCheckPrefix(Prefix))
diff --git a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
index 0c18e0b1c29..7a22764ec35 100644
--- a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
@@ -454,7 +454,7 @@ static void FactorNodes(std::unique_ptr<Matcher> &MatcherPtr) {
SmallVector<std::pair<const SDNodeInfo*, Matcher*>, 8> Cases;
for (unsigned i = 0, e = NewOptionsToMatch.size(); i != e; ++i) {
CheckOpcodeMatcher *COM = cast<CheckOpcodeMatcher>(NewOptionsToMatch[i]);
- assert(Opcodes.insert(COM->getOpcode().getEnumName()) &&
+ assert(Opcodes.insert(COM->getOpcode().getEnumName()).second &&
"Duplicate opcodes not factored?");
Cases.push_back(std::make_pair(&COM->getOpcode(), COM->getNext()));
}
OpenPOWER on IntegriCloud