Esempio n. 1
0
File: xi_dom.cpp Progetto: dhuth/xcc
static void merge_declarations_with(
        ast_decl* decl,
        list<ast_decl>::iterator_t iter_start,
        ptr<list<ast_decl>> decl_list,
        xi_builder& b,
        decl_swap_map_t& swapmap,
        const std::vector<tree_type_id>& treetypes) {

    ast_decl*               merged_decl = decl;
    ptr<list<ast_decl>>     fwdlist     = new list<ast_decl>();

    auto iter = iter_start;
    while(iter < decl_list->end()) {
        auto decl_other = *iter;

        if(b.samedecl(merged_decl, decl_other)) {
            if(is_forward(decl_other)) {
                merged_decl = merge_decl(merged_decl, decl_other, b);
                fwdlist->push_back(decl_other);

                decl_list->erase(iter);
                continue;
            }
        }
        iter++;
    }

    for(auto fiter = fwdlist->begin(); fiter < fwdlist->end(); fiter++) {
        setfwd(*fiter, merged_decl);
        swapmap[*fiter] = merged_decl;
    }
}
Esempio n. 2
0
string DFS::to_string(bool print_edge_type) const
{
  std::stringstream ss;
  if(print_edge_type) {
    if(is_forward()) ss << "F";
    else ss << "B";
  }
  ss << "(" << from << " " << to << " " << fromlabel << " " << elabel << " " << tolabel << ")";
  return ss.str();
}
Esempio n. 3
0
void exception_loop (int line, const char *fcall, bool capchg,
                     Vector &vec, const Vector::iterator &it,
                     int n, const UserClass *x,
                     const Iterator &first, const Iterator &last,
                     std::size_t *n_copy, std::size_t *n_asgn)
{
    std::size_t throw_after = 0;

    const std::size_t            size     = vec.size ();
    const std::size_t            capacity = vec.capacity ();
    const Vector::const_iterator begin    = vec.begin ();

#ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE

    rwt_free_store* const pst = rwt_get_free_store (0);

#endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE

    // iterate for`n=throw_after' starting at the next call to operator
    // new, forcing each call to throw an exception, until the insertion
    // finally succeeds (i.e, no exception is thrown)
    for ( ; ; ) {

        *n_copy = UserClass::n_total_copy_ctor_;
        *n_asgn = UserClass::n_total_op_assign_;

#ifndef _RWSTD_NO_EXCEPTIONS

        // detect objects constructed but not destroyed after an exception
        const std::size_t count = UserClass::count_;

#  ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE

        // disable out of memory exceptions before copying iterators
        // (InputIter ctors may dynamically allocate memory)
        *pst->throw_at_calls_ [0] = std::size_t (-1);
#  endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE
#endif   // _RWSTD_NO_EXCEPTIONS

        // create "deep" copies of the iterators to thwart
        // InpuIter's multi-pass detection
        const Iterator beg = copy_iter (first, (UserClass*)0);
        const Iterator end = copy_iter (last, (UserClass*)0);

#ifndef _RWSTD_NO_EXCEPTIONS
#  ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE

        *pst->throw_at_calls_ [0] = pst->new_calls_ [0] + throw_after + 1;

#  endif   // _RWSTD_NO_REPLACEABLE_NEW_DELETE
#endif   // _RWSTD_NO_EXCEPTIONS

        _TRY {
            if (-2 == n) {
                vec.insert (it, *x);
            }
            else if (-1 == n) {

#ifndef _RWSTD_NO_EXT_VECTOR_INSERT_IN_PLACE
#  ifndef _RWSTD_NO_REPLACEABLE_NEW_DELETE
                // disable exceptions if Iterator is not at least
                // a ForwardIterator since the extension doesn't
                // provide the strong exception safety guarantee
                // required in 23.2.4.3, p1
                if (!is_forward (beg)) {
                    *pst->throw_at_calls_ [0] = std::size_t (-1);
                }
#  endif   //_RWSTD_NO_REPLACEABLE_NEW_DELETE
#endif   // _RWSTD_NO_EXT_VECTOR_INSERT_IN_PLACE

                vec.insert (it, beg, end);
            }
            else {
                vec.insert (it, n, *x);
            }
            break;
        }
        _CATCH (...) {

#ifndef _RWSTD_NO_EXCEPTIONS

            // verify that an exception thrown during allocation
            // doesn't cause a change in the state of the vector

            rw_assert (vec.size () == size, 0, line,
                       "line %d: %s: size unexpectedly changed "
                       "from %zu to %zu after an exception",
                       __LINE__, fcall, size, vec.size ());

            rw_assert (vec.capacity () == capacity, 0, line,
                       "line %d: %s: capacity unexpectedly "
                       "changed from %zu to %zu after an exception",
                       __LINE__, fcall, capacity, vec.capacity ());

            
            rw_assert (vec.begin () == begin, 0, line,
                       "line %d: %s: begin() unexpectedly "
                       "changed from after an exception by %d",
                       __LINE__, fcall, vec.begin () - begin);


            rw_assert (count == UserClass::count_, 0, line,
                       "line %d: %s: leaked %d objects "
                       "after an exception",
                       __LINE__, fcall, UserClass::count_ - count);

            // increment to allow this call to operator new to succeed
            // and force the next one to fail, and try to insert again
            ++throw_after;

#endif   // _RWSTD_NO_EXCEPTIONS

        }   // catch
    }   // for