- //===--------------------------------------------------------------------===//
- /// FoldingSet - This template class is used to instantiate a specialized
- /// implementation of the folding set to the node class T. T must be a
- /// subclass of FoldingSetNode and implement a Profile function.
- ///
- template<class T> class FoldingSet : public FoldingSetImpl {
- private:
- /// GetNodeProfile - Each instantiatation of the FoldingSet
- virtual void GetNodeProfile(NodeID &ID, Node *N) {
- T *TN = static_cast<T *>(N);
- TN->Profile(ID);
- }
-
- public:
- /// RemoveNode - Remove a node from the folding set, returning true if one
- /// was removed or false if the node was not in the folding set.
- bool RemoveNode(T *N) {
- return FoldingSetImpl::RemoveNode(static_cast<FoldingSetNode *>(N));
- }
-
- /// GetOrInsertNode - If there is an existing simple Node exactly
- /// equal to the specified node, return it. Otherwise, insert 'N' and
- /// return it instead.
- T *GetOrInsertNode(Node *N) {
- return static_cast<T *>(FoldingSetImpl::GetOrInsertNode(
- static_cast<FoldingSetNode *>(N)));
- }
-
- /// FindNodeOrInsertPos - Look up the node specified by ID. If it exists,
- /// return it. If not, return the insertion token that will make insertion
- /// faster.
- T *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos) {
- return static_cast<T *>(FoldingSetImpl::FindNodeOrInsertPos(ID,
- InsertPos));
- }
-
- /// InsertNode - Insert the specified node into the folding set, knowing
- /// that it is not already in the folding set. InsertPos must be obtained
- /// from FindNodeOrInsertPos.
- void InsertNode(T *N, void *InsertPos) {
- FoldingSetImpl::InsertNode(static_cast<FoldingSetNode *>(N), InsertPos);
- }
- };
+// Convenience types to hide the implementation of the folding set.
+typedef FoldingSetImpl::Node FoldingSetNode;
+typedef FoldingSetImpl::NodeID FoldingSetNodeID;
+
+//===--------------------------------------------------------------------===//
+/// FoldingSet - This template class is used to instantiate a specialized
+/// implementation of the folding set to the node class T. T must be a
+/// subclass of FoldingSetNode and implement a Profile function.
+///
+template<class T> class FoldingSet : public FoldingSetImpl {
+private:
+ /// GetNodeProfile - Each instantiatation of the FoldingSet
+ virtual void GetNodeProfile(NodeID &ID, Node *N) const {
+ T *TN = static_cast<T *>(N);
+ TN->Profile(ID);
+ }
+
+public:
+ /// GetOrInsertNode - If there is an existing simple Node exactly
+ /// equal to the specified node, return it. Otherwise, insert 'N' and
+ /// return it instead.
+ T *GetOrInsertNode(Node *N) {
+ return static_cast<T *>(FoldingSetImpl::GetOrInsertNode(N));
+ }
+
+ /// FindNodeOrInsertPos - Look up the node specified by ID. If it exists,
+ /// return it. If not, return the insertion token that will make insertion
+ /// faster.
+ T *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos) {
+ return static_cast<T *>(FoldingSetImpl::FindNodeOrInsertPos(ID,
+ InsertPos));
+ }
+};