<commit_before>//===- llvm/ADT/PostOrderIterator.h - PostOrder iterator --------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file builds on the ADT/GraphTraits.h file to build a generic graph
// post order iterator.  This should work over any graph type that has a
// GraphTraits specialization.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_ADT_POSTORDERITERATOR_H
#define LLVM_ADT_POSTORDERITERATOR_H

#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator"
#include <stack>
#include <set>

namespace llvm {

template<class SetType, bool External>   // Non-external set 
class po_iterator_storage { 
public: 
  SetType Visited; 
}; 

template<class SetType> 
class po_iterator_storage<SetType, true> { 
public: 
  po_iterator_storage(SetType &VSet) : Visited(VSet) {} 
  po_iterator_storage(const po_iterator_storage &S) : Visited(S.Visited) {} 
  SetType &Visited; 
}; 

template<class GraphT, 
        class SetType = std::set<typename GraphTraits<GraphT>::NodeType*>, 
        bool ExtStorage = false, 
        class GT = GraphTraits<GraphT> > 
class po_iterator : public forward_iterator<typename GT::NodeType, ptrdiff_t>, 
                    public po_iterator_storage<SetType, ExtStorage> { 
  typedef forward_iterator<typename GT::NodeType, ptrdiff_t> super;
  typedef typename GT::NodeType          NodeType;
  typedef typename GT::ChildIteratorType ChildItTy;

  std::set<NodeType *> Visited;    // All of the blocks visited so far...
  // VisitStack - Used to maintain the ordering.  Top = current block
  // First element is basic block pointer, second is the 'next child' to visit
  std::stack<std::pair<NodeType *, ChildItTy> > VisitStack;

  void traverseChild() {
    while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
      NodeType *BB = *VisitStack.top().second++;
      if (!this->Visited.count(BB)) {  // If the block is not visited...
        this->Visited.insert(BB);
        VisitStack.push(std::make_pair(BB, GT::child_begin(BB)));
      }
    }
  }

  inline po_iterator(NodeType *BB) {
    this->Visited.insert(BB);
    VisitStack.push(std::make_pair(BB, GT::child_begin(BB)));
    traverseChild();
  }
  inline po_iterator() {} // End is when stack is empty. 
     
  inline po_iterator(NodeType *BB, SetType &S) : 
    po_iterator_storage<SetType, ExtStorage>(&S) { 
    if(!S.count(BB)) { 
      this->Visited.insert(BB); 
      VisitStack.push(std::make_pair(BB, GT::child_begin(BB))); 
      traverseChild(); 
    } 
  } 
 
  inline po_iterator(SetType &S) : <commit_msg>Remove a now-dead map, patch by <NAME>, thanks!<commit_after>//===- llvm/ADT/PostOrderIterator.h - PostOrder iterator --------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file builds on the ADT/GraphTraits.h file to build a generic graph
// post order iterator.  This should work over any graph type that has a
// GraphTraits specialization.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_ADT_POSTORDERITERATOR_H
#define LLVM_ADT_POSTORDERITERATOR_H

#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/iterator"
#include <stack>
#include <set>

namespace llvm {

template<class SetType, bool External>   // Non-external set 
class po_iterator_storage { 
public: 
  SetType Visited; 
}; 

template<class SetType> 
class po_iterator_storage<SetType, true> { 
public: 
  po_iterator_storage(SetType &VSet) : Visited(VSet) {} 
  po_iterator_storage(const po_iterator_storage &S) : Visited(S.Visited) {} 
  SetType &Visited; 
}; 

template<class GraphT, 
        class SetType = std::set<typename GraphTraits<GraphT>::NodeType*>, 
        bool ExtStorage = false, 
        class GT = GraphTraits<GraphT> > 
class po_iterator : public forward_iterator<typename GT::NodeType, ptrdiff_t>, 
                    public po_iterator_storage<SetType, ExtStorage> { 
  typedef forward_iterator<typename GT::NodeType, ptrdiff_t> super;
  typedef typename GT::NodeType          NodeType;
  typedef typename GT::ChildIteratorType ChildItTy;
  
  // VisitStack - Used to maintain the ordering.  Top = current block
  // First element is basic block pointer, second is the 'next child' to visit
  std::stack<std::pair<NodeType *, ChildItTy> > VisitStack;

  void traverseChild() {
    while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
      NodeType *BB = *VisitStack.top().second++;
      if (!this->Visited.count(BB)) {  // If the block is not visited...
        this->Visited.insert(BB);
        VisitStack.push(std::make_pair(BB, GT::child_begin(BB)));
      }
    }
  }

  inline po_iterator(NodeType *BB) {
    this->Visited.insert(BB);
    VisitStack.push(std::make_pair(BB, GT::child_begin(BB)));
    traverseChild();
  }
  inline po_iterator() {} // End is when stack is empty. 
     
  inline po_iterator(NodeType *BB, SetType &S) : 
    po_iterator_storage<SetType, ExtStorage>(&S) { 
    if(!S.count(BB)) { 
      this->Visited.insert(BB); 
      VisitStack.push(std::make_pair(BB, GT::child_begin(BB))); 
      traverseChild(); 
    } 
  } 
 
  inline po_iterator(SetType &S) : 
{'fraction_non_alphanumeric': 0.17524509803921567, 'fraction_numerical': 0.0, 'mean_word_length': 2.7536136662286466, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4024102', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1703, 'n_words': 432}